Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/tracing"
Expand All @@ -30,20 +31,27 @@ import (
"github.com/ethereum/go-ethereum/params"
)

// ChainReader defines methods needed to access the local blockchain data
// during state processing.
type ChainReader interface {
consensus.ChainHeaderReader
ChainContext
}

// StateProcessor is a basic Processor, which takes care of transitioning
// state from one point to another.
//
// StateProcessor implements Processor.
type StateProcessor struct {
config *params.ChainConfig // Chain configuration options
chain *HeaderChain // Canonical header chain
config *params.ChainConfig // Chain configuration options
chainReader ChainReader // Chain reader interface
}

// NewStateProcessor initialises a new StateProcessor.
func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain) *StateProcessor {
func NewStateProcessor(config *params.ChainConfig, chainReader ChainReader) *StateProcessor {
return &StateProcessor{
config: config,
chain: chain,
config: config,
chainReader: chainReader,
}
}

Expand Down Expand Up @@ -79,7 +87,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
if hooks := cfg.Tracer; hooks != nil {
tracingStateDB = state.NewHookedState(statedb, hooks)
}
context = NewEVMBlockContext(header, p.chain, nil)
context = NewEVMBlockContext(header, p.chainReader, nil)
evm := vm.NewEVM(context, tracingStateDB, p.config, cfg)

if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
Expand Down Expand Up @@ -123,7 +131,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
}

// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
p.chain.engine.Finalize(p.chain, header, tracingStateDB, block.Body())
p.chainReader.Engine().Finalize(p.chainReader, header, tracingStateDB, block.Body())

return &ProcessResult{
Receipts: receipts,
Expand Down
Loading