diff --git a/bins/revme/src/statetest/runner.rs b/bins/revme/src/statetest/runner.rs index 55c388796e..ca92b1f299 100644 --- a/bins/revme/src/statetest/runner.rs +++ b/bins/revme/src/statetest/runner.rs @@ -257,6 +257,7 @@ pub fn execute_test_suit( )); let mut state = revm::db::StateBuilder::default() .with_cached_prestate(cache) + .with_bundle_update() .build(); let mut evm = revm::new(); evm.database(&mut state); @@ -294,6 +295,7 @@ pub fn execute_test_suit( )); let mut state = revm::db::StateBuilder::default() .with_cached_prestate(cache) + .with_bundle_update() .build(); evm.database(&mut state); let _ = diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index 038cea7070..b50b2d7fbd 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -310,7 +310,7 @@ mod tests { /// state of the account before the block. #[test] fn reverts_preserve_old_values() { - let mut state = StateBuilder::default().build(); + let mut state = StateBuilder::default().with_bundle_update().build(); let (slot1, slot2, slot3) = (U256::from(1), U256::from(2), U256::from(3)); @@ -555,7 +555,7 @@ mod tests { /// Checks that the accounts and storages that are changed within the block and reverted to their previous state do not appear in the reverts. #[test] fn bundle_scoped_reverts_collapse() { - let mut state = StateBuilder::default().build(); + let mut state = StateBuilder::default().with_bundle_update().build(); // Non-existing account. let new_account_address = B160::from_slice(&[0x1; 20]); @@ -721,7 +721,7 @@ mod tests { /// Checks that the behavior of selfdestruct within the block is correct. #[test] fn selfdestruct_state_and_reverts() { - let mut state = StateBuilder::default().build(); + let mut state = StateBuilder::default().with_bundle_update().build(); // Existing account. let existing_account_address = B160::from_slice(&[0x1; 20]); diff --git a/crates/revm/src/db/states/state_builder.rs b/crates/revm/src/db/states/state_builder.rs index fb943815a7..d4b7914066 100644 --- a/crates/revm/src/db/states/state_builder.rs +++ b/crates/revm/src/db/states/state_builder.rs @@ -5,26 +5,28 @@ use revm_interpreter::primitives::{db::Database, B256}; /// Allows building of State and initializing it with different options. pub struct StateBuilder { - pub with_state_clear: bool, + /// Enabled state clear flag that is introduced in Spurious Dragon hardfork. + /// Default is true as spurious dragon happened long time ago. + with_state_clear: bool, /// Optional database that we use to fetch data from. If database is not present, we will /// return not existing account and storage. /// /// Note: It is marked as Send so database can be shared between threads. - pub database: DB, //Box + Send + 'a>, + database: DB, //Box + Send + 'a>, /// if there is prestate that we want to use. /// This would mean that we have additional state layer between evm and disk/database. - pub with_bundle_prestate: Option, + with_bundle_prestate: Option, /// This will initialize cache to this state. - pub with_cache_prestate: Option, + with_cache_prestate: Option, /// Do we want to create reverts and update bundle state. - /// Default is true. - pub without_bundle_update: bool, + /// Default is false. + with_bundle_update: bool, /// Do we want to merge transitions in background. /// This will allows evm to continue executing. /// Default is false. - pub with_background_transition_merge: bool, + with_background_transition_merge: bool, /// If we want to set different block hashes - pub with_block_hashes: BTreeMap, + with_block_hashes: BTreeMap, } impl Default for StateBuilder> { @@ -34,7 +36,7 @@ impl Default for StateBuilder> { database: Box::::default(), with_cache_prestate: None, with_bundle_prestate: None, - without_bundle_update: false, + with_bundle_update: false, with_background_transition_merge: false, with_block_hashes: BTreeMap::new(), } @@ -58,7 +60,7 @@ impl StateBuilder { database, with_cache_prestate: self.with_cache_prestate, with_bundle_prestate: self.with_bundle_prestate, - without_bundle_update: self.without_bundle_update, + with_bundle_update: self.with_bundle_update, with_background_transition_merge: self.with_background_transition_merge, with_block_hashes: self.with_block_hashes, } @@ -85,13 +87,13 @@ impl StateBuilder { } } - /// Don't make transitions and don't update bundle state. + /// Make transitions and update bundle state. /// - /// This is good option if we don't care about creating reverts - /// or getting output of changed states. - pub fn without_bundle_update(self) -> Self { + /// This is needed option if we want to create reverts + /// and getting output of changed states. + pub fn with_bundle_update(self) -> Self { Self { - without_bundle_update: true, + with_bundle_update: true, ..self } } @@ -135,10 +137,10 @@ impl StateBuilder { .with_cache_prestate .unwrap_or(CacheState::new(self.with_state_clear)), database: self.database, - transition_state: if self.without_bundle_update { - None - } else { + transition_state: if self.with_bundle_update { Some(TransitionState::default()) + } else { + None }, bundle_state: self.with_bundle_prestate, use_preloaded_bundle,