Skip to content

Commit

Permalink
Re-added feature gating
Browse files Browse the repository at this point in the history
  • Loading branch information
BGluth committed May 17, 2024
1 parent 5be6461 commit ca907ac
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ hex-literal = "0.4.1"
keccak-hash = "0.10.0"
log = "0.4.20"
num = "0.4.1"
paste = "1.0.15"
rand = "0.8.5"
rlp = "0.5.2"
rlp-derive = "0.1.0"
Expand Down
2 changes: 1 addition & 1 deletion proof_gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords.workspace = true
[dependencies]
ethereum-types = { workspace = true }
log = { workspace = true }
paste = "1.0.14"
paste = { workspace = true }
plonky2 = { workspace = true }
serde = { workspace = true }

Expand Down
10 changes: 8 additions & 2 deletions trace_decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ keywords.workspace = true
bytes = { workspace = true }
ciborium = "0.2.1"
ciborium-io = "0.2.1"
cfg-if = "1.0.0"
enum-as-inner = { workspace = true }
enumn = "0.1.12"
ethereum-types = { workspace = true }
Expand All @@ -25,14 +26,19 @@ rlp = { workspace = true }
rlp-derive = { workspace = true }
serde = { workspace = true }
serde_with = "3.4.0"
supertrait = "0.1.0"
thiserror = { workspace = true }

# Local dependencies
mpt_trie = { version = "0.2.1", path = "../mpt_trie" }
smt_trie = { git = "https://github.com/0xPolygonZero/zk_evm", branch = "smt_insert_hash" }

evm_arithmetization_mpt = { package = "evm_arithmetization", version = "0.1.3", path = "../evm_arithmetization" }
evm_arithmetization_smt = { package = "evm_arithmetization", version = "0.1.2", git = "https://github.com/0xPolygonZero/zk_evm.git", branch = "feat_type2_hack" }
evm_arithmetization_mpt = { package = "evm_arithmetization", version = "0.1.3", path = "../evm_arithmetization", optional = true }
evm_arithmetization_smt = { package = "evm_arithmetization", version = "0.1.2", git = "https://github.com/0xPolygonZero/zk_evm.git", branch = "feat_type2_hack", optional = true }

[dev-dependencies]
pretty_env_logger = "0.5.0"

[features]
mpt = ["evm_arithmetization_mpt"]
smt = ["evm_arithmetization_smt"]
55 changes: 21 additions & 34 deletions trace_decoder/src/aliased_crate_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,33 @@
//!
//! Currently (this may change in the future), but SMT support is currently on
//! its own separate branch in `zk_evm`. We want to be able to support both
//! `MPT` (on the `main` branch) and SMT (on the `feat/type2` branch) in a
//! single binary. Because `feat/type2` modifies existing types that `main`
//! `MPT` (on the `main` branch) and SMT (on the `feat/type2` branch) using feature gating. Because `feat/type2` modifies existing types that `main`
//! uses, we can not just simply use imports from both branches at the same
//! time. Instead, we need to make each version of the packages their own
//! separate dependency. This module just aliases the types to make them a bit
//! more readable, while also making it easier to merge the libraries together
//! later if the `feat/type2` eventually gets merged back into main.
macro_rules! create_aliased_type {
($alias_name:ident, $path:path) => {
pub(crate) type $alias_name = $path;
use cfg_if::cfg_if;

macro_rules! include_feature_gated_zero_deps {
($crate_name:ident) => {
pub(crate) type AccountRlp = $crate_name::generation::mpt::AccountRlp;
pub(crate) type BlockHashes = $crate_name::proof::BlockHashes;
pub(crate) type BlockMetadata = $crate_name::proof::BlockMetadata;
pub(crate) type ExtraBlockData = $crate_name::proof::ExtraBlockData;
pub(crate) type GenerationInputs = $crate_name::generation::GenerationInputs;
pub(crate) type LegacyReceiptRlp = $crate_name::generation::mpt::LegacyReceiptRlp;
pub(crate) type ProofGenIR = $crate_name::GenerationInputs;
pub(crate) type TrieInputs = $crate_name::generation::TrieInputs;
pub(crate) type TrieRoots = $crate_name::proof::TrieRoots;
};
}

// MPT imports
create_aliased_type!(
MptAccountRlp,
evm_arithmetization_mpt::generation::mpt::AccountRlp
);
create_aliased_type!(MptBlockHashes, evm_arithmetization_mpt::proof::BlockHashes);
create_aliased_type!(
MptBlockMetadata,
evm_arithmetization_mpt::proof::BlockMetadata
);
create_aliased_type!(
MptExtraBlockData,
evm_arithmetization_mpt::proof::ExtraBlockData
);
create_aliased_type!(
MptGenerationInputs,
evm_arithmetization_mpt::generation::GenerationInputs
);
create_aliased_type!(
MptTrieInputs,
evm_arithmetization_mpt::generation::TrieInputs
);
create_aliased_type!(MptTrieRoots, evm_arithmetization_mpt::proof::TrieRoots);

// SMT imports
create_aliased_type!(
SmtGenerationInputs,
evm_arithmetization_smt::generation::GenerationInputs
);
cfg_if! {
if #[cfg(feature = "mpt")] {
include_feature_gated_zero_deps!(evm_arithmetization_mpt);
} else if #[cfg(feature = "smt")] {
include_feature_gated_zero_deps!(evm_arithmetization_smt);
}
}
6 changes: 6 additions & 0 deletions trace_decoder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]

#[cfg(not(any(feature = "mpt", feature = "smt")))]
compile_error! {"Either the \"mpt\" or \"smt\" feature (but not both) must be enabled"}

#[cfg(all(feature = "mpt", feature = "smt"))]
compile_error! {"The features \"mpt\" and \"smt\" are mutually exclusive and can not be enabled at the same time"}

mod aliased_crate_types;
/// Provides debugging tools and a compact representation of state and storage
/// tries, used in tests.
Expand Down

0 comments on commit ca907ac

Please sign in to comment.