Fix an issue in reset vs storage fetching
@@ -115,6 +115,23 @@ impl<'config> MemoryStackSubstate<'config> {
self.metadata.swallow_commit(exited.metadata)?;
self.logs.append(&mut exited.logs);
+
+ let mut resets = BTreeSet::new();
+ for (address, account) in &exited.accounts {
+ if account.reset {
+ resets.insert(*address);
+ }
+ }
+ let mut reset_keys = BTreeSet::new();
+ for (address, key) in self.storages.keys() {
+ if resets.contains(&address) {
+ reset_keys.insert((*address, *key));
+ }
+ }
+ for (address, key) in reset_keys {
+ self.storages.remove(&(address, key));
+ }
+
self.accounts.append(&mut exited.accounts);
self.storages.append(&mut exited.storages);
self.deletes.append(&mut exited.deletes);
@@ -230,6 +247,10 @@ impl<'config> MemoryStackSubstate<'config> {
if !self.accounts.contains_key(&address) {
let account = self.known_account(address)
.cloned()
+ .map(|mut v| {
+ v.reset = false;
+ v
+ })
.unwrap_or_else(|| MemoryStackAccount {
basic: backend.basic(address),
code: None,
