diff --git a/trace_decoder/Cargo.toml b/trace_decoder/Cargo.toml index bcb980852..b56d229e6 100644 --- a/trace_decoder/Cargo.toml +++ b/trace_decoder/Cargo.toml @@ -77,3 +77,7 @@ harness = false [[test]] name = "simulate-execution" harness = false + +[[test]] +name = "check-subsets" +harness = false diff --git a/trace_decoder/src/lib.rs b/trace_decoder/src/lib.rs index 88636d877..4a0bdf7b4 100644 --- a/trace_decoder/src/lib.rs +++ b/trace_decoder/src/lib.rs @@ -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 diff --git a/trace_decoder/tests/check-subsets.rs b/trace_decoder/tests/check-subsets.rs new file mode 100644 index 000000000..a9dc4b690 --- /dev/null +++ b/trace_decoder/tests/check-subsets.rs @@ -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::>(); + 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(()) +}