Skip to content

Commit

Permalink
wip: check-subsets
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaatif committed Sep 9, 2024
1 parent befc4ba commit ba69d45
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions trace_decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ harness = false
[[test]]
name = "simulate-execution"
harness = false

[[test]]
name = "check-subsets"
harness = false
2 changes: 2 additions & 0 deletions trace_decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const _DEVELOPER_DOCS: () = ();
mod interface;

pub use interface::*;
pub use type1::frontend;
pub use wire::parse;

mod type1;
// TODO(0xaatif): https://github.com/0xPolygonZero/zk_evm/issues/275
Expand Down
33 changes: 33 additions & 0 deletions trace_decoder/tests/check-subsets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use common::{cases, Case};
use itertools::Itertools;
use mpt_trie::partial_trie::PartialTrie;
use trace_decoder::{BlockTraceTriePreImages, CombinedPreImages};

mod common;

fn main() -> anyhow::Result<()> {
for Case { name, trace, .. } in cases().unwrap() {
println!("{name}");
let BlockTraceTriePreImages::Combined(CombinedPreImages { compact }) =
trace.trie_pre_images
else {
panic!()
};
let whole = trace_decoder::frontend(trace_decoder::parse(&compact).unwrap())
.unwrap()
.state
.as_hashed_partial_trie()
.clone();
let all_keys = whole.keys().collect::<Vec<_>>();
let len = all_keys.len();
for n in 0..len {
println!("{n}/{len}");
for comb in all_keys.iter().copied().combinations(n) {
if let Ok(sub) = mpt_trie::trie_subsets::create_trie_subset(&whole, comb) {
assert_eq!(sub.hash(), whole.hash())
}
}
}
}
Ok(())
}

0 comments on commit ba69d45

Please sign in to comment.