From a86f4b70be52ca2947605dcb139d1866243c8c0f Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 15:45:40 -0700 Subject: [PATCH 01/17] bet --- .../core/state_processor_staking.go | 67 +++++++++++-------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index 41cc4437d8..ddb1fc2584 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -37,47 +37,58 @@ func (sp *StateProcessor) processOperations( st *state.StateDB, blk *ctypes.BeaconBlock, ) error { - // Verify that outstanding deposits are processed up to the maximum number of deposits. - // - // Unlike Eth 2.0 specs we don't check that - // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)` - deposits := blk.GetBody().GetDeposits() - if uint64(len(deposits)) > sp.cs.MaxDepositsPerBlock() { - return errors.Wrapf( - ErrExceedsBlockDepositLimit, "expected: %d, got: %d", - sp.cs.MaxDepositsPerBlock(), len(deposits), - ) - } - - // Instead we directly compare block deposits with our local store ones. - if err := ValidateNonGenesisDeposits( - ctx.ConsensusCtx(), - st, - sp.ds, - sp.cs.MaxDepositsPerBlock(), - deposits, - blk.GetBody().GetEth1Data().DepositRoot, - ); err != nil { - return err - } + if version.IsBefore(blk.GetForkVersion(), version.Electra()) { + + // Verify that outstanding deposits are processed up to the maximum number of deposits. + // + // Unlike Eth 2.0 specs we don't check that + // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)` + deposits := blk.GetBody().GetDeposits() + if uint64(len(deposits)) > sp.cs.MaxDepositsPerBlock() { + return errors.Wrapf( + ErrExceedsBlockDepositLimit, "expected: %d, got: %d", + sp.cs.MaxDepositsPerBlock(), len(deposits), + ) + } - for _, dep := range deposits { - if err := sp.processDeposit(st, dep); err != nil { + // Instead we directly compare block deposits with our local store ones. + if err := ValidateNonGenesisDeposits( + ctx.ConsensusCtx(), + st, + sp.ds, + sp.cs.MaxDepositsPerBlock(), + deposits, + blk.GetBody().GetEth1Data().DepositRoot, + ); err != nil { return err } - } - if version.EqualsOrIsAfter(blk.GetForkVersion(), version.Electra()) { - // After Electra, validators can request withdrawals through execution requests which must be handled. + for _, dep := range deposits { + if err := sp.processDeposit(st, dep); err != nil { + return err + } + } + } else { + // After Electra, validators can request withdrawals through execution requests which must + // be handled. requests, err := blk.GetBody().GetExecutionRequests() if err != nil { return err } + + // EIP-7002 Withdrawals. for _, withdrawal := range requests.Withdrawals { if withdrawErr := sp.processWithdrawalRequest(st, withdrawal); withdrawErr != nil { return withdrawErr } } + + // EIP-6110 Deposits. + for _, dep := range requests.Deposits { + if err := sp.processDeposit(st, dep); err != nil { + return err + } + } } return st.SetEth1Data(blk.GetBody().Eth1Data) From 275e1397ea14edb433628e808a716c32d7298363 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 15:47:38 -0700 Subject: [PATCH 02/17] nit --- state-transition/core/state_processor_staking.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index ddb1fc2584..ab83b9767a 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -69,7 +69,7 @@ func (sp *StateProcessor) processOperations( } } } else { - // After Electra, validators can request withdrawals through execution requests which must + // After Electra, validators increase/decrease stake through execution requests which must // be handled. requests, err := blk.GetBody().GetExecutionRequests() if err != nil { From fbfdcc58cbbe90dec7c110b77fb197d846a96f93 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 15:49:27 -0700 Subject: [PATCH 03/17] empty eth1data --- .../core/state_processor_staking.go | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index ab83b9767a..2f76d25759 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -68,30 +68,32 @@ func (sp *StateProcessor) processOperations( return err } } - } else { - // After Electra, validators increase/decrease stake through execution requests which must - // be handled. - requests, err := blk.GetBody().GetExecutionRequests() - if err != nil { - return err - } - // EIP-7002 Withdrawals. - for _, withdrawal := range requests.Withdrawals { - if withdrawErr := sp.processWithdrawalRequest(st, withdrawal); withdrawErr != nil { - return withdrawErr - } + return st.SetEth1Data(blk.GetBody().Eth1Data) + } + + // After Electra, validators increase/decrease stake through execution requests which must + // be handled. + requests, err := blk.GetBody().GetExecutionRequests() + if err != nil { + return err + } + + // EIP-7002 Withdrawals. + for _, withdrawal := range requests.Withdrawals { + if withdrawErr := sp.processWithdrawalRequest(st, withdrawal); withdrawErr != nil { + return withdrawErr } + } - // EIP-6110 Deposits. - for _, dep := range requests.Deposits { - if err := sp.processDeposit(st, dep); err != nil { - return err - } + // EIP-6110 Deposits. + for _, dep := range requests.Deposits { + if err := sp.processDeposit(st, dep); err != nil { + return err } } - return st.SetEth1Data(blk.GetBody().Eth1Data) + return st.SetEth1Data(ctypes.NewEmptyEth1Data()) } // processDeposit processes the deposit and ensures it matches the local state. From d39fb79f5344bb1380bcad18bf2d266f15d58a3b Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 15:50:41 -0700 Subject: [PATCH 04/17] nit --- state-transition/core/state_processor_staking.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index 2f76d25759..9c22cf5f9b 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -38,11 +38,11 @@ func (sp *StateProcessor) processOperations( blk *ctypes.BeaconBlock, ) error { if version.IsBefore(blk.GetForkVersion(), version.Electra()) { - - // Verify that outstanding deposits are processed up to the maximum number of deposits. + // Before Electra, deposits are processed from the beacon block body directly. // - // Unlike Eth 2.0 specs we don't check that - // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)` + // Verify that outstanding deposits are processed up to the maximum number of deposits. + // Unlike Ethereum 2.0 specs, we don't check that + // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)`. deposits := blk.GetBody().GetDeposits() if uint64(len(deposits)) > sp.cs.MaxDepositsPerBlock() { return errors.Wrapf( @@ -51,7 +51,7 @@ func (sp *StateProcessor) processOperations( ) } - // Instead we directly compare block deposits with our local store ones. + // Instead, we directly compare block deposits with our local store ones. if err := ValidateNonGenesisDeposits( ctx.ConsensusCtx(), st, From a6f4d3b44e97ce3c2dbf53c596834206cc56fdc5 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 16:03:59 -0700 Subject: [PATCH 05/17] more simplifications --- beacon/blockchain/finalize_block.go | 10 +++- beacon/validator/block_builder.go | 55 ++++++++++--------- .../core/state_processor_staking.go | 8 +-- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/beacon/blockchain/finalize_block.go b/beacon/blockchain/finalize_block.go index f2dccffe46..1395fba4f3 100644 --- a/beacon/blockchain/finalize_block.go +++ b/beacon/blockchain/finalize_block.go @@ -29,6 +29,7 @@ import ( "github.com/berachain/beacon-kit/consensus/types" "github.com/berachain/beacon-kit/primitives/math" "github.com/berachain/beacon-kit/primitives/transition" + "github.com/berachain/beacon-kit/primitives/version" statedb "github.com/berachain/beacon-kit/state-transition/core/state" cmtabci "github.com/cometbft/cometbft/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -109,9 +110,12 @@ func (s *Service) FinalizeBlock( // STEP 4: Post Finalizations cleanups. - // Fetch and store the deposit for the block. - blockNum := blk.GetBody().GetExecutionPayload().GetNumber() - s.depositFetcher(ctx, blockNum) + // Before Electra1, deposits must be fetched from the EL directly in the CL. + if version.IsBefore(blk.GetForkVersion(), version.Electra1()) { + // Fetch and store the deposit for the block. + blockNum := blk.GetBody().GetExecutionPayload().GetNumber() + s.depositFetcher(ctx, blockNum) + } // Store the finalized block in the KVStore. // diff --git a/beacon/validator/block_builder.go b/beacon/validator/block_builder.go index 9393fbfa4a..4eed537483 100644 --- a/beacon/validator/block_builder.go +++ b/beacon/validator/block_builder.go @@ -291,36 +291,39 @@ func (s *Service) buildBlockBody( // Set the KZG commitments on the block body. body.SetBlobKzgCommitments(blobsBundle.GetCommitments()) - // Dequeue deposits from the state. - depositIndex, err := st.GetEth1DepositIndex() - if err != nil { - return fmt.Errorf("failed loading eth1 deposit index: %w", err) - } + // Before Electra1, deposits are processed from the beacon block body directly. + if version.IsBefore(body.GetForkVersion(), version.Electra1()) { + // Dequeue deposits from the state. + depositIndex, err := st.GetEth1DepositIndex() + if err != nil { + return fmt.Errorf("failed loading eth1 deposit index: %w", err) + } - // Grab all previous deposits from genesis up to the current index + max deposits per block. - deposits, err := s.sb.DepositStore().GetDepositsByIndex( - ctx, - constants.FirstDepositIndex, - depositIndex+s.chainSpec.MaxDepositsPerBlock(), - ) - if err != nil { - return err - } - if uint64(len(deposits)) < depositIndex { - return errors.Wrapf(ErrDepositStoreIncomplete, - "all historical deposits not available, expected: %d, got: %d", - depositIndex, len(deposits), + // Grab all previous deposits from genesis up to the current index + max deposits per block. + deposits, err := s.sb.DepositStore().GetDepositsByIndex( + ctx, + constants.FirstDepositIndex, + depositIndex+s.chainSpec.MaxDepositsPerBlock(), ) - } + if err != nil { + return err + } + if uint64(len(deposits)) < depositIndex { + return errors.Wrapf(ErrDepositStoreIncomplete, + "all historical deposits not available, expected: %d, got: %d", + depositIndex, len(deposits), + ) + } - eth1Data := ctypes.NewEth1Data(deposits.HashTreeRoot()) - body.SetEth1Data(eth1Data) + eth1Data := ctypes.NewEth1Data(deposits.HashTreeRoot()) + body.SetEth1Data(eth1Data) - s.logger.Info( - "Building block body with local deposits", - "start_index", depositIndex, "num_deposits", uint64(len(deposits))-depositIndex, - ) - body.SetDeposits(deposits[depositIndex:]) + s.logger.Info( + "Building block body with local deposits", + "start_index", depositIndex, "num_deposits", uint64(len(deposits))-depositIndex, + ) + body.SetDeposits(deposits[depositIndex:]) + } // Set the graffiti on the block body. sizedGraffiti := bytes.ExtendToSize([]byte(s.cfg.Graffiti), bytes.B32Size) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index 9c22cf5f9b..691529eff7 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -37,10 +37,10 @@ func (sp *StateProcessor) processOperations( st *state.StateDB, blk *ctypes.BeaconBlock, ) error { - if version.IsBefore(blk.GetForkVersion(), version.Electra()) { - // Before Electra, deposits are processed from the beacon block body directly. - // + // Before Electra1, deposits are processed from the beacon block body directly. + if version.IsBefore(blk.GetForkVersion(), version.Electra1()) { // Verify that outstanding deposits are processed up to the maximum number of deposits. + // // Unlike Ethereum 2.0 specs, we don't check that // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)`. deposits := blk.GetBody().GetDeposits() @@ -72,7 +72,7 @@ func (sp *StateProcessor) processOperations( return st.SetEth1Data(blk.GetBody().Eth1Data) } - // After Electra, validators increase/decrease stake through execution requests which must + // After Electra1, validators increase/decrease stake through execution requests which must // be handled. requests, err := blk.GetBody().GetExecutionRequests() if err != nil { From 65c201c3c4ecab04c92749c07a65b272e0008d42 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 16:46:26 -0700 Subject: [PATCH 06/17] lint --- beacon/blockchain/finalize_block.go | 1 + state-transition/core/state_processor_staking.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon/blockchain/finalize_block.go b/beacon/blockchain/finalize_block.go index 1395fba4f3..12952426d0 100644 --- a/beacon/blockchain/finalize_block.go +++ b/beacon/blockchain/finalize_block.go @@ -35,6 +35,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +//nolint:funlen // Okay for now. func (s *Service) FinalizeBlock( ctx sdk.Context, req *cmtabci.FinalizeBlockRequest, diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index 691529eff7..9927d37068 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -88,7 +88,7 @@ func (sp *StateProcessor) processOperations( // EIP-6110 Deposits. for _, dep := range requests.Deposits { - if err := sp.processDeposit(st, dep); err != nil { + if err = sp.processDeposit(st, dep); err != nil { return err } } From 2e3098dc9ba67ffe2f248c1b4ca5ab49163e0212 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 17:11:17 -0700 Subject: [PATCH 07/17] process electra1 fork --- chain/data.go | 2 + chain/spec.go | 9 ++++ config/spec/mainnet.go | 1 + .../core/state_processor_forks.go | 46 +++++++++++++++++++ testing/files/spec.toml | 1 + testing/networks/80069/spec.toml | 1 + testing/networks/80094/spec.toml | 1 + 7 files changed, 61 insertions(+) diff --git a/chain/data.go b/chain/data.go index 6595bc8fad..d64b690f3d 100644 --- a/chain/data.go +++ b/chain/data.go @@ -95,6 +95,8 @@ type SpecData struct { Deneb1ForkTime uint64 `mapstructure:"deneb-one-fork-time"` // ElectraForkTime is the time at which the Electra fork is activated. ElectraForkTime uint64 `mapstructure:"electra-fork-time"` + // Electra1ForkTime is the time at which the Electra1 fork is activated. + Electra1ForkTime uint64 `mapstructure:"electra-one-fork-time"` // State list lengths // diff --git a/chain/spec.go b/chain/spec.go index f8269a61c0..84fbd32fb3 100644 --- a/chain/spec.go +++ b/chain/spec.go @@ -103,6 +103,9 @@ type ForkSpec interface { // ElectraForkTime returns the time at which the Electra fork takes effect. ElectraForkTime() uint64 + + // Electra1ForkTime returns the time at which the Electra1 fork takes effect. + Electra1ForkTime() uint64 } type BlobSpec interface { @@ -252,6 +255,7 @@ func (s spec) validate() error { s.Data.GenesisTime, s.Data.Deneb1ForkTime, s.Data.ElectraForkTime, + s.Data.Electra1ForkTime, } for i := 1; i < len(orderedForkTimes); i++ { prev, cur := orderedForkTimes[i-1], orderedForkTimes[i] @@ -393,6 +397,11 @@ func (s spec) ElectraForkTime() uint64 { return s.Data.ElectraForkTime } +// Electra1ForkTime returns the epoch of the Electra1 fork. +func (s spec) Electra1ForkTime() uint64 { + return s.Data.Electra1ForkTime +} + // EpochsPerHistoricalVector returns the number of epochs per historical vector. func (s spec) EpochsPerHistoricalVector() uint64 { return s.Data.EpochsPerHistoricalVector diff --git a/config/spec/mainnet.go b/config/spec/mainnet.go index 8f8b4fe87d..11f38291b6 100644 --- a/config/spec/mainnet.go +++ b/config/spec/mainnet.go @@ -133,6 +133,7 @@ func MainnetChainSpecData() *chain.SpecData { GenesisTime: mainnetGenesisTime, Deneb1ForkTime: mainnetDeneb1ForkTime, ElectraForkTime: mainnetElectraForkTime, + Electra1ForkTime: 9999999999999999999, // State list length constants. EpochsPerHistoricalVector: defaultEpochsPerHistoricalVector, diff --git a/state-transition/core/state_processor_forks.go b/state-transition/core/state_processor_forks.go index af04937345..a06c31d2c6 100644 --- a/state-transition/core/state_processor_forks.go +++ b/state-transition/core/state_processor_forks.go @@ -94,6 +94,15 @@ func (sp *StateProcessor) ProcessFork( if logUpgrade { sp.logElectraFork(stateFork.PreviousVersion, timestamp, slot) } + case version.Electra1(): + if err = sp.upgradeToElectra1(st, stateFork, slot); err != nil { + return err + } + + // Log the upgrade to Electra1 if requested. + if logUpgrade { + sp.logElectra1Fork(stateFork.PreviousVersion, timestamp, slot) + } default: panic(fmt.Sprintf("unsupported fork version: %s", forkVersion)) } @@ -208,3 +217,40 @@ func (sp *StateProcessor) logElectraFork( sp.cs.SlotToEpoch(slot).Unwrap(), )) } + +// upgradeToElectra1 upgrades the state to the Electra1 fork version. It just sets the Fork struct +// in the BeaconState. +func (sp *StateProcessor) upgradeToElectra1( + st *statedb.StateDB, fork *types.Fork, slot math.Slot, +) error { + // Set the fork on BeaconState. + fork.PreviousVersion = fork.CurrentVersion + fork.CurrentVersion = version.Electra1() + fork.Epoch = sp.cs.SlotToEpoch(slot) + return st.SetFork(fork) +} + +// logElectra1Fork logs information about the Electra1 fork. +func (sp *StateProcessor) logElectra1Fork( + previousVersion common.Version, timestamp math.U64, slot math.Slot, +) { + sp.logger.Info(fmt.Sprintf(` + + + ⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️ + + + ✅ welcome to the electra1 (0x05010000) fork! 🎉 + + 🚝 previous fork: %s (%s) + + ⏱️ electra1 fork time: %d + + 🍴 first slot / timestamp of electra1: %d / %d + + ⛓️ current beacon epoch: %d + + ⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️⏭️ + +`, + version.Name(previousVersion), previousVersion.String(), + sp.cs.Electra1ForkTime(), + slot.Unwrap(), timestamp.Unwrap(), + sp.cs.SlotToEpoch(slot).Unwrap(), + )) +} diff --git a/testing/files/spec.toml b/testing/files/spec.toml index 9b392b8b1a..8a9871c4e0 100644 --- a/testing/files/spec.toml +++ b/testing/files/spec.toml @@ -35,6 +35,7 @@ target-seconds-per-eth1-block = 2 genesis-time = 0 deneb-one-fork-time = 0 electra-fork-time = 0 +electra-one-fork-time = 9_999_999_999_999_999_999 # State list lengths epochs-per-historical-vector = 8 diff --git a/testing/networks/80069/spec.toml b/testing/networks/80069/spec.toml index 89a7f58d32..c26f1952b5 100644 --- a/testing/networks/80069/spec.toml +++ b/testing/networks/80069/spec.toml @@ -35,6 +35,7 @@ target-seconds-per-eth1-block = 2 genesis-time = 1_739_976_735 deneb-one-fork-time = 1_740_090_694 electra-fork-time = 1_746_633_600 +electra-one-fork-time = 9_999_999_999_999_999_999 # State list lengths epochs-per-historical-vector = 8 diff --git a/testing/networks/80094/spec.toml b/testing/networks/80094/spec.toml index fb06fdfa60..0e0b20ef4b 100644 --- a/testing/networks/80094/spec.toml +++ b/testing/networks/80094/spec.toml @@ -35,6 +35,7 @@ target-seconds-per-eth1-block = 2 genesis-time = 1_737_381_600 deneb-one-fork-time = 1_738_415_507 electra-fork-time = 1_749_056_400 +electra-one-fork-time = 9_999_999_999_999_999_999 # State list lengths epochs-per-historical-vector = 8 From b7dae5e8221210a8939a202474e88eb8ad6fb328 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 17:15:18 -0700 Subject: [PATCH 08/17] EL genesis config update --- .../kurtosis-devnet/network-configs/genesis.json.template | 3 ++- testing/files/eth-genesis.json | 3 ++- testing/networks/80069/eth-genesis.json | 3 ++- testing/networks/80094/eth-genesis.json | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kurtosis/src/networks/kurtosis-devnet/network-configs/genesis.json.template b/kurtosis/src/networks/kurtosis-devnet/network-configs/genesis.json.template index dc935de735..710f4cded7 100644 --- a/kurtosis/src/networks/kurtosis-devnet/network-configs/genesis.json.template +++ b/kurtosis/src/networks/kurtosis-devnet/network-configs/genesis.json.template @@ -34,7 +34,8 @@ "max": 6, "baseFeeUpdateFraction": 3338477 } - } + }, + "depositContractAddress": "0x4242424242424242424242424242424242424242" }, "coinbase": "0x0000000000000000000000000000000000000000", "difficulty": "0x0", diff --git a/testing/files/eth-genesis.json b/testing/files/eth-genesis.json index bf7f9828e5..a45ce7e133 100644 --- a/testing/files/eth-genesis.json +++ b/testing/files/eth-genesis.json @@ -34,7 +34,8 @@ "max": 6, "baseFeeUpdateFraction": 3338477 } - } + }, + "depositContractAddress": "0x4242424242424242424242424242424242424242" }, "coinbase": "0x0000000000000000000000000000000000000000", "difficulty": "0x0", diff --git a/testing/networks/80069/eth-genesis.json b/testing/networks/80069/eth-genesis.json index 98944ee991..c88065b5da 100644 --- a/testing/networks/80069/eth-genesis.json +++ b/testing/networks/80069/eth-genesis.json @@ -94,7 +94,8 @@ "max": 6, "baseFeeUpdateFraction": 3338477 } - } + }, + "depositContractAddress": "0x4242424242424242424242424242424242424242" }, "difficulty": "0x01", "extraData": "", diff --git a/testing/networks/80094/eth-genesis.json b/testing/networks/80094/eth-genesis.json index 836672f54d..bae202ff9d 100644 --- a/testing/networks/80094/eth-genesis.json +++ b/testing/networks/80094/eth-genesis.json @@ -34,7 +34,8 @@ "baseFeeUpdateFraction": 3338477 } }, - "ethash": {} + "ethash": {}, + "depositContractAddress": "0x4242424242424242424242424242424242424242" }, "coinbase": "0x0000000000000000000000000000000000000000", "difficulty": "0x01", From 9ea411b2cdbf6206dbb69b4602b6d51a0fb2d00e Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Wed, 28 May 2025 17:33:43 -0700 Subject: [PATCH 09/17] lint --- config/spec/mainnet.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/spec/mainnet.go b/config/spec/mainnet.go index 11f38291b6..edc005d030 100644 --- a/config/spec/mainnet.go +++ b/config/spec/mainnet.go @@ -94,6 +94,8 @@ const ( // mainnetMinValidatorWithdrawabilityDelay is the number of epochs of delay epochs of delay for a balance to be withdrawable. // 256 Epochs equates to roughly ~27 hours of withdrawal delay. This gives us room to emergency fork if needed. mainnetMinValidatorWithdrawabilityDelay = defaultMinValidatorWithdrawabilityDelay + + farFutureElectra1ForkTime = 9999999999999999999 ) // MainnetChainSpecData is the chain.SpecData for the Berachain mainnet. @@ -130,10 +132,10 @@ func MainnetChainSpecData() *chain.SpecData { TargetSecondsPerEth1Block: defaultTargetSecondsPerEth1Block, // Fork-related values. - GenesisTime: mainnetGenesisTime, - Deneb1ForkTime: mainnetDeneb1ForkTime, - ElectraForkTime: mainnetElectraForkTime, - Electra1ForkTime: 9999999999999999999, + GenesisTime: mainnetGenesisTime, + Deneb1ForkTime: mainnetDeneb1ForkTime, + ElectraForkTime: mainnetElectraForkTime, + Electra1ForkTime: farFutureElectra1ForkTime, // State list length constants. EpochsPerHistoricalVector: defaultEpochsPerHistoricalVector, From 2b364dd9435bbec8059da99cbfd7f73e15e4a42b Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Thu, 29 May 2025 16:47:18 -0700 Subject: [PATCH 10/17] upgradeToElectra1 --- .../core/state_processor_forks.go | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/state-transition/core/state_processor_forks.go b/state-transition/core/state_processor_forks.go index a06c31d2c6..8b1face7e7 100644 --- a/state-transition/core/state_processor_forks.go +++ b/state-transition/core/state_processor_forks.go @@ -21,8 +21,10 @@ package core import ( + "errors" "fmt" + "cosmossdk.io/collections" "github.com/berachain/beacon-kit/consensus-types/types" "github.com/berachain/beacon-kit/primitives/common" "github.com/berachain/beacon-kit/primitives/constants" @@ -185,11 +187,7 @@ func (sp *StateProcessor) upgradeToElectra( // Initialize the pending partial withdrawals to an empty array. sp.metrics.gaugePartialWithdrawalsEnqueued(0) - if err := st.SetPendingPartialWithdrawals([]*types.PendingPartialWithdrawal{}); err != nil { - return err - } - - return nil + return st.SetPendingPartialWithdrawals([]*types.PendingPartialWithdrawal{}) } // logElectraFork logs information about the Electra fork. @@ -218,8 +216,10 @@ func (sp *StateProcessor) logElectraFork( )) } -// upgradeToElectra1 upgrades the state to the Electra1 fork version. It just sets the Fork struct -// in the BeaconState. +// upgradeToElectra1 upgrades the state to the Electra1 fork version. It is modified from the ETH +// 2.0 spec (https://ethereum.github.io/consensus-specs/specs/electra/fork/#upgrading-the-state) to: +// - update the Fork struct in the BeaconState +// - initialize the pending partial withdrawals to an empty array (if not already initialized) func (sp *StateProcessor) upgradeToElectra1( st *statedb.StateDB, fork *types.Fork, slot math.Slot, ) error { @@ -227,7 +227,17 @@ func (sp *StateProcessor) upgradeToElectra1( fork.PreviousVersion = fork.CurrentVersion fork.CurrentVersion = version.Electra1() fork.Epoch = sp.cs.SlotToEpoch(slot) - return st.SetFork(fork) + if err := st.SetFork(fork); err != nil { + return err + } + + // Initialize the pending partial withdrawals to an empty array if not already initialized. + if _, err := st.GetPendingPartialWithdrawals(); errors.Is(err, collections.ErrNotFound) { + sp.metrics.gaugePartialWithdrawalsEnqueued(0) + return st.SetPendingPartialWithdrawals([]*types.PendingPartialWithdrawal{}) + } + + return nil } // logElectra1Fork logs information about the Electra1 fork. From 2df992f84eac59979a8cee254377ca54ca3b6649 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 2 Jun 2025 18:42:02 -0700 Subject: [PATCH 11/17] fix some unit tests --- chain/spec_test.go | 1 + config/spec/defaults.go | 3 +++ config/spec/mainnet.go | 4 +--- testing/files/spec.toml | 2 +- testing/networks/80069/spec.toml | 2 +- testing/networks/80094/spec.toml | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/chain/spec_test.go b/chain/spec_test.go index 4ceae5a42e..3221f8e792 100644 --- a/chain/spec_test.go +++ b/chain/spec_test.go @@ -42,6 +42,7 @@ func TestValidate_ForkOrder_Success(t *testing.T) { data.GenesisTime = 10 data.Deneb1ForkTime = 20 data.ElectraForkTime = 30 + data.Electra1ForkTime = 40 _, err := chain.NewSpec(data) require.NoError(t, err) diff --git a/config/spec/defaults.go b/config/spec/defaults.go index a581f9f23f..771b3960a0 100644 --- a/config/spec/defaults.go +++ b/config/spec/defaults.go @@ -79,4 +79,7 @@ const ( // Electra values. defaultMinValidatorWithdrawabilityDelay = 256 + + // Misc values. + defaultFarFutureTime = 9999999999999999 ) diff --git a/config/spec/mainnet.go b/config/spec/mainnet.go index edc005d030..a167a06b8a 100644 --- a/config/spec/mainnet.go +++ b/config/spec/mainnet.go @@ -94,8 +94,6 @@ const ( // mainnetMinValidatorWithdrawabilityDelay is the number of epochs of delay epochs of delay for a balance to be withdrawable. // 256 Epochs equates to roughly ~27 hours of withdrawal delay. This gives us room to emergency fork if needed. mainnetMinValidatorWithdrawabilityDelay = defaultMinValidatorWithdrawabilityDelay - - farFutureElectra1ForkTime = 9999999999999999999 ) // MainnetChainSpecData is the chain.SpecData for the Berachain mainnet. @@ -135,7 +133,7 @@ func MainnetChainSpecData() *chain.SpecData { GenesisTime: mainnetGenesisTime, Deneb1ForkTime: mainnetDeneb1ForkTime, ElectraForkTime: mainnetElectraForkTime, - Electra1ForkTime: farFutureElectra1ForkTime, + Electra1ForkTime: defaultFarFutureTime, // State list length constants. EpochsPerHistoricalVector: defaultEpochsPerHistoricalVector, diff --git a/testing/files/spec.toml b/testing/files/spec.toml index 8a9871c4e0..5ba0eaf039 100644 --- a/testing/files/spec.toml +++ b/testing/files/spec.toml @@ -35,7 +35,7 @@ target-seconds-per-eth1-block = 2 genesis-time = 0 deneb-one-fork-time = 0 electra-fork-time = 0 -electra-one-fork-time = 9_999_999_999_999_999_999 +electra-one-fork-time = 9_999_999_999_999_999 # State list lengths epochs-per-historical-vector = 8 diff --git a/testing/networks/80069/spec.toml b/testing/networks/80069/spec.toml index c26f1952b5..37d5003c84 100644 --- a/testing/networks/80069/spec.toml +++ b/testing/networks/80069/spec.toml @@ -35,7 +35,7 @@ target-seconds-per-eth1-block = 2 genesis-time = 1_739_976_735 deneb-one-fork-time = 1_740_090_694 electra-fork-time = 1_746_633_600 -electra-one-fork-time = 9_999_999_999_999_999_999 +electra-one-fork-time = 9_999_999_999_999_999 # State list lengths epochs-per-historical-vector = 8 diff --git a/testing/networks/80094/spec.toml b/testing/networks/80094/spec.toml index 0e0b20ef4b..c93a6a965c 100644 --- a/testing/networks/80094/spec.toml +++ b/testing/networks/80094/spec.toml @@ -35,7 +35,7 @@ target-seconds-per-eth1-block = 2 genesis-time = 1_737_381_600 deneb-one-fork-time = 1_738_415_507 electra-fork-time = 1_749_056_400 -electra-one-fork-time = 9_999_999_999_999_999_999 +electra-one-fork-time = 9_999_999_999_999_999 # State list lengths epochs-per-historical-vector = 8 From 3b0912a8d5d9daa7568d5d9ef87757937a5f50d1 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 2 Jun 2025 21:02:07 -0700 Subject: [PATCH 12/17] fix withdrawals fork handling --- .../core/state_processor_staking.go | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index 9927d37068..9e04a6bbd8 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -37,10 +37,16 @@ func (sp *StateProcessor) processOperations( st *state.StateDB, blk *ctypes.BeaconBlock, ) error { - // Before Electra1, deposits are processed from the beacon block body directly. + // Validators increase/decrease stake through execution requests starting in Electra. + requests, err := blk.GetBody().GetExecutionRequests() + if err != nil { + return err + } + if version.IsBefore(blk.GetForkVersion(), version.Electra1()) { - // Verify that outstanding deposits are processed up to the maximum number of deposits. + // Before Electra1 however, deposits are processed from the beacon block body directly. // + // Verify that outstanding deposits are processed up to the maximum number of deposits. // Unlike Ethereum 2.0 specs, we don't check that // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)`. deposits := blk.GetBody().GetDeposits() @@ -52,7 +58,7 @@ func (sp *StateProcessor) processOperations( } // Instead, we directly compare block deposits with our local store ones. - if err := ValidateNonGenesisDeposits( + if err = ValidateNonGenesisDeposits( ctx.ConsensusCtx(), st, sp.ds, @@ -64,31 +70,26 @@ func (sp *StateProcessor) processOperations( } for _, dep := range deposits { - if err := sp.processDeposit(st, dep); err != nil { + if err = sp.processDeposit(st, dep); err != nil { return err } } - return st.SetEth1Data(blk.GetBody().Eth1Data) - } - - // After Electra1, validators increase/decrease stake through execution requests which must - // be handled. - requests, err := blk.GetBody().GetExecutionRequests() - if err != nil { - return err + if err = st.SetEth1Data(blk.GetBody().Eth1Data); err != nil { + return err + } + } else { + // Starting in Electra1, deposits are processed from the execution requests (EIP-6110 style). + for _, dep := range requests.Deposits { + if err = sp.processDeposit(st, dep); err != nil { + return err + } + } } // EIP-7002 Withdrawals. for _, withdrawal := range requests.Withdrawals { - if withdrawErr := sp.processWithdrawalRequest(st, withdrawal); withdrawErr != nil { - return withdrawErr - } - } - - // EIP-6110 Deposits. - for _, dep := range requests.Deposits { - if err = sp.processDeposit(st, dep); err != nil { + if err = sp.processWithdrawalRequest(st, withdrawal); err != nil { return err } } From 3a88dbaafa6e147ee4058d907c73c831b55b3ff4 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 2 Jun 2025 21:22:53 -0700 Subject: [PATCH 13/17] refactor for readability --- .../core/state_processor_staking.go | 41 ++++++++++--------- state-transition/core/validation_deposits.go | 1 + 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index 9e04a6bbd8..bc07a1763c 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -43,13 +43,17 @@ func (sp *StateProcessor) processOperations( return err } - if version.IsBefore(blk.GetForkVersion(), version.Electra1()) { - // Before Electra1 however, deposits are processed from the beacon block body directly. + var deposits []*ctypes.Deposit + if version.EqualsOrIsAfter(blk.GetForkVersion(), version.Electra1()) { + // Starting in Electra1, EIP-6110 style deposit requests are used. + deposits = requests.Deposits + } else { + // Before Electra1 however, deposits are taken from the beacon block body directly. // // Verify that outstanding deposits are processed up to the maximum number of deposits. // Unlike Ethereum 2.0 specs, we don't check that // `len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index)`. - deposits := blk.GetBody().GetDeposits() + deposits = blk.GetBody().GetDeposits() if uint64(len(deposits)) > sp.cs.MaxDepositsPerBlock() { return errors.Wrapf( ErrExceedsBlockDepositLimit, "expected: %d, got: %d", @@ -68,33 +72,32 @@ func (sp *StateProcessor) processOperations( ); err != nil { return err } + } - for _, dep := range deposits { - if err = sp.processDeposit(st, dep); err != nil { - return err - } - } - - if err = st.SetEth1Data(blk.GetBody().Eth1Data); err != nil { + // Process the deposits. + for _, dep := range deposits { + if err = sp.processDeposit(st, dep); err != nil { return err } - } else { - // Starting in Electra1, deposits are processed from the execution requests (EIP-6110 style). - for _, dep := range requests.Deposits { - if err = sp.processDeposit(st, dep); err != nil { - return err - } - } } - // EIP-7002 Withdrawals. + // Process the EIP-7002 withdrawal requests. for _, withdrawal := range requests.Withdrawals { if err = sp.processWithdrawalRequest(st, withdrawal); err != nil { return err } } - return st.SetEth1Data(ctypes.NewEmptyEth1Data()) + // Set the eth1 data to state. + var eth1Data *ctypes.Eth1Data + if version.EqualsOrIsAfter(blk.GetForkVersion(), version.Electra1()) { + // Starting in Electra1, the eth1 data is unused so set in state as empty. + eth1Data = ctypes.NewEmptyEth1Data() + } else { + // Before Electra1 however, the eth1 data is applied to state from the beacon block body. + eth1Data = blk.GetBody().Eth1Data + } + return st.SetEth1Data(eth1Data) } // processDeposit processes the deposit and ensures it matches the local state. diff --git a/state-transition/core/validation_deposits.go b/state-transition/core/validation_deposits.go index 1838450efe..b160072899 100644 --- a/state-transition/core/validation_deposits.go +++ b/state-transition/core/validation_deposits.go @@ -70,6 +70,7 @@ func validateGenesisDeposits( return nil } +// NOTE: only used before Electra1. func ValidateNonGenesisDeposits( ctx context.Context, st *statedb.StateDB, From af9313c6cd8beba2b0758c0568d0c424247f1658 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 2 Jun 2025 21:26:24 -0700 Subject: [PATCH 14/17] nit --- state-transition/core/state_processor_staking.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index bc07a1763c..4c16c369c9 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -44,10 +44,7 @@ func (sp *StateProcessor) processOperations( } var deposits []*ctypes.Deposit - if version.EqualsOrIsAfter(blk.GetForkVersion(), version.Electra1()) { - // Starting in Electra1, EIP-6110 style deposit requests are used. - deposits = requests.Deposits - } else { + if version.IsBefore(blk.GetForkVersion(), version.Electra1()) { // Before Electra1 however, deposits are taken from the beacon block body directly. // // Verify that outstanding deposits are processed up to the maximum number of deposits. @@ -72,6 +69,9 @@ func (sp *StateProcessor) processOperations( ); err != nil { return err } + } else { + // Starting in Electra1, EIP-6110 style deposit requests are used. + deposits = requests.Deposits } // Process the deposits. @@ -90,12 +90,12 @@ func (sp *StateProcessor) processOperations( // Set the eth1 data to state. var eth1Data *ctypes.Eth1Data - if version.EqualsOrIsAfter(blk.GetForkVersion(), version.Electra1()) { - // Starting in Electra1, the eth1 data is unused so set in state as empty. - eth1Data = ctypes.NewEmptyEth1Data() - } else { + if version.IsBefore(blk.GetForkVersion(), version.Electra1()) { // Before Electra1 however, the eth1 data is applied to state from the beacon block body. eth1Data = blk.GetBody().Eth1Data + } else { + // Starting in Electra1, the eth1 data is unused so set in state as empty. + eth1Data = ctypes.NewEmptyEth1Data() } return st.SetEth1Data(eth1Data) } From 741e0d0622a5b5b7f5009db5909a722030700286 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Mon, 2 Jun 2025 22:06:50 -0700 Subject: [PATCH 15/17] fix nilaway --- cli/commands/genesis/collect.go | 13 ++++++++++--- cli/commands/genesis/payload.go | 15 +++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cli/commands/genesis/collect.go b/cli/commands/genesis/collect.go index 021c7e5ca5..707b3f739d 100644 --- a/cli/commands/genesis/collect.go +++ b/cli/commands/genesis/collect.go @@ -59,13 +59,20 @@ func CollectGenesisDeposits(config *cmtcfg.Config) error { } // create the app state - appGenesisState, err := genutiltypes.GenesisStateFromAppGenesis( - appGenesis, - ) + appGenesisState, err := genutiltypes.GenesisStateFromAppGenesis(appGenesis) if err != nil { return err } + // Ensure the map is initialized before it is indexed below. If the + // underlying function returned a nil map with a nil error (which is + // permissible in Go), we defensively allocate an empty map to avoid + // potential nil dereference panics that static analysis (nilaway) + // rightfully complains about. + if appGenesisState == nil { + appGenesisState = make(map[string]json.RawMessage) + } + var deposits []*types.Deposit if deposits, err = CollectValidatorJSONFiles( filepath.Join(config.RootDir, "config", "premined-deposits"), diff --git a/cli/commands/genesis/payload.go b/cli/commands/genesis/payload.go index 3f09aee793..b1fec4f2be 100644 --- a/cli/commands/genesis/payload.go +++ b/cli/commands/genesis/payload.go @@ -84,21 +84,24 @@ func AddExecutionPayload(chainSpec ChainSpec, elGenesisPath string, config *cmtc nil, ).ExecutionPayload - appGenesis, err := genutiltypes.AppGenesisFromFile( - config.GenesisFile(), - ) + appGenesis, err := genutiltypes.AppGenesisFromFile(config.GenesisFile()) if err != nil { return errors.Wrap(err, "failed to read genesis doc from file") } // create the app state - appGenesisState, err := genutiltypes.GenesisStateFromAppGenesis( - appGenesis, - ) + appGenesisState, err := genutiltypes.GenesisStateFromAppGenesis(appGenesis) if err != nil { return err } + // Defensive: ensure the map returned is non-nil before indexing. This + // prevents potential nil dereference panics flagged by static analysis + // tools such as nilaway. + if appGenesisState == nil { + appGenesisState = make(map[string]json.RawMessage) + } + genesisInfo := &types.Genesis{} if err = json.Unmarshal( From fdac98bc9cdba2588380d21b5b8b232656c84ef8 Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Tue, 3 Jun 2025 19:29:42 -0700 Subject: [PATCH 16/17] handle all fork versions --- .../core/state_processor_staking.go | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/state-transition/core/state_processor_staking.go b/state-transition/core/state_processor_staking.go index 4c16c369c9..3cb99b10c2 100644 --- a/state-transition/core/state_processor_staking.go +++ b/state-transition/core/state_processor_staking.go @@ -37,10 +37,16 @@ func (sp *StateProcessor) processOperations( st *state.StateDB, blk *ctypes.BeaconBlock, ) error { - // Validators increase/decrease stake through execution requests starting in Electra. - requests, err := blk.GetBody().GetExecutionRequests() - if err != nil { - return err + var ( + requests *ctypes.ExecutionRequests + err error + ) + if version.EqualsOrIsAfter(blk.GetForkVersion(), version.Electra()) { + // Validators increase/decrease stake through execution requests starting in Electra. + requests, err = blk.GetBody().GetExecutionRequests() + if err != nil { + return err + } } var deposits []*ctypes.Deposit @@ -69,7 +75,7 @@ func (sp *StateProcessor) processOperations( ); err != nil { return err } - } else { + } else if requests != nil { // Starting in Electra1, EIP-6110 style deposit requests are used. deposits = requests.Deposits } @@ -81,10 +87,12 @@ func (sp *StateProcessor) processOperations( } } - // Process the EIP-7002 withdrawal requests. - for _, withdrawal := range requests.Withdrawals { - if err = sp.processWithdrawalRequest(st, withdrawal); err != nil { - return err + // Starting in Electra, process the EIP-7002 withdrawal requests. + if requests != nil { + for _, withdrawal := range requests.Withdrawals { + if err = sp.processWithdrawalRequest(st, withdrawal); err != nil { + return err + } } } From e283f373a78db6a0962fb51ece1bb60a803abd8f Mon Sep 17 00:00:00 2001 From: Cal Bera Date: Thu, 28 Aug 2025 20:55:56 +0100 Subject: [PATCH 17/17] lint --- beacon/blockchain/finalize_block.go | 1 - config/spec/defaults.go | 3 --- consensus/cometbft/service/finalize_block.go | 10 +++++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/beacon/blockchain/finalize_block.go b/beacon/blockchain/finalize_block.go index 80e5d00a2f..7d7df65f27 100644 --- a/beacon/blockchain/finalize_block.go +++ b/beacon/blockchain/finalize_block.go @@ -37,7 +37,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -//nolint:funlen // Okay for now. func (s *Service) FinalizeBlock( ctx sdk.Context, req *cmtabci.FinalizeBlockRequest, diff --git a/config/spec/defaults.go b/config/spec/defaults.go index 771b3960a0..a581f9f23f 100644 --- a/config/spec/defaults.go +++ b/config/spec/defaults.go @@ -79,7 +79,4 @@ const ( // Electra values. defaultMinValidatorWithdrawabilityDelay = 256 - - // Misc values. - defaultFarFutureTime = 9999999999999999 ) diff --git a/consensus/cometbft/service/finalize_block.go b/consensus/cometbft/service/finalize_block.go index a04f5ea48f..d8d880653d 100644 --- a/consensus/cometbft/service/finalize_block.go +++ b/consensus/cometbft/service/finalize_block.go @@ -130,7 +130,6 @@ func (s *Service) finalizeBlock( return s.calculateFinalizeBlockResponse(req, valUpdates) } -//nolint:lll // long message on one line for readability. func (s *Service) nextBlockDelay(req *cmtabci.FinalizeBlockRequest) time.Duration { // c0. SBT is not enabled => use the old block delay. if s.cmtConsensusParams.Feature.SBTEnableHeight <= 0 { @@ -170,8 +169,13 @@ func (s *Service) nextBlockDelay(req *cmtabci.FinalizeBlockRequest) time.Duratio // // Looks like we've skipped SBTEnableHeight (probably restoring from the // snapshot) => panic. - panic(fmt.Sprintf("nil block delay at height %d past SBTEnableHeight %d. This is only possible w/ statesync, which is not supported by SBT atm", - req.Height, s.cmtConsensusParams.Feature.SBTEnableHeight)) + panic( + fmt.Sprintf( + "nil block delay at height %d past SBTEnableHeight %d. This is only possible w/ statesync, which is not supported by SBT atm", + req.Height, + s.cmtConsensusParams.Feature.SBTEnableHeight, + ), + ) } // workingHash gets the apphash that will be finalized in commit.