@@ -43,6 +43,7 @@ import (
4343 "github.com/ledgerwatch/erigon/turbo/engineapi"
4444 "github.com/ledgerwatch/erigon/turbo/engineapi/engine_helpers"
4545 "github.com/ledgerwatch/erigon/turbo/jsonrpc"
46+ "github.com/ledgerwatch/erigon/turbo/rpchelper"
4647 "github.com/ledgerwatch/erigon/turbo/snapshotsync/freezeblocks"
4748 "github.com/ledgerwatch/erigon/turbo/snapshotsync/snap"
4849
@@ -74,11 +75,13 @@ import (
7475 "github.com/ledgerwatch/erigon-lib/txpool/txpooluitl"
7576 types2 "github.com/ledgerwatch/erigon-lib/types"
7677
78+ txpool2 "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
7779 "github.com/ledgerwatch/erigon/cl/clparams"
7880 "github.com/ledgerwatch/erigon/cl/cltypes"
7981 "github.com/ledgerwatch/erigon/cl/fork"
8082 "github.com/ledgerwatch/erigon/cmd/caplin-phase1/caplin1"
8183 "github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
84+ "github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli/httpcfg"
8285 "github.com/ledgerwatch/erigon/cmd/sentinel/sentinel"
8386 "github.com/ledgerwatch/erigon/cmd/sentinel/sentinel/service"
8487 "github.com/ledgerwatch/erigon/cmd/sentry/sentry"
@@ -114,6 +117,12 @@ import (
114117 "github.com/ledgerwatch/erigon/turbo/stages/headerdownload"
115118)
116119
120+ type StartableEngineRPC interface {
121+ Start (httpConfig httpcfg.HttpCfg ,
122+ filters * rpchelper.Filters , stateCache kvcache.Cache , agg * libstate.AggregatorV3 , engineReader consensus.EngineReader ,
123+ eth rpchelper.ApiBackend , txPool txpool2.TxpoolClient , mining txpool2.MiningClient )
124+ }
125+
117126// Config contains the configuration options of the ETH protocol.
118127// Deprecated: use ethconfig.Config instead.
119128type Config = ethconfig.Config
@@ -139,7 +148,7 @@ type Ethereum struct {
139148 genesisHash libcommon.Hash
140149
141150 ethBackendRPC * privateapi.EthBackendServer
142- engineBackendRPC * engineapi. EngineServer
151+ engineBackendRPC StartableEngineRPC
143152 miningRPC txpool_proto.MiningServer
144153 stateChangesClient txpool.StateChangesClient
145154
@@ -558,7 +567,22 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
558567 // Initialize ethbackend
559568 ethBackendRPC := privateapi .NewEthBackendServer (ctx , backend , backend .chainDB , backend .notifications .Events , blockReader , logger , latestBlockBuiltStore )
560569 // intiialize engine backend
561- backend .engineBackendRPC = engineapi .NewEngineServer (ctx , logger , chainConfig , assembleBlockPOS , backend .chainDB , blockReader , backend .sentriesClient .Hd , config .Miner .EnabledPOS )
570+ var engine * execution_client.ExecutionClientDirect
571+
572+ if config .ExperimentalConsensusSeparation {
573+ log .Info ("Using experimental Engine API" )
574+ engineBackendRPC := engineapi .NewEngineServerExperimental (ctx , logger , chainConfig , assembleBlockPOS , backend .chainDB , blockReader , backend .sentriesClient .Hd , config .Miner .EnabledPOS )
575+ backend .engineBackendRPC = engineBackendRPC
576+ engine , err = execution_client .NewExecutionClientDirect (ctx ,
577+ engineBackendRPC ,
578+ )
579+ } else {
580+ engineBackendRPC := engineapi .NewEngineServer (ctx , logger , chainConfig , assembleBlockPOS , backend .chainDB , blockReader , backend .sentriesClient .Hd , config .Miner .EnabledPOS )
581+ backend .engineBackendRPC = engineBackendRPC
582+ engine , err = execution_client .NewExecutionClientDirect (ctx ,
583+ engineBackendRPC ,
584+ )
585+ }
562586
563587 miningRPC = privateapi .NewMiningServer (ctx , backend , ethashApi , logger )
564588
@@ -630,10 +654,6 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
630654 return nil , fmt .Errorf ("could not load jwt for Caplin: %s" , err )
631655 }
632656
633- engine , err := execution_client .NewExecutionClientDirect (ctx ,
634- backend .engineBackendRPC ,
635- )
636-
637657 if err != nil {
638658 return nil , err
639659 }
0 commit comments