Skip to content

Commit

Permalink
Remove self destructs from the native tracer (#461)
Browse files Browse the repository at this point in the history
* [WIP] debugging block 20000275

* Ignore selfdestructs

* Remove hacky fix

* Clean code

* Fix fmt
  • Loading branch information
4l0n50 authored Aug 6, 2024
1 parent 98c2654 commit f6a3386
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 55 deletions.
28 changes: 0 additions & 28 deletions trace_decoder/src/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,34 +538,6 @@ impl ProcessedBlockTrace {
.map_err(TraceParsingError::from)?;
}

// Remove any accounts that self-destructed.
for hashed_addr in deltas.self_destructed_accounts.iter() {
let k = Nibbles::from_h256_be(*hashed_addr);

trie_state.storage.remove(hashed_addr).ok_or_else(|| {
let hashed_addr = *hashed_addr;
let mut e = TraceParsingError::new(
TraceParsingErrorReason::MissingAccountStorageTrie(hashed_addr),
);
e.h_addr(hashed_addr);
e
})?;

// TODO: Once the mechanism for resolving code hashes settles, we probably want
// to also delete the code hash mapping here as well...

if let Some(remaining_account_key) =
Self::delete_node_and_report_remaining_key_if_branch_collapsed(
&mut trie_state.state,
&k,
)
.map_err(TraceParsingError::from)?
{
out.additional_state_trie_paths_to_not_hash
.push(remaining_account_key);
}
}

Ok(out)
}

Expand Down
5 changes: 0 additions & 5 deletions trace_decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,6 @@ pub struct TxnTrace {
/// Contract code that this account has accessed or created
#[serde(skip_serializing_if = "Option::is_none")]
pub code_usage: Option<ContractCodeUsage>,

/// True if the account existed before this txn but self-destructed at the
/// end of this txn.
#[serde(skip_serializing_if = "Option::is_none")]
pub self_destructed: Option<bool>,
}

/// Contract code access type. Used by txn traces.
Expand Down
8 changes: 0 additions & 8 deletions trace_decoder/src/processed_block_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,6 @@ impl TxnInfo {
}
}
}

if trace
.self_destructed
.map_or(false, |self_destructed| self_destructed)
{
nodes_used_by_txn.self_destructed_accounts.push(hashed_addr);
}
}

for &hashed_addr in extra_state_accesses {
Expand Down Expand Up @@ -225,7 +218,6 @@ pub(crate) struct NodesUsedByTxn {
pub(crate) storage_accesses: Vec<(H256, StorageAccess)>,
pub(crate) storage_writes: Vec<(H256, StorageWrite)>,
pub(crate) state_accounts_with_no_accesses_but_storage_tries: HashMap<H256, H256>,
pub(crate) self_destructed_accounts: Vec<H256>,
}

#[derive(Debug)]
Expand Down
14 changes: 0 additions & 14 deletions zero_bin/rpc/src/native/txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,13 @@ async fn process_tx_traces(
);
let code = process_code(post_state, read_state, &mut code_db).await;
let nonce = process_nonce(post_state, &code);
let self_destructed = process_self_destruct(post_state, pre_state);

let result = TxnTrace {
balance,
nonce,
storage_read,
storage_written,
code_usage: code,
self_destructed,
};

traces.insert(address, result);
Expand Down Expand Up @@ -277,18 +275,6 @@ async fn process_code(
}
}

/// Processes the self destruct for the given account state.
const fn process_self_destruct(
post_state: Option<&AccountState>,
pre_state: Option<&AccountState>,
) -> Option<bool> {
if post_state.is_none() && pre_state.is_some() {
Some(true)
} else {
None
}
}

mod rlp {
use alloy::consensus::{Receipt, ReceiptEnvelope};
use alloy::rpc::types::eth::ReceiptWithBloom;
Expand Down

0 comments on commit f6a3386

Please sign in to comment.