-
Notifications
You must be signed in to change notification settings - Fork 131
refactor(l2): remove async from Blockchain::new_evm
#5062
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
Conversation
There was a problem hiding this 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_evmmethod from async to sync by switching fromtokio::sync::RwLocktostd::sync::RwLock - Added explicit error handling for poisoned lock scenarios
- Extracted EVM creation logic into a standalone
new_evmhelper 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.
Lines of code reportTotal lines added: Detailed view |
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
awaitfor L2's fee config is bringing us some problems.Description
This PR changes the
tokio::sync::RwLockto astd::sync::RwLock, to avoidasyncuse 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.