added --internalcl flag to Erigon (#7349)

This commit is contained in:
Giulio rebuffo 2023-04-19 14:37:35 +02:00 committed by GitHub
parent c39cc6a441
commit 2ce5e761bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 24 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -241,7 +241,7 @@ type Config struct {
// Ethstats service
Ethstats string
// Consensus layer
ExternalCL bool
InternalCL bool
LightClientDiscoveryAddr string
LightClientDiscoveryPort uint64
LightClientDiscoveryTCPPort uint64

View File

@ -12,7 +12,7 @@ var DefaultFlags = []cli.Flag{
&utils.DataDirFlag,
&utils.EthashDatasetDirFlag,
&utils.SnapshotFlag,
&utils.ExternalConsensusFlag,
&utils.InternalConsensusFlag,
&utils.TxPoolDisableFlag,
&utils.TxPoolLocalsFlag,
&utils.TxPoolNoLocalsFlag,