Skip to content

Commit

Permalink
feat: return wiped inside storage changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Sep 11, 2023
1 parent d1b5dd6 commit 49a6dfb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/revm/src/db/states/bundle_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ impl BundleAccount {
None
}
AccountStatus::Destroyed => {
// clear this storage and move it to the Revert.
let this_storage = self.storage.drain().collect();
let ret = match self.status {
AccountStatus::InMemoryChange | AccountStatus::Changed | AccountStatus::Loaded | AccountStatus::LoadedEmptyEIP161 => {
Expand Down
3 changes: 2 additions & 1 deletion crates/revm/src/db/states/bundle_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,12 @@ impl BundleState {
}
}

if !account_storage_changed.is_empty() {
if !account_storage_changed.is_empty() || was_destroyed {
account_storage_changed.sort_by(|a, b| a.0.cmp(&b.0));
// append storage changes to account.
storage.push(PlainStorageChangeset {
address,
wipe_storage: was_destroyed,
storage: account_storage_changed,
});
}
Expand Down
2 changes: 2 additions & 0 deletions crates/revm/src/db/states/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub struct StateChangeset {
pub struct PlainStorageChangeset {
/// Address of account
pub address: B160,
/// Wipe storage,
pub wipe_storage: bool,
/// Storage key value pairs.
pub storage: Vec<(U256, U256)>,
}
Expand Down

0 comments on commit 49a6dfb

Please sign in to comment.