Skip to content

Commit

Permalink
Fix address masking in trace_decoder processing (#639)
Browse files Browse the repository at this point in the history
* Fix address masking

* Add marking for non-failing accesses

* Make const
  • Loading branch information
Nashtare authored Sep 19, 2024
1 parent 6ef8827 commit a506472
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions trace_decoder/src/core.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ops::Range;
use std::{
cmp,
collections::{BTreeMap, BTreeSet, HashMap},
Expand Down Expand Up @@ -455,24 +456,25 @@ fn middle<StateTrieT: StateTrie + Clone>(
}

state_trie.insert_by_address(addr, acct)?;
state_mask.insert(TrieKey::from_address(addr));
} else {
// Simple state access
const PRECOMPILE_ADDRESSES: Range<alloy::primitives::Address> =
address!("0000000000000000000000000000000000000001")
..address!("000000000000000000000000000000000000000a");

if receipt.status || !PRECOMPILE_ADDRESSES.contains(&addr.compat()) {
// TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/pull/613
// masking like this SHOULD be a space-saving optimization,
// BUT if it's omitted, we actually get state root mismatches
state_mask.insert(TrieKey::from_address(addr));
}
}

if self_destructed {
storage_tries.remove(&keccak_hash::keccak(addr));
state_mask.extend(state_trie.reporting_remove(addr)?)
}

let precompiled_addresses = address!("0000000000000000000000000000000000000001")
..address!("000000000000000000000000000000000000000a");

if !precompiled_addresses.contains(&addr.compat()) {
// TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/pull/613
// masking like this SHOULD be a space-saving optimization,
// BUT if it's omitted, we actually get state root mismatches
state_mask.insert(TrieKey::from_address(addr));
} // else we don't even need to include them,
// because nodes will only emit a precompiled address if
// the transaction calling them reverted.
}

if do_increment_txn_ix {
Expand Down

0 comments on commit a506472

Please sign in to comment.