diff --git a/consensus/merge/merge.go b/consensus/merge/merge.go index 273c8994c51..81790881e8e 100644 --- a/consensus/merge/merge.go +++ b/consensus/merge/merge.go @@ -20,9 +20,10 @@ import ( "bytes" "errors" "fmt" + "math/big" + "github.com/erigontech/erigon-lib/kv" "github.com/holiman/uint256" - "math/big" "github.com/erigontech/erigon-lib/chain" libcommon "github.com/erigontech/erigon-lib/common" @@ -353,7 +354,7 @@ func (s *Merge) Initialize(config *chain.Config, chain consensus.ChainHeaderRead }, tracer) } if chain.Config().IsPrague(header.Time) { - misc.StoreBlockHashesEip2935(header, state, config, chain) + misc.StoreBlockHashesEip2935(header, state) } return nil } diff --git a/consensus/misc/eip2935.go b/consensus/misc/eip2935.go index 460c95f4b39..950b7e10b4d 100644 --- a/consensus/misc/eip2935.go +++ b/consensus/misc/eip2935.go @@ -19,17 +19,15 @@ package misc import ( "github.com/holiman/uint256" - "github.com/erigontech/erigon-lib/chain" libcommon "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/consensus" "github.com/erigontech/erigon/core/state" "github.com/erigontech/erigon/core/types" "github.com/erigontech/erigon/params" ) -func StoreBlockHashesEip2935(header *types.Header, state *state.IntraBlockState, config *chain.Config, headerReader consensus.ChainHeaderReader) { +func StoreBlockHashesEip2935(header *types.Header, state *state.IntraBlockState) { if state.GetCodeSize(params.HistoryStorageAddress) == 0 { log.Debug("[EIP-2935] No code deployed to HistoryStorageAddress before call to store EIP-2935 history") return diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index 42b58e091cc..c0b6a18cb06 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -6,9 +6,6 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/erigontech/erigon/consensus/parlia/finality" - "github.com/erigontech/erigon/core/tracing" - "github.com/erigontech/erigon/core/vm/evmtypes" "io" "math/big" "sort" @@ -16,6 +13,10 @@ import ( "sync" "time" + "github.com/erigontech/erigon/consensus/parlia/finality" + "github.com/erigontech/erigon/core/tracing" + "github.com/erigontech/erigon/core/vm/evmtypes" + "github.com/erigontech/erigon/crypto/cryptopool" "github.com/erigontech/erigon/turbo/services" @@ -892,6 +893,12 @@ func (p *Parlia) Initialize(config *chain.Config, chain consensus.ChainHeaderRea if err = p.verifyTurnLength(chain, header, state); err != nil { return err } + + // store block hashes for EIP-2935 (BEP440) upgrade + if config.IsPrague(header.Time) { + misc.StoreBlockHashesEip2935(header, state) + } + // update validators every day if p.chainConfig.IsFeynman(header.Number.Uint64(), header.Time) && isBreatheBlock(parentHeader.Time, header.Time) { // we should avoid update validators in the Feynman upgrade block diff --git a/core/blockchain.go b/core/blockchain.go index d6c260f65fa..8c5ec914659 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -40,7 +40,6 @@ import ( "github.com/erigontech/erigon/common/math" "github.com/erigontech/erigon/common/u256" "github.com/erigontech/erigon/consensus" - "github.com/erigontech/erigon/consensus/misc" "github.com/erigontech/erigon/core/state" "github.com/erigontech/erigon/core/tracing" "github.com/erigontech/erigon/core/types" @@ -508,10 +507,6 @@ func InitializeBlockExecution(engine consensus.Engine, chain consensus.ChainHead return SysCallContract(contract, data, cc, ibState, header, engine, constCall) }, logger, tracer) - if cc.IsPrague(header.Time) { - misc.StoreBlockHashesEip2935(header, ibs, cc, chain) - } - noop := state.NewNoopWriter() ibs.FinalizeTx(cc.Rules(header.Number.Uint64(), header.Time), noop) return nil