From c0d0b1cb069b918c74d7dbb2ad25d3d0ba08fd5f Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Tue, 25 Mar 2025 16:18:46 +0530 Subject: [PATCH] consensus/bor: handle wrapped vm.State in Finalize --- consensus/bor/bor.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index 738fb61bce..e2006e0844 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -34,6 +34,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" @@ -819,15 +820,19 @@ func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) e // Finalize implements consensus.Engine, ensuring no uncles are set, nor block // rewards given. -func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) { +func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, wrappedState vm.StateDB, body *types.Body) { headerNumber := header.Number.Uint64() if body.Withdrawals != nil || header.WithdrawalsHash != nil { return } - if body.Requests != nil || header.RequestsHash != nil { + if header.RequestsHash != nil { return } + // Extract the underlying state to access methods like `IntermediateRoot` and `Copy` + // required for bor consensus operations + state := wrappedState.(*state.StateDB) + var ( stateSyncData []*types.StateSyncData err error @@ -913,7 +918,7 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ if body.Withdrawals != nil || header.WithdrawalsHash != nil { return nil, consensus.ErrUnexpectedWithdrawals } - if body.Requests != nil || header.RequestsHash != nil { + if header.RequestsHash != nil { return nil, consensus.ErrUnexpectedRequests }