Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions crates/rbuilder/src/building/evm_inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub struct SlotKey {
}

#[derive(Debug, Clone, Default, PartialEq, Eq)]
/// UsedStateTrace is an execution trace of the given order
/// Limitations:
/// * `written_slot_values`, `received_amount` and `sent_amount` are not correct if transaction reverts
pub struct UsedStateTrace {
/// read slot values contains first read
pub read_slot_values: HashMap<SlotKey, B256>,
Expand Down Expand Up @@ -173,6 +176,14 @@ where
}

fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) {
// selfdestruct can be called multiple times during transaction execution
if self
.used_state_trace
.destructed_contracts
.contains(&contract)
{
return;
}
self.used_state_trace.destructed_contracts.push(contract);
if !value.is_zero() {
*self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ fn test_transfer() -> eyre::Result<()> {
.get(&sender_nonce_slot_key);
assert!(nonce_read_value.is_some());
assert!(nonce_written_value.is_some());
let nonce_read_value: U256 = nonce_read_value.unwrap().clone().into();
let nonce_written_value: U256 = nonce_written_value.unwrap().clone().into();
let nonce_read_value: U256 = (*nonce_read_value.unwrap()).into();
let nonce_written_value: U256 = (*nonce_written_value.unwrap()).into();
assert_eq!(
nonce_written_value.checked_sub(nonce_read_value),
Some(U256::from(1))
Expand Down