Skip to content

Make Lazy::Drop always clear up all its storage #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions crates/storage/src/lazy/lazy_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,16 @@ where
// the value is not yet in the cache. we need it in there
// though in order to properly clean up.
crate::assert_footprint_threshold!(<T as SpreadLayout>::FOOTPRINT);
let _ = self.get();
let entry = self.entry().expect("entry must exist after prior get");
clear_spread_root_opt::<T, _>(key, || entry.value().into())
if <T as SpreadLayout>::REQUIRES_DEEP_CLEAN_UP {
let _ = self.get();
let entry =
self.entry().expect("entry must exist after prior get");
clear_spread_root_opt::<T, _>(key, || entry.value().into())
} else {
// The type does not require deep clean-up so we can simply clean-up
// its associated storage cell and be done without having to load it first.
ink_env::clear_contract_storage(&key);
}
}
}
}
Expand Down