Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,13 @@ func createHandler(cfg *httpcfg.HttpCfg, apiList []rpc.API, httpHandler http.Han
return
}

// EIP-8161: Route /engine/* paths to SSZ-REST handler,
// everything else (/) to JSON-RPC handler.
if cfg.SszRestHandler != nil && strings.HasPrefix(r.URL.Path, "/engine/") {
cfg.SszRestHandler.ServeHTTP(w, r)
return
}

httpHandler.ServeHTTP(w, r)
})

Expand Down
5 changes: 5 additions & 0 deletions cmd/rpcdaemon/cli/httpcfg/http_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package httpcfg

import (
"net/http"
"time"

"github.com/erigontech/erigon/db/datadir"
Expand Down Expand Up @@ -114,4 +115,8 @@ type HttpCfg struct {

RpcTxSyncDefaultTimeout time.Duration // Default timeout for eth_sendRawTransactionSync
RpcTxSyncMaxTimeout time.Duration // Maximum timeout for eth_sendRawTransactionSync

// EIP-8161: SSZ-REST Engine API Transport — handler injected by EngineServer,
// served on the same port as JSON-RPC (path-based routing).
SszRestHandler http.Handler
}
8 changes: 8 additions & 0 deletions execution/engineapi/engine_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ type EngineServer struct {
// TODO Remove this on next release
printPectraBanner bool
maxReorgDepth uint64
httpConfig *httpcfg.HttpCfg
}

func NewEngineServer(
Expand Down Expand Up @@ -151,6 +152,7 @@ func (e *EngineServer) Start(
return nil
})
}
e.httpConfig = httpConfig
base := jsonrpc.NewBaseApi(filters, stateCache, blockReader, httpConfig.WithDatadir, httpConfig.EvmCallTimeout, engineReader, httpConfig.Dirs, nil, httpConfig.BlockRangeLimit, httpConfig.GetLogsMaxResults)
ethImpl := jsonrpc.NewEthAPI(base, db, eth, e.txpool, mining, jsonrpc.NewEthApiConfig(httpConfig), e.logger)

Expand All @@ -167,6 +169,11 @@ func (e *EngineServer) Start(
Version: "1.0",
}}

// EIP-8161: Register SSZ-REST handler on the same port as JSON-RPC.
// Path-based routing: /engine/* → SSZ-REST, / → JSON-RPC
httpConfig.SszRestHandler = NewSszRestHandler(e, e.logger)
e.logger.Info("[EngineServer] SSZ-REST routes registered on Engine API port")

eg.Go(func() error {
defer e.logger.Debug("[EngineServer] engine rpc server goroutine terminated")
err := cli.StartRpcServerWithJwtAuthentication(ctx, httpConfig, apiList, e.logger)
Expand All @@ -175,6 +182,7 @@ func (e *EngineServer) Start(
}
return err
})

return eg.Wait()
}

Expand Down
Loading
Loading