Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(prover): remove BlockTrace wrapper in geth_client.rs to make it more flexible for circuits #1376

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions prover/src/geth_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,11 @@ use anyhow::Result;
use ethers_core::types::BlockNumber;
use tokio::runtime::Runtime;

use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{de::DeserializeOwned, Serialize};
use std::fmt::Debug;

use ethers_providers::{Http, Provider};

// ======================= types ============================

/// L2 block full trace which tracks to the version in golang.
///
/// The inner block_trace is a generic type, whose real implementation
/// lies in two version's zkevm-circuits library.
///
/// The inner block_trace missed some fields compared to the go version.
/// These fields are defined here for clarity although not used.
#[derive(Deserialize, Serialize, Default, Debug, Clone)]
pub struct BlockTrace<T> {
#[serde(flatten)]
pub block_trace: T,

pub version: String,

pub withdraw_trie_root: Option<CommonHash>,

#[serde(rename = "mptwitness", default)]
pub mpt_witness: Vec<u8>,
}

// ======================= geth client ============================

pub struct GethClient {
id: String,
provider: Provider<Http>,
Expand All @@ -52,7 +28,7 @@ impl GethClient {
})
}

pub fn get_block_trace_by_hash<T>(&mut self, hash: &CommonHash) -> Result<BlockTrace<T>>
pub fn get_block_trace_by_hash<T>(&mut self, hash: &CommonHash) -> Result<T>
where
T: Serialize + DeserializeOwned + Debug + Send,
{
Expand Down
2 changes: 1 addition & 1 deletion prover/src/zk_circuits_handler/bernoulli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl BaseCircuitsHandler {
.unwrap()
.borrow_mut()
.get_block_trace_by_hash(hash)?;
block_traces.push(trace.block_trace);
block_traces.push(trace);
}

block_traces.sort_by(|a, b| {
Expand Down
2 changes: 1 addition & 1 deletion prover/src/zk_circuits_handler/curie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl NextCircuitsHandler {
.unwrap()
.borrow_mut()
.get_block_trace_by_hash(hash)?;
block_traces.push(trace.block_trace);
block_traces.push(trace);
}

block_traces.sort_by(|a, b| {
Expand Down
Loading