Skip to content
Merged
Changes from 2 commits
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
27 changes: 18 additions & 9 deletions crates/revm/src/db/states/bundle_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ impl BundleBuilder {
}

/// Collect storage info of BundleState state
pub fn state_storage(mut self, address: Address, storage: HashMap<U256, (U256, U256)>) -> Self {
pub fn state_storage(
mut self,
address: Address,
storage: &mut HashMap<U256, (U256, U256)>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what the requirement was.

It is to add get_state_storage_mut( function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are at it, it would be good to add mut getters for all fields

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, i'm going to fix it 💪

) -> Self {
self.states.insert(address);
self.state_storage.insert(address, storage);
let entry = self.state_storage.entry(address).or_default();
entry.extend(storage.drain());
self
}

Expand Down Expand Up @@ -138,10 +143,14 @@ impl BundleBuilder {
mut self,
block_number: u64,
address: Address,
storage: Vec<(U256, U256)>,
storage: &mut Vec<(U256, U256)>,
) -> Self {
self.reverts.insert((block_number, address));
self.revert_storage.insert((block_number, address), storage);
let entry = self
.revert_storage
.entry((block_number, address))
.or_default();
entry.append(storage);
self
}

Expand Down Expand Up @@ -832,7 +841,7 @@ mod tests {
)
.state_storage(
account1(),
HashMap::from([(slot1(), (U256::from(0), U256::from(10)))]),
&mut HashMap::from([(slot1(), (U256::from(0), U256::from(10)))]),
)
.state_address(account2())
.state_present_account_info(
Expand All @@ -846,7 +855,7 @@ mod tests {
)
.revert_address(0, account1())
.revert_account_info(0, account1(), Some(None))
.revert_storage(0, account1(), vec![(slot1(), U256::from(0))])
.revert_storage(0, account1(), &mut vec![(slot1(), U256::from(0))])
.revert_account_info(0, account2(), Some(None))
.build()
}
Expand All @@ -865,7 +874,7 @@ mod tests {
)
.state_storage(
account1(),
HashMap::from([(slot1(), (U256::from(0), U256::from(15)))]),
&mut HashMap::from([(slot1(), (U256::from(0), U256::from(15)))]),
)
.revert_address(0, account1())
.revert_account_info(
Expand All @@ -878,7 +887,7 @@ mod tests {
code: None,
})),
)
.revert_storage(0, account1(), vec![(slot1(), U256::from(10))])
.revert_storage(0, account1(), &mut vec![(slot1(), U256::from(10))])
.build()
}

Expand Down Expand Up @@ -1008,7 +1017,7 @@ mod tests {
.revert_address(2, account2())
.revert_account_info(0, account1(), Some(None))
.revert_account_info(2, account2(), None)
.revert_storage(0, account1(), vec![(slot1(), U256::from(10))])
.revert_storage(0, account1(), &mut vec![(slot1(), U256::from(10))])
.build();

assert_eq!(state.reverts.len(), 4);
Expand Down