diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index 03581d07c0f..133b90fb78e 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -1140,7 +1140,7 @@ func (e *remoteConsensusEngine) Prepare(_ consensus.ChainHeaderReader, _ *types. panic("remoteConsensusEngine.Prepare not supported") } -func (e *remoteConsensusEngine) Finalize(_ *chain.Config, _ *types.Header, _ *state.IntraBlockState, _ types.Transactions, _ []*types.Header, _ types.Receipts, _ []*types.Withdrawal, _ consensus.ChainReader, _ consensus.SystemCall, _ log.Logger) (types.Transactions, types.Receipts, types.FlatRequests, error) { +func (e *remoteConsensusEngine) Finalize(_ *chain.Config, _ *types.Header, _ *state.IntraBlockState, _ types.Transactions, _ []*types.Header, _ types.Receipts, _ []*types.Withdrawal, _ consensus.ChainReader, _ consensus.SystemCall, skipReceiptsEval bool, _ log.Logger) (types.Transactions, types.Receipts, types.FlatRequests, error) { panic("remoteConsensusEngine.Finalize not supported") } diff --git a/cmd/state/exec3/historical_trace_worker.go b/cmd/state/exec3/historical_trace_worker.go index b4b1be0b838..76a343e6c48 100644 --- a/cmd/state/exec3/historical_trace_worker.go +++ b/cmd/state/exec3/historical_trace_worker.go @@ -180,7 +180,7 @@ func (rw *HistoricalTraceWorker) RunTxTask(txTask *state.TxTask) { return core.SysCallContract(contract, data, rw.execArgs.ChainConfig, ibs, header, rw.execArgs.Engine, false /* constCall */) } - _, _, _, err := rw.execArgs.Engine.Finalize(rw.execArgs.ChainConfig, types.CopyHeader(header), ibs, txTask.Txs, txTask.Uncles, txTask.BlockReceipts, txTask.Withdrawals, rw.chain, syscall, rw.logger) + _, _, _, err := rw.execArgs.Engine.Finalize(rw.execArgs.ChainConfig, types.CopyHeader(header), ibs, txTask.Txs, txTask.Uncles, txTask.BlockReceipts, txTask.Withdrawals, rw.chain, syscall, true /* skipReceiptsEval */, rw.logger) if err != nil { txTask.Error = err } diff --git a/cmd/state/exec3/state.go b/cmd/state/exec3/state.go index 324ac38c24a..9ee469ac4b6 100644 --- a/cmd/state/exec3/state.go +++ b/cmd/state/exec3/state.go @@ -153,7 +153,7 @@ func (rw *Worker) Run() (err error) { func (rw *Worker) RunTxTask(txTask *state.TxTask, isMining bool) { rw.lock.Lock() defer rw.lock.Unlock() - rw.RunTxTaskNoLock(txTask, isMining) + rw.RunTxTaskNoLock(txTask, isMining, false) } // Needed to set history reader when need to offset few txs from block beginning and does not break processing, @@ -175,7 +175,7 @@ func (rw *Worker) SetReader(reader state.ResettableStateReader) { } } -func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) { +func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining, skipPostEvaluaion bool) { if txTask.HistoryExecution && !rw.historyMode { // in case if we cancelled execution and commitment happened in the middle of the block, we have to process block // from the beginning until committed txNum and only then disable history mode. @@ -238,7 +238,6 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) { break } - //fmt.Printf("txNum=%d, blockNum=%d, finalisation of the block\n", txTask.TxNum, txTask.BlockNum) // End of block transaction in a block syscall := func(contract libcommon.Address, data []byte) ([]byte, error) { return core.SysCallContract(contract, data, rw.chainConfig, ibs, header, rw.engine, false /* constCall */) @@ -247,7 +246,7 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) { if isMining { _, txTask.Txs, txTask.BlockReceipts, _, err = rw.engine.FinalizeAndAssemble(rw.chainConfig, types.CopyHeader(header), ibs, txTask.Txs, txTask.Uncles, txTask.BlockReceipts, txTask.Withdrawals, rw.chain, syscall, nil, rw.logger) } else { - _, _, _, err = rw.engine.Finalize(rw.chainConfig, types.CopyHeader(header), ibs, txTask.Txs, txTask.Uncles, txTask.BlockReceipts, txTask.Withdrawals, rw.chain, syscall, rw.logger) + _, _, _, err = rw.engine.Finalize(rw.chainConfig, types.CopyHeader(header), ibs, txTask.Txs, txTask.Uncles, txTask.BlockReceipts, txTask.Withdrawals, rw.chain, syscall, skipPostEvaluaion, rw.logger) } if err != nil { txTask.Error = err diff --git a/consensus/aura/aura.go b/consensus/aura/aura.go index e0184745cfd..6250fb9fe67 100644 --- a/consensus/aura/aura.go +++ b/consensus/aura/aura.go @@ -717,7 +717,7 @@ func (c *AuRa) applyRewards(header *types.Header, state *state.IntraBlockState, // word `signal epoch` == word `pending epoch` func (c *AuRa) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal, - chain consensus.ChainReader, syscall consensus.SystemCall, logger log.Logger, + chain consensus.ChainReader, syscall consensus.SystemCall, skipReceiptsEval bool, logger log.Logger, ) (types.Transactions, types.Receipts, types.FlatRequests, error) { if err := c.applyRewards(header, state, syscall); err != nil { return nil, nil, nil, err @@ -856,7 +856,7 @@ func allHeadersUntil(chain consensus.ChainHeaderReader, from *types.Header, to l // FinalizeAndAssemble implements consensus.Engine func (c *AuRa) FinalizeAndAssemble(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal, chain consensus.ChainReader, syscall consensus.SystemCall, call consensus.Call, logger log.Logger) (*types.Block, types.Transactions, types.Receipts, types.FlatRequests, error) { - outTxs, outReceipts, _, err := c.Finalize(config, header, state, txs, uncles, receipts, withdrawals, chain, syscall, logger) + outTxs, outReceipts, _, err := c.Finalize(config, header, state, txs, uncles, receipts, withdrawals, chain, syscall, false, logger) if err != nil { return nil, nil, nil, nil, err } diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 70c1a7f85a7..237e8d7fdd3 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -379,7 +379,7 @@ func (c *Clique) CalculateRewards(config *chain.Config, header *types.Header, un // rewards given. func (c *Clique) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, r types.Receipts, withdrawals []*types.Withdrawal, - chain consensus.ChainReader, syscall consensus.SystemCall, logger log.Logger, + chain consensus.ChainReader, syscall consensus.SystemCall, skipReceiptsEval bool, logger log.Logger, ) (types.Transactions, types.Receipts, types.FlatRequests, error) { return txs, r, nil, nil } diff --git a/consensus/consensus.go b/consensus/consensus.go index 0ed3552cfbd..5ef365ddfbe 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -165,7 +165,7 @@ type EngineWriter interface { // Finalize runs any post-transaction state modifications (e.g. block rewards) // but does not assemble the block. Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, - txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal, chain ChainReader, syscall SystemCall, logger log.Logger, + txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal, chain ChainReader, syscall SystemCall, skipReceiptsEval bool, logger log.Logger, ) (types.Transactions, types.Receipts, types.FlatRequests, error) // FinalizeAndAssemble runs any post-transaction state modifications (e.g. block diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 2ab2624f96d..99290c3e536 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -568,7 +568,7 @@ func (ethash *Ethash) Initialize(config *chain.Config, chain consensus.ChainHead // setting the final state on the header func (ethash *Ethash) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, r types.Receipts, withdrawals []*types.Withdrawal, - chain consensus.ChainReader, syscall consensus.SystemCall, logger log.Logger, + chain consensus.ChainReader, syscall consensus.SystemCall, skipReceiptsEval bool, logger log.Logger, ) (types.Transactions, types.Receipts, types.FlatRequests, error) { // Accumulate any block and uncle rewards and commit the final state root accumulateRewards(config, state, header, uncles) @@ -583,7 +583,7 @@ func (ethash *Ethash) FinalizeAndAssemble(chainConfig *chain.Config, header *typ ) (*types.Block, types.Transactions, types.Receipts, types.FlatRequests, error) { // Finalize block - outTxs, outR, _, err := ethash.Finalize(chainConfig, header, state, txs, uncles, r, withdrawals, chain, syscall, logger) + outTxs, outR, _, err := ethash.Finalize(chainConfig, header, state, txs, uncles, r, withdrawals, chain, syscall, false, logger) if err != nil { return nil, nil, nil, nil, err } diff --git a/consensus/merge/merge.go b/consensus/merge/merge.go index bab6541532b..28cd46bb8a6 100644 --- a/consensus/merge/merge.go +++ b/consensus/merge/merge.go @@ -151,10 +151,10 @@ func (s *Merge) CalculateRewards(config *chain.Config, header *types.Header, unc func (s *Merge) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal, - chain consensus.ChainReader, syscall consensus.SystemCall, logger log.Logger, + chain consensus.ChainReader, syscall consensus.SystemCall, skipReceiptsEval bool, logger log.Logger, ) (types.Transactions, types.Receipts, types.FlatRequests, error) { if !misc.IsPoSHeader(header) { - return s.eth1Engine.Finalize(config, header, state, txs, uncles, receipts, withdrawals, chain, syscall, logger) + return s.eth1Engine.Finalize(config, header, state, txs, uncles, receipts, withdrawals, chain, syscall, skipReceiptsEval, logger) } rewards, err := s.CalculateRewards(config, header, uncles, syscall) @@ -186,7 +186,7 @@ func (s *Merge) Finalize(config *chain.Config, header *types.Header, state *stat } var rs types.FlatRequests - if config.IsPrague(header.Time) { + if config.IsPrague(header.Time) && !skipReceiptsEval { rs = make(types.FlatRequests, 0) allLogs := make(types.Logs, 0) for _, rec := range receipts { @@ -225,7 +225,7 @@ func (s *Merge) FinalizeAndAssemble(config *chain.Config, header *types.Header, return s.eth1Engine.FinalizeAndAssemble(config, header, state, txs, uncles, receipts, withdrawals, chain, syscall, call, logger) } header.RequestsHash = nil - outTxs, outReceipts, outRequests, err := s.Finalize(config, header, state, txs, uncles, receipts, withdrawals, chain, syscall, logger) + outTxs, outReceipts, outRequests, err := s.Finalize(config, header, state, txs, uncles, receipts, withdrawals, chain, syscall, false, logger) if err != nil { return nil, nil, nil, nil, err diff --git a/core/blockchain.go b/core/blockchain.go index f4cebd0d6c1..6211821436d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -345,7 +345,7 @@ func FinalizeBlockExecution( if isMining { newBlock, newTxs, newReceipt, retRequests, err = engine.FinalizeAndAssemble(cc, header, ibs, txs, uncles, receipts, withdrawals, chainReader, syscall, nil, logger) } else { - newTxs, newReceipt, retRequests, err = engine.Finalize(cc, header, ibs, txs, uncles, receipts, withdrawals, chainReader, syscall, logger) + newTxs, newReceipt, retRequests, err = engine.Finalize(cc, header, ibs, txs, uncles, receipts, withdrawals, chainReader, syscall, false, logger) } if err != nil { return nil, nil, nil, nil, err diff --git a/eth/stagedsync/exec3_parallel.go b/eth/stagedsync/exec3_parallel.go index b698a70b665..dfafd8acd6b 100644 --- a/eth/stagedsync/exec3_parallel.go +++ b/eth/stagedsync/exec3_parallel.go @@ -398,7 +398,7 @@ func (pe *parallelExecutor) processResultQueue(ctx context.Context, inputTxNum u } // resolve first conflict right here: it's faster and conflict-free - pe.applyWorker.RunTxTaskNoLock(txTask.Reset(), pe.isMining) + pe.applyWorker.RunTxTaskNoLock(txTask.Reset(), pe.isMining, false) if txTask.Error != nil { //fmt.Println("RETRY", txTask.TxNum, txTask.Error) return outputTxNum, conflicts, triggers, processedBlockNum, false, fmt.Errorf("%w: %v", consensus.ErrInvalidBlock, txTask.Error) diff --git a/eth/stagedsync/exec3_serial.go b/eth/stagedsync/exec3_serial.go index 6d2214be0b2..908ee5ff0e9 100644 --- a/eth/stagedsync/exec3_serial.go +++ b/eth/stagedsync/exec3_serial.go @@ -40,7 +40,7 @@ func (se *serialExecutor) execute(ctx context.Context, tasks []*state.TxTask) (c return false, nil } - se.applyWorker.RunTxTaskNoLock(txTask, se.isMining) + se.applyWorker.RunTxTaskNoLock(txTask, se.isMining, se.skipPostEvaluation) if err := func() error { if errors.Is(txTask.Error, context.Canceled) { return txTask.Error diff --git a/polygon/bor/bor.go b/polygon/bor/bor.go index 9e9ccc0a428..804c6923e00 100644 --- a/polygon/bor/bor.go +++ b/polygon/bor/bor.go @@ -1019,7 +1019,7 @@ func (c *Bor) CalculateRewards(config *chain.Config, header *types.Header, uncle // rewards given. func (c *Bor) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, r types.Receipts, withdrawals []*types.Withdrawal, - chain consensus.ChainReader, syscall consensus.SystemCall, logger log.Logger, + chain consensus.ChainReader, syscall consensus.SystemCall, skipReceiptsEval bool, logger log.Logger, ) (types.Transactions, types.Receipts, types.FlatRequests, error) { headerNumber := header.Number.Uint64() diff --git a/polygon/bor/fake.go b/polygon/bor/fake.go index db6d5769b51..1826786ad71 100644 --- a/polygon/bor/fake.go +++ b/polygon/bor/fake.go @@ -38,7 +38,7 @@ func NewFaker() *FakeBor { func (f *FakeBor) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState, txs types.Transactions, uncles []*types.Header, r types.Receipts, withdrawals []*types.Withdrawal, - chain consensus.ChainReader, syscall consensus.SystemCall, logger log.Logger, + chain consensus.ChainReader, syscall consensus.SystemCall, skipReceiptsEval bool, logger log.Logger, ) (types.Transactions, types.Receipts, types.FlatRequests, error) { - return f.FakeEthash.Finalize(config, header, state, txs, uncles, r, withdrawals, chain, syscall, logger) + return f.FakeEthash.Finalize(config, header, state, txs, uncles, r, withdrawals, chain, syscall, skipReceiptsEval, logger) }