From 2ce5e761bb07a3a45fad302ed60a7efdfcd8fb1f Mon Sep 17 00:00:00 2001 From: Giulio rebuffo Date: Wed, 19 Apr 2023 14:37:35 +0200 Subject: [PATCH] added --internalcl flag to Erigon (#7349) --- README.md | 6 +++--- cmd/rpcdaemon/commands/engine_api.go | 18 ++++++++---------- cmd/utils/flags.go | 13 +++++-------- eth/backend.go | 2 +- eth/ethconfig/config.go | 2 +- turbo/cli/default_flags.go | 2 +- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5d5c9a2e4..efd226a97 100644 --- a/README.md +++ b/README.md @@ -157,10 +157,10 @@ How to start Erigon's services as separated processes, see in [docker-compose.ym ### Embedded Consensus Layer -By default, on Ethereum Mainnet, Görli, and Sepolia, the Engine API is disabled in favour of the Erigon native Embedded +On Ethereum Mainnet, Görli, and Sepolia, the Engine API can be disabled in favour of the Erigon native Embedded Consensus Layer. -If you want to use an external Consensus Layer, run Erigon with flag `--externalcl`. -_Warning:_ Staking (block production) is not possible with the embedded CL – use `--externalcl` instead. +If you want to use the internal Consensus Layer, run Erigon with flag `--internalcl`. +_Warning:_ Staking (block production) is not possible with the embedded CL. ### Testnets diff --git a/cmd/rpcdaemon/commands/engine_api.go b/cmd/rpcdaemon/commands/engine_api.go index b50e21c23..9e075526d 100644 --- a/cmd/rpcdaemon/commands/engine_api.go +++ b/cmd/rpcdaemon/commands/engine_api.go @@ -3,6 +3,7 @@ package commands import ( "context" "encoding/binary" + "errors" "fmt" "math/big" @@ -165,10 +166,11 @@ func withdrawalValues(ptrs []*types.Withdrawal) []types.Withdrawal { return vals } +var errEmbedeedConsensus = errors.New("engine api should not be used, restart without --internalcl") + func (e *EngineImpl) forkchoiceUpdated(version uint32, ctx context.Context, forkChoiceState *ForkChoiceState, payloadAttributes *PayloadAttributes) (map[string]interface{}, error) { if e.internalCL { - log.Error("EXTERNAL CONSENSUS LAYER IS NOT ENABLED, PLEASE RESTART WITH FLAG --externalcl") - return nil, fmt.Errorf("engine api should not be used, restart with --externalcl") + return nil, errEmbedeedConsensus } if payloadAttributes == nil { log.Debug("Received ForkchoiceUpdated", "version", version, @@ -232,8 +234,7 @@ func (e *EngineImpl) NewPayloadV2(ctx context.Context, payload *ExecutionPayload func (e *EngineImpl) newPayload(version uint32, ctx context.Context, payload *ExecutionPayload) (map[string]interface{}, error) { if e.internalCL { - log.Error("EXTERNAL CONSENSUS LAYER IS NOT ENABLED, PLEASE RESTART WITH FLAG --externalcl") - return nil, fmt.Errorf("engine api should not be used, restart with --externalcl") + return nil, errEmbedeedConsensus } log.Debug("Received NewPayload", "version", version, "height", uint64(payload.BlockNumber), "hash", payload.BlockHash) @@ -327,8 +328,7 @@ func convertPayloadFromRpc(payload *types2.ExecutionPayload) *ExecutionPayload { func (e *EngineImpl) GetPayloadV1(ctx context.Context, payloadID hexutility.Bytes) (*ExecutionPayload, error) { if e.internalCL { - log.Error("EXTERNAL CONSENSUS LAYER IS NOT ENABLED, PLEASE RESTART WITH FLAG --externalcl") - return nil, fmt.Errorf("engine api should not be used, restart with --externalcl") + return nil, errEmbedeedConsensus } decodedPayloadId := binary.BigEndian.Uint64(payloadID) @@ -344,8 +344,7 @@ func (e *EngineImpl) GetPayloadV1(ctx context.Context, payloadID hexutility.Byte func (e *EngineImpl) GetPayloadV2(ctx context.Context, payloadID hexutility.Bytes) (*GetPayloadV2Response, error) { if e.internalCL { - log.Error("EXTERNAL CONSENSUS LAYER IS NOT ENABLED, PLEASE RESTART WITH FLAG --externalcl") - return nil, fmt.Errorf("engine api should not be used, restart with --externalcl") + return nil, errEmbedeedConsensus } decodedPayloadId := binary.BigEndian.Uint64(payloadID) @@ -369,8 +368,7 @@ func (e *EngineImpl) GetPayloadV2(ctx context.Context, payloadID hexutility.Byte // See https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.1/src/engine/specification.md#engine_exchangetransitionconfigurationv1 func (e *EngineImpl) ExchangeTransitionConfigurationV1(ctx context.Context, beaconConfig *TransitionConfiguration) (*TransitionConfiguration, error) { if e.internalCL { - log.Error("EXTERNAL CONSENSUS LAYER IS NOT ENABLED, PLEASE RESTART WITH FLAG --externalcl") - return nil, fmt.Errorf("engine api should not be used, restart with --externalcl") + return nil, errEmbedeedConsensus } tx, err := e.db.BeginRo(ctx) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 3c865e087..376842dca 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -131,8 +131,8 @@ var ( Usage: `Default: use snapshots "true" for Mainnet, Goerli, Gnosis Chain and Chiado. use snapshots "false" in all other cases`, Value: true, } - ExternalConsensusFlag = cli.BoolFlag{ - Name: "externalcl", + InternalConsensusFlag = cli.BoolFlag{ + Name: "internalcl", Usage: "enables external consensus", } // Transaction pool settings @@ -1585,13 +1585,10 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C cfg.TxPool.OverrideShanghaiTime = cfg.OverrideShanghaiTime } - if ctx.IsSet(ExternalConsensusFlag.Name) { - cfg.ExternalCL = ctx.Bool(ExternalConsensusFlag.Name) - } else { - cfg.ExternalCL = !clparams.EmbeddedEnabledByDefault(cfg.NetworkID) + if ctx.IsSet(InternalConsensusFlag.Name) && clparams.EmbeddedEnabledByDefault(cfg.NetworkID) { + cfg.InternalCL = ctx.Bool(InternalConsensusFlag.Name) } - - nodeConfig.Http.InternalCL = !cfg.ExternalCL + nodeConfig.Http.InternalCL = cfg.InternalCL if ctx.IsSet(SentryDropUselessPeers.Name) { cfg.DropUselessPeers = ctx.Bool(SentryDropUselessPeers.Name) diff --git a/eth/backend.go b/eth/backend.go index 52dc233c8..a9d46f87c 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -555,7 +555,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { } // If we choose not to run a consensus layer, run our embedded. - if !config.ExternalCL && clparams.EmbeddedSupported(config.NetworkID) { + if config.InternalCL && clparams.EmbeddedSupported(config.NetworkID) { genesisCfg, networkCfg, beaconCfg := clparams.GetConfigsByNetwork(clparams.NetworkType(config.NetworkID)) if err != nil { return nil, err diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 4bbbc670e..f3882fcb2 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -241,7 +241,7 @@ type Config struct { // Ethstats service Ethstats string // Consensus layer - ExternalCL bool + InternalCL bool LightClientDiscoveryAddr string LightClientDiscoveryPort uint64 LightClientDiscoveryTCPPort uint64 diff --git a/turbo/cli/default_flags.go b/turbo/cli/default_flags.go index 530a96864..29ebc26b1 100644 --- a/turbo/cli/default_flags.go +++ b/turbo/cli/default_flags.go @@ -12,7 +12,7 @@ var DefaultFlags = []cli.Flag{ &utils.DataDirFlag, &utils.EthashDatasetDirFlag, &utils.SnapshotFlag, - &utils.ExternalConsensusFlag, + &utils.InternalConsensusFlag, &utils.TxPoolDisableFlag, &utils.TxPoolLocalsFlag, &utils.TxPoolNoLocalsFlag,