mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core: add blockchain back to state processor for bor consensus
This commit is contained in:
parent
88147109be
commit
adb53876db
3 changed files with 12 additions and 8 deletions
|
|
@ -363,7 +363,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
|||
bc.statedb = state.NewDatabase(bc.triedb, nil)
|
||||
bc.validator = NewBlockValidator(chainConfig, bc)
|
||||
bc.prefetcher = newStatePrefetcher(chainConfig, bc.hc)
|
||||
bc.processor = NewStateProcessor(chainConfig, bc.hc)
|
||||
bc.processor = NewStateProcessor(chainConfig, bc.hc, bc)
|
||||
|
||||
bc.genesisBlock = bc.GetBlockByNumber(0)
|
||||
if bc.genesisBlock == nil {
|
||||
|
|
|
|||
|
|
@ -37,15 +37,17 @@ import (
|
|||
//
|
||||
// StateProcessor implements Processor.
|
||||
type StateProcessor struct {
|
||||
config *params.ChainConfig // Chain configuration options
|
||||
chain *HeaderChain // Canonical header chain
|
||||
config *params.ChainConfig // Chain configuration options
|
||||
chain *HeaderChain // Canonical header chain
|
||||
blockchain *BlockChain
|
||||
}
|
||||
|
||||
// NewStateProcessor initialises a new StateProcessor.
|
||||
func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain) *StateProcessor {
|
||||
func NewStateProcessor(config *params.ChainConfig, chain *HeaderChain, blockchain *BlockChain) *StateProcessor {
|
||||
return &StateProcessor{
|
||||
config: config,
|
||||
chain: chain,
|
||||
config: config,
|
||||
chain: chain,
|
||||
blockchain: blockchain,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +135,9 @@ 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())
|
||||
// Note that we specifically need `Blockchain` for `ChainHeaderReader` interface as it's
|
||||
// typecasted in bor consensus for setting state-sync events.
|
||||
p.chain.engine.Finalize(p.blockchain, header, tracingStateDB, block.Body())
|
||||
|
||||
return &ProcessResult{
|
||||
Receipts: receipts,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func ExecuteStateless(config *params.ChainConfig, block *types.Block, witness *s
|
|||
headerCache: lru.NewCache[common.Hash, *types.Header](256),
|
||||
engine: beacon.New(ethash.NewFaker()),
|
||||
}
|
||||
processor := NewStateProcessor(config, headerChain)
|
||||
processor := NewStateProcessor(config, headerChain, nil)
|
||||
validator := NewBlockValidator(config, nil) // No chain, we only validate the state, not the block
|
||||
|
||||
// Run the stateless blocks processing and self-validate certain fields
|
||||
|
|
|
|||
Loading…
Reference in a new issue