Skip to content

Commit d296f9e

Browse files
w1tchermattsse
andauthored
fix(anvil): resolve incorrect historical states dump behavior (#12732)
fix: resolve incorrect historical states dump behavior Co-authored-by: Matthias Seitz <[email protected]>
1 parent a78c89f commit d296f9e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/anvil/src/eth/backend/mem/fork_db.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,21 @@ impl MaybeFullDatabase for ForkDbStateSnapshot {
127127
}
128128

129129
fn clear_into_state_snapshot(&mut self) -> StateSnapshot {
130-
std::mem::take(&mut self.state_snapshot)
130+
let mut state_snapshot = std::mem::take(&mut self.state_snapshot);
131+
let local_state_snapshot = self.local.clear_into_state_snapshot();
132+
state_snapshot.accounts.extend(local_state_snapshot.accounts);
133+
state_snapshot.storage.extend(local_state_snapshot.storage);
134+
state_snapshot.block_hashes.extend(local_state_snapshot.block_hashes);
135+
state_snapshot
131136
}
132137

133138
fn read_as_state_snapshot(&self) -> StateSnapshot {
134-
self.state_snapshot.clone()
139+
let mut state_snapshot = self.state_snapshot.clone();
140+
let local_state_snapshot = self.local.read_as_state_snapshot();
141+
state_snapshot.accounts.extend(local_state_snapshot.accounts);
142+
state_snapshot.storage.extend(local_state_snapshot.storage);
143+
state_snapshot.block_hashes.extend(local_state_snapshot.block_hashes);
144+
state_snapshot
135145
}
136146

137147
fn clear(&mut self) {

0 commit comments

Comments
 (0)