impl original_storage in SubstrateStackState#871
impl original_storage in SubstrateStackState#871sorpaas merged 6 commits intopolkadot-evm:masterfrom
Conversation
| @@ -629,6 +643,15 @@ where | |||
| } | |||
|
|
|||
| fn set_storage(&mut self, address: H160, index: H256, value: H256) { | |||
There was a problem hiding this comment.
Add a check beforehand that:
- If
self.original_storagedoes not contain the key, - and the to-set-value is the same as the current value.
Skip inserting into the original_storage.
There was a problem hiding this comment.
If self.original_storage does not contain the key,
That's whatif let Vacant(e) = self.original_storage.entry(...)does, which was recommanded by clippy instead ofcontainstheninsert.
and the to-set-value is the same as the current value.
Yeah, can add this check to not insert for same value as original.
| // in the transaction. | ||
| use sp_std::collections::btree_map::Entry::Vacant; | ||
| if let Vacant(e) = self.original_storage.entry((address, index)) { | ||
| let original = <AccountStorages<T>>::get(address, index); |
There was a problem hiding this comment.
Use self.storage here to keep it consistent.
| let original = <AccountStorages<T>>::get(address, index); | |
| let original = self.storage(address, index); |
There was a problem hiding this comment.
Cannot use self.storage as we're already borrowing self with self.original_storage.entry. Seems better to keep <AccountStorages<T>>::get than fetching the value every time even when the entry is not vacant.
408fbe3 to
018eb95
Compare
* handle original_storage * only cache original_storage in set_storage * test * clippy * remove RefCell * don't write to cache if = to original
* handle original_storage * only cache original_storage in set_storage * test * clippy * remove RefCell * don't write to cache if = to original
Implement
original_storagewhich previously returnedNoneeverytime.