Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Use alloy instead of primitive-types and ethereum-types #78

Merged
merged 13 commits into from
May 28, 2024
1,429 changes: 1,254 additions & 175 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ tokio = { version = "1.33.0", features = ["full"] }
serde = "1.0.183"
serde_path_to_error = "0.1.14"
serde_json = "1.0.107"
ethereum-types = "0.14.1"
thiserror = "1.0.50"
futures = "0.3.29"
rlp = "0.5.2"
keccak-hash = "0.10.0"
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone happen to know why they haven't/aren't releasing this? It makes me slightly uncomfortable with unreleased code but I don't think we really have another option here. We've been looking at alloy in the agglayer too but haven't made the switch yet for this exact reason. But... I think we just bite the bullet here.

"rpc-types-eth",
"providers",
"transports",
"transport-http",
] }


# zk-evm dependencies
plonky2 = "0.2.2"
Expand Down
2 changes: 0 additions & 2 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ plonky2 = { workspace = true }
evm_arithmetization = { workspace = true }
clap = { workspace = true }
anyhow = { workspace = true }
trace_decoder = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
seahash = "4.1.0"
2 changes: 1 addition & 1 deletion leader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tokio = { workspace = true }
proof_gen = { workspace = true }
serde_json = { workspace = true }
serde_path_to_error = { workspace = true }
ethereum-types = { workspace = true }
alloy.workspace = true
axum = "0.7.4"
toml = "0.8.12"

Expand Down
2 changes: 1 addition & 1 deletion leader/src/http.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{net::SocketAddr, path::PathBuf, sync::Arc};

use alloy::primitives::U256;
use anyhow::{bail, Result};
use axum::{http::StatusCode, routing::post, Json, Router};
use ethereum_types::U256;
use paladin::runtime::Runtime;
use proof_gen::{proof_types::GeneratedBlockProof, types::PlonkyProofIntern};
use prover::ProverInput;
Expand Down
11 changes: 6 additions & 5 deletions leader/src/jerigon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{
path::PathBuf,
};

use alloy::providers::RootProvider;
use anyhow::Result;
use paladin::runtime::Runtime;
use proof_gen::types::PlonkyProofIntern;
Expand All @@ -18,11 +19,11 @@ pub(crate) async fn jerigon_main(
proof_output_path_opt: Option<PathBuf>,
save_inputs_on_error: bool,
) -> Result<()> {
let prover_input = rpc::fetch_prover_input(rpc::FetchProverInputRequest {
rpc_url,
block_number,
checkpoint_block_number,
})
let prover_input = rpc::prover_input(
RootProvider::new_http(rpc_url.parse()?),
block_number.into(),
checkpoint_block_number.into(),
)
.await?;

let proof = prover_input
Expand Down
3 changes: 0 additions & 3 deletions ops/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ paladin-core = { workspace = true }
serde = { workspace = true }
evm_arithmetization = { workspace = true }
proof_gen = { workspace = true }
trace_decoder = { workspace = true }
tracing = { workspace = true }
rlp = { workspace = true }
ethereum-types = { workspace = true }
keccak-hash = { workspace = true }

common = { path = "../common" }
Expand Down
9 changes: 5 additions & 4 deletions prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ proof_gen = { workspace = true }
trace_decoder = { workspace = true }
tracing = { workspace = true }
paladin-core = { workspace = true }
ethereum-types = { workspace = true }
anyhow = { workspace = true }
futures = { workspace = true }

# Local dependencies
alloy.workspace = true
ruint = { version = "1.12.1", features = ["num-traits", "primitive-types"] }
ops = { path = "../ops" }
common = { path = "../common" }
num-traits = "0.2.19"

[features]
default = []
test_only = ["ops/test_only"]
test_only = ["ops/test_only"]
12 changes: 9 additions & 3 deletions prover/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use alloy::primitives::U256;
use anyhow::Result;
use ethereum_types::U256;
#[cfg(feature = "test_only")]
use futures::stream::TryStreamExt;
use num_traits::ToPrimitive as _;
use ops::TxProof;
use paladin::{
directive::{Directive, IndexedStream},
Expand All @@ -27,7 +28,7 @@ fn resolve_code_hash_fn(_: &CodeHash) -> Vec<u8> {

impl ProverInput {
pub fn get_block_number(&self) -> U256 {
self.other_data.b_data.b_meta.block_number
self.other_data.b_data.b_meta.block_number.into()
}

#[cfg(not(feature = "test_only"))]
Expand All @@ -37,6 +38,8 @@ impl ProverInput {
previous: Option<PlonkyProofIntern>,
save_inputs_on_error: bool,
) -> Result<GeneratedBlockProof> {
use anyhow::Context as _;
0xaatif marked this conversation as resolved.
Show resolved Hide resolved

let block_number = self.get_block_number();
info!("Proving block {block_number}");

Expand All @@ -57,8 +60,11 @@ impl ProverInput {
.await?;

if let proof_gen::proof_types::AggregatableProof::Agg(proof) = agg_proof {
let block_number = block_number
.to_u64()
.context("block number overflows u64")?;
let prev = previous.map(|p| GeneratedBlockProof {
b_height: block_number.as_u64() - 1,
b_height: block_number - 1,
intern: p,
});

Expand Down
14 changes: 4 additions & 10 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@ anyhow = { workspace = true }
serde = { workspace = true }
trace_decoder = { workspace = true }
serde_json = { workspace = true }
serde_path_to_error = { workspace = true }
clap = { workspace = true }
ethereum-types = { workspace = true }
evm_arithmetization = { workspace = true }
thiserror = { workspace = true }
alloy.workspace = true
futures = { workspace = true }

hex = "0.4.3"
hex-literal = "0.4.1"
reqwest = { version = "0.11.22", default-features = false, features = [
"json",
"rustls-tls",
] }


# Local dependencies
itertools = "0.13.0"
url = "2.5.0"
common = { path = "../common" }
prover = { path = "../prover" }
__compat_primitive-types = { version = "0.12.2", package = "primitive-types" }
23 changes: 0 additions & 23 deletions rpc/src/cli.rs

This file was deleted.

11 changes: 0 additions & 11 deletions rpc/src/init.rs

This file was deleted.

Loading
Loading