Skip to content

perf(l1): run batch block execution on spawn_blocking - #7117

Open
NikhilSharmaWe wants to merge 1 commit into
lambdaclass:mainfrom
NikhilSharmaWe:perf/l1-batch-spawn-blocking
Open

perf(l1): run batch block execution on spawn_blocking#7117
NikhilSharmaWe wants to merge 1 commit into
lambdaclass:mainfrom
NikhilSharmaWe:perf/l1-batch-spawn-blocking

Conversation

@NikhilSharmaWe

Copy link
Copy Markdown

Motivation

#7100 item 5: add_blocks_in_batch ran the per-block pipeline on a Tokio async worker, so full sync competed with RLPx and body download. The tip path already used spawn_blocking.

Description

  • run the batch loop on spawn_blocking
  • keep per-block cancel checks; drop yield_now (can't await on the blocking pool)
  • remove run_blocks_pipeline; final batches use the same path (cancel + BAL commitment filter)

Test plan

  • cargo fmt --check
  • cargo check -p ethrex-blockchain -p ethrex-p2p -p ethrex
  • cargo clippy -p ethrex-blockchain -p ethrex-p2p -- -D warnings
  • cargo test -p ethrex-test --test ethrex_tests batch_

Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
@NikhilSharmaWe
NikhilSharmaWe requested a review from a team as a code owner August 6, 2026 18:31
@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

The PR moves full-sync batch block execution from Tokio async workers to the blocking pool and consolidates final batches onto the same validated, cancellable path.

  • Wraps Blockchain::add_blocks_in_batch in spawn_blocking.
  • Preserves per-block cancellation checks while removing the async yield.
  • Removes the separate final-batch pipeline and consistently applies BAL commitment filtering.
  • Updates CLI import and batch tests for the owned Arc and BAL vector API.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified.

The unified path retains the prior bounded per-block execution and persistence behavior while adding cancellation and BAL commitment filtering to final batches; all repository call sites were migrated to the new ownership contract.

Important Files Changed

Filename Overview
crates/blockchain/blockchain.rs Moves the existing batch loop to spawn_blocking while retaining cancellation, bounded persistence, BAL filtering, and failure metadata.
crates/networking/p2p/sync/full.rs Removes the redundant final-batch implementation and routes every full-sync batch through the unified blockchain API without changing the common fork-choice update.
cmd/ethrex/cli.rs Adapts block import to the consuming Arc<Self> receiver and owned BAL vector.
test/tests/blockchain/batch_tests.rs Updates batch regression tests to exercise the new Arc<Blockchain> API.
test/tests/blockchain/canonical_commit_gate_tests.rs Updates documentation to identify full-sync batch import as a bounded re-execution path.

Sequence Diagram

sequenceDiagram
  participant Sync as Full sync / CLI import
  participant Async as Tokio async worker
  participant Blocking as Tokio blocking pool
  participant BC as Blockchain pipeline
  participant Store as Store
  Sync->>Async: add_blocks_in_batch(blocks, BALs, token)
  Async->>Blocking: spawn_blocking(batch loop)
  loop Each block
    Blocking->>Blocking: Check cancellation
    Blocking->>BC: add_block_pipeline_bounded
    BC->>BC: Validate BAL commitment and execute
    BC->>Store: Stage block and state updates
  end
  Blocking-->>Async: Batch result
  Async-->>Sync: Success or failure metadata
Loading

Reviews (1): Last reviewed commit: "perf(l1): run batch block execution on s..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant