Skip to content

perf: Parallelize block validation operations #18441

@yongkangc

Description

@yongkangc

Parallelize block validation operations

Currently, block validation operations in the engine tree execute sequentially. These operations are independent and can be parallelized for performance improvements.

Current implementation

https://github.com/paradigmxyz/reth/blob/main/crates/engine/tree/src/tree/payload_validator.rs#L271-L312

The handle_execution_error method performs sequential validation:

  1. First calls validate_block_inner
  2. Then calls validate_header_against_parent

Other Areas to look at:

Proposed implementation

Execute both validation operations in parallel using rayon::join:

let (block_validation, parent_validation) = rayon::join(
    || self.validate_block_inner(&block),
    || self.consensus.validate_header_against_parent(block.sealed_header(), parent_block)
);

Other parallelization opportunities

  1. Transaction signature recovery - Recover signatures for all transactions in a block in parallel
  2. Multiple block validation - When validating multiple blocks in a batch, validate them in parallel
  3. State prefetching - Prefetch state data in parallel while executing transactions (already partially implemented in prewarm.rs)
  4. Consensus checks - Parallelize independent consensus validation checks within validate_block_inner

Concerns / Thoughts

The question tho is whether there’s a bigger opportunity to eliminate and simplify instead of optimising? and whether the overhead > parallelisation

Metadata

Metadata

Labels

A-engineRelated to the engine implementationC-perfA change motivated by improving speed, memory usage or disk footprint

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions