consensus/bor: handle wrapped vm.State in Finalize

This commit is contained in:
Manav Darji 2025-03-25 16:18:46 +05:30
parent f9f84acd4b
commit c0d0b1cb06
No known key found for this signature in database
GPG key ID: A426F0124435F36E

View file

@ -34,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "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/crypto"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log" "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 // Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// rewards given. // 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() headerNumber := header.Number.Uint64()
if body.Withdrawals != nil || header.WithdrawalsHash != nil { if body.Withdrawals != nil || header.WithdrawalsHash != nil {
return return
} }
if body.Requests != nil || header.RequestsHash != nil { if header.RequestsHash != nil {
return return
} }
// Extract the underlying state to access methods like `IntermediateRoot` and `Copy`
// required for bor consensus operations
state := wrappedState.(*state.StateDB)
var ( var (
stateSyncData []*types.StateSyncData stateSyncData []*types.StateSyncData
err error err error
@ -913,7 +918,7 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ
if body.Withdrawals != nil || header.WithdrawalsHash != nil { if body.Withdrawals != nil || header.WithdrawalsHash != nil {
return nil, consensus.ErrUnexpectedWithdrawals return nil, consensus.ErrUnexpectedWithdrawals
} }
if body.Requests != nil || header.RequestsHash != nil { if header.RequestsHash != nil {
return nil, consensus.ErrUnexpectedRequests return nil, consensus.ErrUnexpectedRequests
} }