Skip to content

Conversation

@MegaRedHand
Copy link
Collaborator

@MegaRedHand MegaRedHand commented Oct 27, 2025

Motivation

Block execution is a blocking process, except for some parts which could be async, like DB access. We're currently working on removing async-ness from block execution, for performance reasons, and a recently added await for L2's fee config is bringing us some problems.

Description

This PR changes the tokio::sync::RwLock to a std::sync::RwLock, to avoid async use during block execution. This shouldn't impact the tokio runtime, due to the lock being updated every L1 block, and the change being a single assign operation.

Copilot AI review requested due to automatic review settings October 27, 2025 16:11
@MegaRedHand MegaRedHand requested a review from a team as a code owner October 27, 2025 16:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes async from the Blockchain::new_evm method to improve performance during block execution. The change replaces tokio::sync::RwLock with std::sync::RwLock for the L2 fee config, eliminating unnecessary async overhead in a predominantly blocking process.

Key changes:

  • Changed new_evm method from async to sync by switching from tokio::sync::RwLock to std::sync::RwLock
  • Added explicit error handling for poisoned lock scenarios
  • Extracted EVM creation logic into a standalone new_evm helper function

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/blockchain/blockchain.rs Converted new_evm method to sync, extracted logic to standalone function, switched to std RwLock
crates/blockchain/payload.rs Removed async from PayloadBuildContext::new, updated to use new sync helper
crates/blockchain/tracing.rs Removed await from new_evm call
crates/l2/based/block_fetcher.rs Removed await from new_evm call
crates/l2/sequencer/block_producer.rs Added error handling for poisoned lock when reading fee config
crates/l2/sequencer/block_producer/payload_builder.rs Removed await from PayloadBuildContext::new call
crates/l2/sequencer/l1_committer.rs Removed await from new_evm call
crates/l2/sequencer/l1_watcher.rs Added error handling for poisoned lock when writing fee config
crates/networking/rpc/eth/gas_price.rs Added error handling for poisoned lock when reading fee config
crates/networking/rpc/eth/transaction.rs Removed await from new_evm calls
cmd/ethrex/l2/initializers.rs Changed RwLock initialization from tokio to std

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added the L2 Rollup client label Oct 27, 2025
@github-actions
Copy link

github-actions bot commented Oct 27, 2025

Lines of code report

Total lines added: 16
Total lines removed: 6
Total lines changed: 22

Detailed view
+--------------------------------------------------------------+-------+------+
| File                                                         | Lines | Diff |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/blockchain.rs                       | 958   | +7   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/blockchain/payload.rs                          | 662   | -5   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/block_producer.rs                 | 259   | +3   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/block_producer/payload_builder.rs | 277   | -1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_watcher.rs                     | 421   | +3   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/gas_price.rs                | 124   | +3   |
+--------------------------------------------------------------+-------+------+

@ilitteri ilitteri added this pull request to the merge queue Oct 27, 2025
Merged via the queue into main with commit ebb341b Oct 27, 2025
43 checks passed
@ilitteri ilitteri deleted the remove-async-in-new_evm branch October 27, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L2 Rollup client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants