From b215cd470fe49336b9dd02413da941a2516df8b8 Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Wed, 30 Apr 2025 12:44:56 +0530 Subject: [PATCH] core: fixed processors --- core/blockchain.go | 2 -- core/events.go | 3 +++ core/parallel_state_processor.go | 24 ++++++++++-------------- core/state_processor.go | 5 +++-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 1434eb07fc..b657004630 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -371,8 +371,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis logger: vmConfig.Tracer, } - var err error - bc.hc, err = NewHeaderChain(db, chainConfig, engine, bc.insertStopped) if err != nil { return nil, err diff --git a/core/events.go b/core/events.go index 283718c0cc..ab8b2b5f84 100644 --- a/core/events.go +++ b/core/events.go @@ -23,6 +23,9 @@ import ( // NewTxsEvent is posted when a batch of transactions enter the transaction pool. type NewTxsEvent struct{ Txs []*types.Transaction } +// NewMinedBlockEvent is posted when a block has been imported. +type NewMinedBlockEvent struct{ Block *types.Block } + // RemovedLogsEvent is posted when a reorg happens type RemovedLogsEvent struct{ Logs []*types.Log } diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index 3e58530f59..63b434fbde 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -104,7 +104,7 @@ func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (er // Create a new context to be used in the EVM environment. txContext := NewEVMTxContext(&task.msg) - evm.Reset(txContext, task.statedb) + evm.SetTxContext(txContext) defer func() { if r := recover(); r != nil { @@ -246,7 +246,7 @@ func (task *ExecutionTask) Settle() { // Set the receipt logs and create the bloom filter. receipt.Logs = task.finalStateDB.GetLogs(task.tx.Hash(), task.blockNumber.Uint64(), task.blockHash) - receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) + receipt.Bloom = types.CreateBloom(receipt) receipt.BlockHash = task.blockHash receipt.BlockNumber = task.blockNumber receipt.TransactionIndex = uint(task.finalStateDB.TxIndex()) @@ -304,15 +304,12 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat context := NewEVMBlockContext(header, p.bc.hc, nil) vmenv := vm.NewEVM(context, statedb, p.config, cfg) - var tracingStateDB = vm.StateDB(statedb) - if hooks := cfg.Tracer; hooks != nil { - tracingStateDB = state.NewHookedState(statedb, hooks) - } + if beaconRoot := block.BeaconRoot(); beaconRoot != nil { - ProcessBeaconBlockRoot(*beaconRoot, vmenv, tracingStateDB) + ProcessBeaconBlockRoot(*beaconRoot, vmenv) } if p.config.IsPrague(block.Number()) { - ProcessParentBlockHash(block.ParentHash(), vmenv, statedb) + ProcessParentBlockHash(block.ParentHash(), vmenv) } // Iterate over and process the individual transactions for i, tx := range block.Transactions() { @@ -405,17 +402,16 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat var requests [][]byte if p.config.IsPrague(block.Number()) && p.config.Bor == nil { // EIP-6110 deposits - depositRequests, err := ParseDepositLogs(allLogs, p.config) + err := ParseDepositLogs(&requests, allLogs, p.config) if err != nil { return nil, err } - requests = append(requests, depositRequests) + // EIP-7002 withdrawals - withdrawalRequests := ProcessWithdrawalQueue(vmenv, tracingStateDB) - requests = append(requests, withdrawalRequests) + ProcessWithdrawalQueue(&requests, vmenv) + // EIP-7251 consolidations - consolidationRequests := ProcessConsolidationQueue(vmenv, tracingStateDB) - requests = append(requests, consolidationRequests) + ProcessConsolidationQueue(&requests, vmenv) } // Finalize the block, applying any consensus engine specific extras (e.g. block rewards) diff --git a/core/state_processor.go b/core/state_processor.go index 99a880b116..7846b8bdd5 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -159,7 +159,7 @@ func ApplyTransactionWithEVM(msg *Message, gp *GasPool, statedb *state.StateDB, // Create a new context to be used in the EVM environment. txContext := NewEVMTxContext(msg) - evm.Reset(txContext, tracingStateDB) + evm.SetTxContext(txContext) var result *ExecutionResult @@ -313,7 +313,8 @@ func ProcessParentBlockHash(prevHash common.Hash, evm *vm.EVM) { GasPrice: common.Big0, GasFeeCap: common.Big0, GasTipCap: common.Big0, - To: &addr, + To: ¶ms.HistoryStorageAddress, + Data: prevHash.Bytes(), } evm.SetTxContext(NewEVMTxContext(msg)) evm.StateDB.AddAddressToAccessList(params.HistoryStorageAddress)