From 56e806a99c53b5a3891d14b5958f0f87c7f2fb2c Mon Sep 17 00:00:00 2001 From: Giulio Rebuffo Date: Mon, 27 Mar 2023 11:22:17 +0200 Subject: [PATCH] removed --el.enabled --- cmd/erigon-cl/main.go | 12 ++--- .../stages/stage_history_reconstruction.go | 2 +- cmd/erigon-cl/stages/stages_beacon_state.go | 50 +++++++++---------- cmd/sentinel/cli/cliSettings.go | 2 - cmd/sentinel/cli/flags/defaultFlags.go | 2 - cmd/sentinel/cli/flags/flags.go | 5 -- 6 files changed, 28 insertions(+), 45 deletions(-) diff --git a/cmd/erigon-cl/main.go b/cmd/erigon-cl/main.go index 7534d250691..3f288428fe6 100644 --- a/cmd/erigon-cl/main.go +++ b/cmd/erigon-cl/main.go @@ -62,13 +62,10 @@ func runConsensusLayerNode(cliCtx *cli.Context) error { } tmpdir := "/tmp" - var executionClient *execution_client.ExecutionClient - if cfg.ELEnabled { - executionClient, err = execution_client.NewExecutionClient(ctx, "127.0.0.1:8989") - if err != nil { - log.Warn("Could not connect to execution client", "err", err) - return err - } + executionClient, err := execution_client.NewExecutionClient(ctx, "127.0.0.1:8989") + if err != nil { + log.Warn("Could not connect to execution client", "err", err) + return err } if cfg.TransitionChain { @@ -80,7 +77,6 @@ func runConsensusLayerNode(cliCtx *cli.Context) error { return stages.SpawnStageBeaconState(stages.StageBeaconState(db, cfg.BeaconCfg, state, executionClient), nil, ctx) } - fmt.Println(cfg.CheckpointUri) // Fetch the checkpoint state. cpState, err := getCheckpointState(ctx, db, cfg.BeaconCfg, cfg.GenesisCfg, cfg.CheckpointUri) if err != nil { diff --git a/cmd/erigon-cl/stages/stage_history_reconstruction.go b/cmd/erigon-cl/stages/stage_history_reconstruction.go index b3e26a0156c..beb659efc4b 100644 --- a/cmd/erigon-cl/stages/stage_history_reconstruction.go +++ b/cmd/erigon-cl/stages/stage_history_reconstruction.go @@ -126,7 +126,7 @@ func SpawnStageHistoryReconstruction(cfg StageHistoryReconstructionCfg, s *stage return false, err } // Collect Execution Payloads - if cfg.executionClient != nil && blk.Version() >= clparams.BellatrixVersion && !foundLatestEth1ValidHash { + if blk.Version() >= clparams.BellatrixVersion && !foundLatestEth1ValidHash { payload := blk.Block.Body.ExecutionPayload if foundLatestEth1ValidHash, err = cfg.executionClient.IsCanonical(payload.BlockHash); err != nil { return false, err diff --git a/cmd/erigon-cl/stages/stages_beacon_state.go b/cmd/erigon-cl/stages/stages_beacon_state.go index 6dd9fff0fbf..65f66450ca4 100644 --- a/cmd/erigon-cl/stages/stages_beacon_state.go +++ b/cmd/erigon-cl/stages/stages_beacon_state.go @@ -64,39 +64,35 @@ func SpawnStageBeaconState(cfg StageBeaconStateCfg, tx kv.RwTx, ctx context.Cont if err != nil { return err } - // TODO: Pass this to state transition with the state - if cfg.executionClient != nil { - // Query execution engine only if the payload have an hash. - if eth1Hash != (libcommon.Hash{}) { - if block.Block.Body.ExecutionPayload, err = cfg.executionClient.ReadExecutionPayload(eth1Number, eth1Hash); err != nil { - return err - } - } - // validate fully only in current epoch. - fullValidate := utils.GetCurrentEpoch(cfg.state.GenesisTime(), cfg.beaconCfg.SecondsPerSlot, cfg.beaconCfg.SlotsPerEpoch) == cfg.state.Epoch() - if err := transition.TransitionState(cfg.state, block, fullValidate); err != nil { - log.Info("Found epoch, so stopping now...", "count", slot-(fromSlot+1), "slot", slot) + + // Query execution engine only if the payload have an hash. + if eth1Hash != (libcommon.Hash{}) { + if block.Block.Body.ExecutionPayload, err = cfg.executionClient.ReadExecutionPayload(eth1Number, eth1Hash); err != nil { return err } - log.Info("Applied state transition", "from", slot, "to", slot+1) } - } - // If successful update fork choice - if cfg.executionClient != nil { - finalizedRoot, err := rawdb.ReadFinalizedBlockRoot(tx, endSlot) - if err != nil { - return err - } - _, _, eth1Hash, _, err := rawdb.ReadBeaconBlockForStorage(tx, finalizedRoot, endSlot) - if err != nil { - return err - } - receipt, err := cfg.executionClient.ForkChoiceUpdate(eth1Hash) - if err != nil { + // validate fully only in current epoch. + fullValidate := utils.GetCurrentEpoch(cfg.state.GenesisTime(), cfg.beaconCfg.SecondsPerSlot, cfg.beaconCfg.SlotsPerEpoch) == cfg.state.Epoch() + if err := transition.TransitionState(cfg.state, block, fullValidate); err != nil { + log.Info("Found epoch, so stopping now...", "count", slot-(fromSlot+1), "slot", slot) return err } - log.Info("Forkchoice Status", "outcome", receipt.Success) + log.Info("Applied state transition", "from", slot, "to", slot+1) + } + // If successful update fork choice + finalizedRoot, err := rawdb.ReadFinalizedBlockRoot(tx, endSlot) + if err != nil { + return err + } + _, _, eth1Hash, _, err := rawdb.ReadBeaconBlockForStorage(tx, finalizedRoot, endSlot) + if err != nil { + return err + } + receipt, err := cfg.executionClient.ForkChoiceUpdate(eth1Hash) + if err != nil { + return err } + log.Info("Forkchoice Status", "outcome", receipt.Success) log.Info("[BeaconState] Finished transitioning state", "from", fromSlot, "to", endSlot) if !useExternalTx { diff --git a/cmd/sentinel/cli/cliSettings.go b/cmd/sentinel/cli/cliSettings.go index 0d490009305..765a3384bb3 100644 --- a/cmd/sentinel/cli/cliSettings.go +++ b/cmd/sentinel/cli/cliSettings.go @@ -25,7 +25,6 @@ type ConsensusClientCliCfg struct { NoDiscovery bool `json:"noDiscovery"` CheckpointUri string `json:"checkpointUri"` Chaindata string `json:"chaindata"` - ELEnabled bool `json:"elEnabled"` ErigonPrivateApi string `json:"erigonPrivateApi"` TransitionChain bool `json:"transitionChain"` NetworkType clparams.NetworkType @@ -69,7 +68,6 @@ func SetupConsensusClientCfg(ctx *cli.Context) (*ConsensusClientCliCfg, error) { fmt.Println(cfg.CheckpointUri) } cfg.Chaindata = ctx.String(flags.ChaindataFlag.Name) - cfg.ELEnabled = ctx.Bool(flags.ELEnabledFlag.Name) cfg.BeaconDataCfg = rawdb.BeaconDataConfigurations[ctx.String(flags.BeaconDBModeFlag.Name)] // Process bootnodes if ctx.String(flags.BootnodesFlag.Name) != "" { diff --git a/cmd/sentinel/cli/flags/defaultFlags.go b/cmd/sentinel/cli/flags/defaultFlags.go index 64688890859..a8488516ac0 100644 --- a/cmd/sentinel/cli/flags/defaultFlags.go +++ b/cmd/sentinel/cli/flags/defaultFlags.go @@ -12,7 +12,6 @@ var CLDefaultFlags = []cli.Flag{ &SentinelTcpPort, &NoDiscovery, &ChaindataFlag, - &ELEnabledFlag, &BeaconDBModeFlag, &BootnodesFlag, &BeaconConfigFlag, @@ -31,7 +30,6 @@ var LCDefaultFlags = []cli.Flag{ &SentinelTcpPort, &NoDiscovery, &ChaindataFlag, - &ELEnabledFlag, &BeaconDBModeFlag, &BootnodesFlag, &BeaconConfigFlag, diff --git a/cmd/sentinel/cli/flags/flags.go b/cmd/sentinel/cli/flags/flags.go index 04d2f8cb68e..20ac6dc765a 100644 --- a/cmd/sentinel/cli/flags/flags.go +++ b/cmd/sentinel/cli/flags/flags.go @@ -63,11 +63,6 @@ var ( Usage: "chaindata of database", Value: "", } - ELEnabledFlag = cli.BoolFlag{ - Name: "el.enabled", - Usage: "enables EL support", - Value: false, - } BeaconDBModeFlag = cli.StringFlag{ Name: "beacon-db-mode", Usage: "level of storing on beacon chain, minimal(only 500k blocks stored), full (all blocks stored), light (no blocks stored)",