Skip to content

Commit

Permalink
refactor: frontend of trace_decoder (#309)
Browse files Browse the repository at this point in the history
* mark: 0xaatif/trace-decoder-rewrite

* run: rm -r trace_decoder/src/

* run: git checkout 0xaatif/type-2-witness -- trace_decoder/src/

* build: add required deps

* run: cargo autoinherit

* chore: sort and trim deps

* chore: update benches

* chore: update zero-bin

* run: mv zero_bin/.cargo/config.toml .cargo/config.toml

* fix: feature gated code

* fix: clippy

* review: nits

* chore: track smt_trie upstreaming

* chore: trace script

* fix: accept different header tokens

* test: port other testing logic

* chore: mark generated files

* refactor: make decode_key less quirky

* fix: eth_getWitness returns 0x-prefixed strings

* fix: broken build

* review: change BUG to BUG(spec), change wording

* refactor: zero_jerigon -> type1, hermez_cdk_erigon -> type2

* review: docs from @atanmarko

* fix: broken intra-doc links
  • Loading branch information
0xaatif authored Jul 10, 2024
1 parent 43a984d commit 715a905
Show file tree
Hide file tree
Showing 34 changed files with 1,930 additions and 3,211 deletions.
510 changes: 197 additions & 313 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ keywords = ["cryptography", "STARK", "plonky2", "ethereum", "zk"]
categories = ["cryptography::cryptocurrencies"]

[workspace.dependencies]
__compat_primitive_types = { version = "0.12.2", package = "primitive-types" }
alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-features = false, features = [
"consensus",
"reqwest",
Expand All @@ -43,19 +44,21 @@ alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-fea
anyhow = "1.0.86"
async-stream = "0.3.5"
axum = "0.7.5"
bitflags = "2.5.0"
bitvec = "1.0.1"
bytes = "1.6.0"
ciborium = "0.2.2"
ciborium-io = "0.2.2"
clap = { version = "4.5.7", features = ["derive", "env"] }
compat = { path = "compat" }
__compat_primitive_types = { version = "0.12.2", package = "primitive-types" }
criterion = "0.5.1"
dotenvy = "0.15.7"
either = "1.12.0"
enum-as-inner = "0.6.0"
enumn = "0.1.13"
env_logger = "0.11.3"
ethereum-types = "0.14.1"
eth_trie = "0.4.0"
ethereum-types = "0.14.1"
evm_arithmetization = { path = "evm_arithmetization", version = "0.2.0" }
futures = "0.3.30"
hashbrown = "0.14.5"
Expand All @@ -68,10 +71,12 @@ impl-serde = "0.4.0"
itertools = "0.13.0"
keccak-hash = "0.10.0"
log = "0.4.21"
lru = "0.12.3"
mpt_trie = { path = "mpt_trie", version = "0.3.0" }
num = "0.4.3"
num-bigint = "0.4.5"
num-traits = "0.2.19"
nunny = "0.2.1"
once_cell = "1.19.0"
paladin-core = "0.4.2"
parking_lot = "0.12.3"
Expand All @@ -90,8 +95,8 @@ serde = "1.0.203"
serde_json = "1.0.118"
serde_path_to_error = "0.1.16"
serde_with = "3.8.1"
smt_trie = { path = "smt_trie", version = "0.1.0" }
sha2 = "0.10.8"
smt_trie = { path = "smt_trie", version = "0.1.0" }
static_assertions = "1.1.0"
thiserror = "1.0.61"
tiny-keccak = "2.0.2"
Expand All @@ -101,9 +106,10 @@ tower = "0.4"
trace_decoder = { path = "trace_decoder", version = "0.4.0" }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
u4 = "0.1.0"
uint = "0.9.5"
url = "2.5.2"
lru = "0.12.3"
winnow = "0.6.13"

# zero-bin related dependencies
ops = { path = "zero_bin/ops" }
Expand Down
26 changes: 17 additions & 9 deletions trace_decoder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "trace_decoder"
description = "Processes trace payloads into Intermediate Representation (IR) format."
authors = ["Polygon Zero <bgluth@polygon.technology>"]
description = "Ethereum node witness -> Prover input"
authors = ["Polygon Zero"]
version = "0.4.0"
edition.workspace = true
license.workspace = true
Expand All @@ -10,25 +10,33 @@ homepage.workspace = true
keywords.workspace = true

[dependencies]
anyhow.workspace = true
bitflags = { workspace = true }
bitvec = { workspace = true }
bytes = { workspace = true }
ciborium = { workspace = true }
ciborium-io = { workspace = true }
either = { workspace = true }
enum-as-inner = { workspace = true }
enumn = { workspace = true }
ethereum-types = { workspace = true }
evm_arithmetization = { workspace = true }
hex = { workspace = true }
hex-literal = { workspace = true }
itertools.workspace = true
keccak-hash = { workspace = true }
log = { workspace = true }
mpt_trie = { workspace = true }
nunny = { workspace = true, features = ["serde"] }
plonky2 = { workspace = true }
rlp = { workspace = true }
serde = { workspace = true }
serde_with = { workspace = true }
smt_trie = { workspace = true }
thiserror = { workspace = true }

# Local dependencies
mpt_trie = { workspace = true }
evm_arithmetization = { workspace = true }
u4 = { workspace = true }
winnow = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }
pretty_env_logger = { workspace = true }
serde_json = { workspace = true }

[[bench]]
Expand Down
29 changes: 0 additions & 29 deletions trace_decoder/README.md

This file was deleted.

30 changes: 10 additions & 20 deletions trace_decoder/benches/block_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,27 @@
//! (<https://etherscan.io/block/19240650>) containing 201 transactions and 16 withdrawals.

use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use serde::{Deserialize, Serialize};
use trace_decoder::{
processed_block_trace::ProcessingMeta,
trace_protocol::BlockTrace,
types::{CodeHash, OtherBlockData},
};
use trace_decoder::{BlockTrace, OtherBlockData};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, serde::Deserialize)]
pub struct ProverInput {
pub block_trace: BlockTrace,
pub other_data: OtherBlockData,
}

fn resolve_code_hash_fn(_: &CodeHash) -> Vec<u8> {
todo!()
}

fn criterion_benchmark(c: &mut Criterion) {
let bytes = std::fs::read("benches/block_input.json").unwrap();
let prover_input: ProverInput = serde_json::from_slice(&bytes).unwrap();
let prover_input =
serde_json::from_slice::<ProverInput>(include_bytes!("block_input.json").as_slice())
.unwrap();

c.bench_function("Block 19240650 processing", |b| {
b.iter_batched(
|| prover_input.clone(),
|pi| {
pi.block_trace
.into_txn_proof_gen_ir(
&ProcessingMeta::new(resolve_code_hash_fn),
prover_input.other_data.clone(),
)
.unwrap()
|ProverInput {
block_trace,
other_data,
}| {
trace_decoder::entrypoint(block_trace, other_data, |_| unimplemented!()).unwrap()
},
BatchSize::LargeInput,
)
Expand Down
28 changes: 0 additions & 28 deletions trace_decoder/src/compact/compact_debug_tools.rs

This file was deleted.

Loading

0 comments on commit 715a905

Please sign in to comment.