Skip to content

Consolidate Mining Execution #17529

Description

@mh0lt

At the moment SpawnMiningExecStage executes all transactions twice:

Once when it initially builds the block here:

if len(preparedTxns) > 0 {

and a second time when it has a complete block here:

if err = ExecBlockV3(execS, u, sd, tx, blockHeight, context.Background(), execCfg, false, logger, true); err != nil {

This has 2 unfortunate side effects:

  1. Performance: we're executing the block twice when we only need to do it once
  2. Cosistency: As we never check the contents of the block we finalize and seal we don't actually know if its valid. See Gas mismatch on Hoodi #17363 for a practical example if the implications of this.

I think the reason for this double execution is the fact that

func (rs *StateV3) ApplyTxState(ctx context.Context,
was only practically accessable withing the Exec3 function:
func ExecV3(ctx context.Context,

Once we have finished the BAL & Parallel execution development we can extract this so it can be called directly from block building. Once we have done this we can just call Apply and then compute the state trie.

Note we will also need to call post execution validation to ensure we have a valid block before publishing as we do in the execution flow:

if err := core.BlockPostValidation(se.gasUsed, se.blobGasUsed, checkReceipts, blockReceipts, txTask.Header, se.isMining, txTask.Txs, se.cfg.chainConfig, se.logger); err != nil {

Metadata

Metadata

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions