Skip to content

state, consensus: skip requests check when receipts unavailable after exec #14107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/state/exec3/historical_trace_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here i don't know if receipts are available, but perhaps not needed to check it (?)

if err != nil {
txTask.Error = err
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/state/exec3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
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,
Expand All @@ -175,7 +175,7 @@
}
}

func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) {
func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining , skipPostEvaluaion bool) {

Check failure on line 178 in cmd/state/exec3/state.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gofmt)
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.
Expand Down Expand Up @@ -238,7 +238,6 @@
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 */)
Expand All @@ -247,7 +246,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions consensus/aura/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions consensus/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@

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)
Expand Down Expand Up @@ -186,7 +186,7 @@
}

var rs types.FlatRequests
if config.IsPrague(header.Time) {
if config.IsPrague(header.Time) && !skipReceiptsEval{

Check failure on line 189 in consensus/merge/merge.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gofmt)
rs = make(types.FlatRequests, 0)
allLogs := make(types.Logs, 0)
for _, rec := range receipts {
Expand Down Expand Up @@ -225,7 +225,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion eth/stagedsync/exec3_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion eth/stagedsync/exec3_serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion polygon/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions polygon/bor/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading