Skip to content
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

perf(rpc): use only Revm cache for execution witness #10454

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use reth_rpc_types::{
use reth_tasks::pool::BlockingTaskGuard;
use reth_trie::{HashedPostState, HashedStorage};
use revm::{
db::{states::bundle_state::BundleRetention, CacheDB},
db::CacheDB,
primitives::{db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg},
StateBuilder,
};
Expand Down Expand Up @@ -581,10 +581,8 @@ where
.eth_api
.spawn_with_state_at_block(block.parent_hash.into(), move |state| {
let evm_config = Call::evm_config(this.eth_api()).clone();
let mut db = StateBuilder::new()
.with_database(StateProviderDatabase::new(state))
.with_bundle_update()
.build();
let mut db =
StateBuilder::new().with_database(StateProviderDatabase::new(state)).build();

pre_block_beacon_root_contract_call(
&mut db,
Expand Down Expand Up @@ -623,20 +621,18 @@ where
db.commit(res.state);
}

// Merge all state transitions
db.merge_transitions(BundleRetention::Reverts);

// Take the bundle state
let bundle_state = db.take_bundle();
// No need to merge transitions and create the bundle state, we will use Revm's
// cache directly.

// Initialize a map of preimages.
let mut state_preimages = HashMap::new();

// Grab all account proofs for the data accessed during block execution.
//
// Note: We grab *all* accounts in the cache here, as the `BundleState` prunes
// referenced accounts + storage slots.
let mut hashed_state = HashedPostState::from_bundle_state(&bundle_state.state);
// referenced accounts + storage slots. Cache is a superset of `BundleState`, so we
// can just query it to get the latest state of all accounts and storage slots.
let mut hashed_state = HashedPostState::default();
for (address, account) in db.cache.accounts {
let hashed_address = keccak256(address);
hashed_state.accounts.insert(
Expand Down
Loading