From f8bacb2c181a585bbde08639e44c90fe90184291 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:06:16 +0200 Subject: [PATCH] remove StateDB as an extra param to Prepare (#281) --- consensus/beacon/consensus.go | 4 ++-- consensus/clique/clique.go | 2 +- consensus/consensus.go | 2 +- consensus/ethash/consensus.go | 2 +- miner/worker.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 7cea637ba1..82abe65ca1 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -330,14 +330,14 @@ func (beacon *Beacon) verifyHeaders(chain consensus.ChainHeaderReader, headers [ // Prepare implements consensus.Engine, initializing the difficulty field of a // header to conform to the beacon protocol. The changes are done inline. -func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.Header, statedb *state.StateDB) error { +func (beacon *Beacon) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error { // Transition isn't triggered yet, use the legacy rules for preparation. reached, err := IsTTDReached(chain, header.ParentHash, header.Number.Uint64()-1) if err != nil { return err } if !reached { - return beacon.ethone.Prepare(chain, header, statedb) + return beacon.ethone.Prepare(chain, header) } header.Difficulty = beaconDifficulty return nil diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 23c7d32755..f708050abd 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -499,7 +499,7 @@ func (c *Clique) verifySeal(snap *Snapshot, header *types.Header, parents []*typ // Prepare implements consensus.Engine, preparing all the consensus fields of the // header for running the transactions on top. -func (c *Clique) Prepare(chain consensus.ChainHeaderReader, header *types.Header, _ *state.StateDB) error { +func (c *Clique) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error { // If the block isn't a checkpoint, cast a random vote (good enough for now) header.Coinbase = common.Address{} header.Nonce = types.BlockNonce{} diff --git a/consensus/consensus.go b/consensus/consensus.go index aa5ad43ede..3a2c2d2229 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -81,7 +81,7 @@ type Engine interface { // Prepare initializes the consensus fields of a block header according to the // rules of a particular engine. The changes are executed inline. - Prepare(chain ChainHeaderReader, header *types.Header, state *state.StateDB) error + Prepare(chain ChainHeaderReader, header *types.Header) error // Finalize runs any post-transaction state modifications (e.g. block rewards // or process withdrawals) but does not assemble the block. diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index d155a3521c..44aec25c12 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -479,7 +479,7 @@ var DynamicDifficultyCalculator = makeDifficultyCalculator // Prepare implements consensus.Engine, initializing the difficulty field of a // header to conform to the ethash protocol. The changes are done inline. -func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.Header, _ *state.StateDB) error { +func (ethash *Ethash) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error { parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1) if parent == nil { return consensus.ErrUnknownAncestor diff --git a/miner/worker.go b/miner/worker.go index 8568abf376..124c932122 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -908,7 +908,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { core.OverlayVerkleTransition(state) } // Run the consensus preparation with the default or customized consensus engine. - if err := w.engine.Prepare(w.chain, header, state); err != nil { + if err := w.engine.Prepare(w.chain, header); err != nil { log.Error("Failed to prepare header for sealing", "err", err) return nil, err }