Skip to content

Commit

Permalink
fix: reset tstorage on finalize (#1168)
Browse files Browse the repository at this point in the history
* fix: reset tstorage on finalize

* destruct Self

* change order

* Update crates/revm/src/journaled_state.rs
  • Loading branch information
mattsse authored and rakita committed Mar 9, 2024
1 parent 46bbcfc commit 34e636b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bins/revm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
bytes = "1.4"
hex = "0.4"
revm = { path = "../../crates/revm", version = "6.1.0",default-features=false }
revm = { path = "../../crates/revm", version = "6.2.0",default-features=false }
microbench = "0.5"
alloy-sol-macro = "0.6.3"
alloy-sol-types = "0.6.3"
Expand Down
2 changes: 1 addition & 1 deletion bins/revme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hash-db = "0.15"
hashbrown = "0.14"
indicatif = "0.17"
plain_hasher = "0.2"
revm = { path = "../../crates/revm", version = "6.1.0", default-features = false, features = [
revm = { path = "../../crates/revm", version = "6.2.0", default-features = false, features = [
"ethersdb",
"std",
"serde-json",
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords = ["no_std", "ethereum", "evm", "revm"]
license = "MIT"
name = "revm"
repository = "https://github.com/bluealloy/revm"
version = "6.1.0"
version = "6.2.0"
readme = "../../README.md"

[package.metadata.docs.rs]
Expand Down
24 changes: 19 additions & 5 deletions crates/revm/src/journaled_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::vec::Vec;
pub struct JournaledState {
/// Current state.
pub state: State,
/// EIP 1153 transient storage
/// [EIP-1153[(https://eips.ethereum.org/EIPS/eip-1153) transient storage that is discarded after every transactions
pub transient_storage: TransientStorage,
/// logs
pub logs: Vec<Log>,
Expand Down Expand Up @@ -92,13 +92,27 @@ impl JournaledState {
}

/// Does cleanup and returns modified state.
///
/// This resets the [JournaledState] to its initial state in [Self::new]
#[inline]
pub fn finalize(&mut self) -> (State, Vec<Log>) {
let state = mem::take(&mut self.state);
let Self {
state,
transient_storage,
logs,
depth,
journal,
// kept, see [Self::new]
spec: _,
warm_preloaded_addresses: _,
} = self;

*transient_storage = TransientStorage::default();
*journal = vec![vec![]];
*depth = 0;
let state = mem::take(state);
let logs = mem::take(logs);

let logs = mem::take(&mut self.logs);
self.journal = vec![vec![]];
self.depth = 0;
(state, logs)
}

Expand Down

0 comments on commit 34e636b

Please sign in to comment.