Skip to content

Commit

Permalink
migrate compat to micro crate (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
frisitano authored Jun 29, 2024
1 parent d81d683 commit 439b8c2
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 9 deletions.
11 changes: 10 additions & 1 deletion Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ members = ["mpt_trie",
"zero_bin/ops",
"zero_bin/verifier",
"zero_bin/rpc",
"zero_bin/prover"]
"zero_bin/prover",
"compat"]
resolver = "2"

[workspace.package]
Expand Down Expand Up @@ -44,6 +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" }
__compat_primitive_types = { version = "0.12.2", package = "primitive-types" }
criterion = "0.5.1"
dotenvy = "0.15.7"
enum-as-inner = "0.6.0"
Expand Down
14 changes: 14 additions & 0 deletions compat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "compat"
version = "0.1.0"
publish = false # TODO(<owner>): https://github.com/0xPolygonZero/zk_evm/issues/314 find a better place for this
edition.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies]
alloy = {workspace = true }
__compat_primitive_types = { workspace = true }
2 changes: 2 additions & 0 deletions zero_bin/rpc/src/compat.rs → compat/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// A trait to convert between alloy and ethereum types.
pub trait Compat<Out> {
/// Convert the type to another type
fn compat(self) -> Out;
}

Expand Down
5 changes: 3 additions & 2 deletions zero_bin/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ mpt_trie = { workspace = true }
alloy.workspace = true
futures = { workspace = true }
url = { workspace = true }
__compat_primitive_types = { version = "0.12.2", package = "primitive-types" }
__compat_primitive_types = { workspace = true }
tower = { workspace = true, features = ["retry"] }

# Local dependencies
zero_bin_common ={ workspace = true }
compat = { workspace = true }
zero_bin_common = { workspace = true }
prover = { workspace = true }

4 changes: 1 addition & 3 deletions zero_bin/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ use alloy::{
};
use anyhow::Context as _;
use clap::ValueEnum;
use compat::Compat;
use evm_arithmetization::proof::{BlockHashes, BlockMetadata};
use futures::{StreamExt as _, TryStreamExt as _};
use prover::ProverInput;
use trace_decoder::types::{BlockLevelData, OtherBlockData};
use zero_bin_common::block_interval::BlockInterval;

mod compat;
pub mod jerigon;
pub mod native;
pub mod retry;

use compat::Compat;

const PREVIOUS_HASHES_COUNT: usize = 256;

/// The RPC type.
Expand Down
2 changes: 1 addition & 1 deletion zero_bin/rpc/src/native/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use trace_decoder::trace_protocol::{
SeparateTriePreImages, TrieDirect, TxnInfo,
};

use crate::compat::Compat;
use crate::Compat;

/// Processes the state witness for the given block.
pub async fn process_state_witness<ProviderT, TransportT>(
Expand Down
2 changes: 1 addition & 1 deletion zero_bin/rpc/src/native/txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use futures::stream::{FuturesOrdered, TryStreamExt};
use trace_decoder::trace_protocol::{ContractCodeUsage, TxnInfo, TxnMeta, TxnTrace};

use super::CodeDb;
use crate::compat::Compat;
use crate::Compat;

/// Processes the transactions in the given block and updates the code db.
pub(super) async fn process_transactions<ProviderT, TransportT>(
Expand Down

0 comments on commit 439b8c2

Please sign in to comment.