Skip to content

Commit

Permalink
Move world into evm_arithmetization
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Nov 6, 2024
1 parent b49b14f commit d4dd2aa
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 934 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ bytes = "1.6.0"
ciborium = "0.2.2"
ciborium-io = "0.2.2"
clap = { version = "4.5.7", features = ["derive", "env"] }
compat = { path = "compat" }
alloy-compat = "0.1.0"
copyvec = "0.2.0"
criterion = "0.5.1"
dotenvy = "0.15.7"
either = "1.12.0"
Expand Down Expand Up @@ -104,6 +105,7 @@ url = "2.5.2"
winnow = "0.6.13"

# local dependencies
compat = { path = "compat" }
evm_arithmetization = { path = "evm_arithmetization", version = "0.4.0", default-features = false }
mpt_trie = { path = "mpt_trie", version = "0.4.1" }
smt_trie = { path = "smt_trie", version = "0.1.1" }
Expand Down
11 changes: 9 additions & 2 deletions evm_arithmetization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ homepage.workspace = true
keywords.workspace = true

[dependencies]
__compat_primitive_types.workspace = true # TODO(#229)
alloy.workspace = true
alloy-compat.workspace = true
anyhow.workspace = true
bitvec.workspace = true
bytes.workspace = true
copyvec.workspace = true
either.workspace = true
env_logger.workspace = true
ethereum-types.workspace = true
hashbrown.workspace = true
Expand All @@ -43,14 +49,15 @@ serde = { workspace = true, features = ["derive"] }
serde-big-array.workspace = true
serde_json.workspace = true
sha2.workspace = true
smt_trie = { workspace = true, optional = true }
smt_trie = { workspace = true }
starky = { workspace = true, features = ["parallel"] }
static_assertions.workspace = true
thiserror.workspace = true
tiny-keccak.workspace = true
tokio.workspace = true
tower-lsp = "0.20.0"
tracing.workspace = true
u4.workspace = true
url.workspace = true
zk_evm_common.workspace = true
zk_evm_proc_macro.workspace = true
Expand All @@ -64,7 +71,7 @@ ripemd.workspace = true
default = ["eth_mainnet"]
asmtools = ["hex"]
polygon_pos = []
cdk_erigon = ["smt_trie"]
cdk_erigon = []
eth_mainnet = []

[[bin]]
Expand Down
2 changes: 2 additions & 0 deletions evm_arithmetization/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ pub mod witness;
pub mod curve_pairings;
pub mod extension_tower;
pub mod testing_utils;
pub mod tries;
pub mod util;
pub mod world;

// Public definitions and re-exports
mod public_types;
Expand Down
6 changes: 3 additions & 3 deletions trace_decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ keywords.workspace = true

[dependencies]
alloy.workspace = true
alloy-compat = "0.1.0"
alloy-compat.workspace = true
anyhow.workspace = true
bitflags.workspace = true
bitvec.workspace = true
bytes.workspace = true
ciborium.workspace = true
ciborium-io.workspace = true
copyvec = "0.2.0"
copyvec.workspace = true
either.workspace = true
enum-as-inner.workspace = true
ethereum-types.workspace = true
Expand All @@ -43,7 +43,7 @@ zk_evm_common.workspace = true

[dev-dependencies]
alloy.workspace = true
alloy-compat = "0.1.0"
alloy-compat.workspace = true
assert2 = "0.3.15"
camino = "1.1.9"
clap.workspace = true
Expand Down
10 changes: 3 additions & 7 deletions trace_decoder/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use ethereum_types::{Address, BigEndianHash as _, U256};
use evm_arithmetization::{
generation::TrieInputs,
proof::{BlockMetadata, TrieRoots},
tries::{MptKey, ReceiptTrie, StateMpt, StorageTrie, TransactionTrie},
world::{Hasher, KeccakHash, PoseidonHash, Type1World, Type2World, World},
GenerationInputs,
};
use itertools::Itertools as _;
Expand All @@ -19,14 +21,8 @@ use mpt_trie::partial_trie::PartialTrie as _;
use nunny::NonEmpty;
use zk_evm_common::gwei_to_wei;

use crate::observer::{DummyObserver, Observer};
use crate::{
observer::{DummyObserver, Observer},
world::Type2World,
Hasher, KeccakHash, PoseidonHash,
};
use crate::{
tries::{MptKey, ReceiptTrie, StateMpt, StorageTrie, TransactionTrie},
world::{Type1World, World},
BlockLevelData, BlockTrace, BlockTraceTriePreImages, CombinedPreImages, ContractCodeUsage,
OtherBlockData, SeparateStorageTriesPreImage, SeparateTriePreImage, SeparateTriePreImages,
TxnInfo, TxnMeta, TxnTrace,
Expand Down
25 changes: 0 additions & 25 deletions trace_decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,10 @@ const _DEVELOPER_DOCS: () = ();
mod interface;

pub use interface::*;
use keccak_hash::H256;
use smt_trie::code::hash_bytecode_h256;

mod tries;
mod type1;
mod type2;
mod wire;
mod world;

pub use core::{entrypoint, WireDisposition};

Expand Down Expand Up @@ -103,27 +99,6 @@ mod hex {
}
}

/// Utility trait to leverage a specific hash function across Type1 and Type2
/// zkEVM variants.
pub(crate) trait Hasher {
fn hash(bytes: &[u8]) -> H256;
}

pub(crate) struct PoseidonHash;
pub(crate) struct KeccakHash;

impl Hasher for PoseidonHash {
fn hash(bytes: &[u8]) -> H256 {
hash_bytecode_h256(bytes)
}
}

impl Hasher for KeccakHash {
fn hash(bytes: &[u8]) -> H256 {
keccak_hash::keccak(bytes)
}
}

#[cfg(test)]
#[derive(serde::Deserialize)]
struct Case {
Expand Down
2 changes: 1 addition & 1 deletion trace_decoder/src/observer.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::marker::PhantomData;

use ethereum_types::U256;
use evm_arithmetization::tries::{ReceiptTrie, TransactionTrie};

use crate::core::IntraBlockTries;
use crate::tries::{ReceiptTrie, TransactionTrie};

/// Observer API for the trace decoder.
/// Observer is used to collect various debugging and metadata info
Expand Down
Loading

0 comments on commit d4dd2aa

Please sign in to comment.