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(eigen-client-m0): Extract EigenDA client #373

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f6422cd
feat(state-keeper): mempool io opens batch if there is protocol upgra…
perekopskiy Dec 9, 2024
003316e
fix: Fixed cargo deny (#3372)
brunoffranca Dec 11, 2024
51958f6
docs: interop docs update (#3366)
kelemeno Dec 11, 2024
5d77727
fix(tracer): adds vm error to flatCallTracer error field if exists (#…
dutterbutter Dec 11, 2024
503956d
chore(main): release core 25.3.0 (#3313)
zksync-era-bot Dec 11, 2024
fe8f68c
feat(eigen-client-extra-features): Fix PR comments (#369)
gianbelinche Dec 11, 2024
64a08bc
Merge branch 'main' into eigen-client-extra-features
gianbelinche Dec 11, 2024
8395cca
Cargo lock conflicts
gianbelinche Dec 11, 2024
f2d7941
Merge pull request #370 from lambdaclass/eigen-client-extra-main-merged
gianbelinche Dec 11, 2024
291ac85
Merge branch 'eigen-client-extra-features' into eigen-client-m0-imple…
juan518munoz Dec 11, 2024
452fc6c
remove concurrent dispatcher leftovers
juan518munoz Dec 11, 2024
4b3c059
Solve comments (#372)
gianbelinche Dec 12, 2024
5a9c282
Remove eigen client for external crate
gianbelinche Dec 12, 2024
798cf45
Add real repo
gianbelinche Dec 12, 2024
c4b5b0b
Merge branch 'eigen-client-extra-features' into eigen-client-m0-imple…
juan518munoz Dec 13, 2024
4af1a20
remove METRICS var
juan518munoz Dec 13, 2024
051c661
Merge branch 'eigen-client-m0-implementation-merge-extra-features' in…
gianbelinche Dec 13, 2024
7bef5b3
Change proxy name and remove generic
gianbelinche Dec 13, 2024
93b94b2
feat(eigen-client-extra-features): address PR comments (#375)
gianbelinche Dec 19, 2024
2ddb512
Merge branch 'eigen-client-extra-features' into eigen-client-m0-imple…
juan518munoz Dec 19, 2024
9213660
Merge branch 'eigen-client-m0-implementation-merge-extra-features' in…
gianbelinche Dec 19, 2024
4a997fc
Fix compilation
gianbelinche Dec 19, 2024
e81d4d0
Update branch
gianbelinche Jan 3, 2025
fd63400
Merge branch 'eigen-client-m0-implementation' into eigen-client-m0-ex…
gianbelinche Jan 3, 2025
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
1,874 changes: 1,081 additions & 793 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ tonic = { version = "0.11.0", default-features = false }
pbjson-types = "0.6.0"

# Eigen
tokio-stream = "0.1.16"
rust-kzg-bn254 = "0.2.1"
ark-bn254 = "0.5.0"
num-bigint = "0.4.6"
serial_test = "3.1.1"
eigenda-client-rs = {git = "https://github.com/lambdaclass/eigenda-client-rs", branch = "client-implementation", package = "eigen-client"}

# Here and below:
# We *always* pin the latest version of protocol to disallow accidental changes in the execution logic.
Expand Down
16 changes: 2 additions & 14 deletions core/node/da_clients/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,5 @@ tonic = { workspace = true, features = ["tls-roots", "prost", "codegen"] }
pbjson-types.workspace = true

# Eigen dependencies
tokio-stream.workspace = true
rand.workspace = true
sha3.workspace = true
tiny-keccak.workspace = true
ethabi.workspace = true
rust-kzg-bn254.workspace = true
ark-bn254.workspace = true
num-bigint.workspace = true
zksync_web3_decl.workspace = true
zksync_eth_client.workspace = true
url.workspace = true

[dev-dependencies]
serial_test.workspace = true
eigenda-client-rs.workspace = true
zksync_dal.workspace = true
168 changes: 0 additions & 168 deletions core/node/da_clients/src/eigen/blob_info.rs

This file was deleted.

81 changes: 55 additions & 26 deletions core/node/da_clients/src/eigen/client.rs
Original file line number Diff line number Diff line change
@@ -1,48 +1,77 @@
use std::{str::FromStr, sync::Arc};
use std::{error::Error, str::FromStr};

use async_trait::async_trait;
use secp256k1::SecretKey;
use eigenda_client_rs::{client::GetBlobData, EigenClient};
use subxt_signer::ExposeSecret;
use zksync_config::{configs::da_client::eigen::EigenSecrets, EigenConfig};
use zksync_da_client::{
types::{DAError, DispatchResponse, InclusionData},
DataAvailabilityClient,
};
use zksync_dal::{ConnectionPool, Core, CoreDal};

use super::sdk::RawEigenClient;
use crate::utils::to_retriable_da_error;

#[async_trait]
pub trait GetBlobData: std::fmt::Debug + Send + Sync {
async fn get_blob_data(&self, input: &str) -> anyhow::Result<Option<Vec<u8>>>;

fn clone_boxed(&self) -> Box<dyn GetBlobData>;
}

/// EigenClient is a client for the Eigen DA service.
// We can't implement DataAvailabilityClient for an outside struct, so it is needed to defined this intermediate struct
#[derive(Debug, Clone)]
pub struct EigenClient {
pub(crate) client: Arc<RawEigenClient>,
pub struct EigenDAClient {
client: EigenClient,
}

impl EigenClient {
impl EigenDAClient {
pub async fn new(
config: EigenConfig,
secrets: EigenSecrets,
get_blob_data: Box<dyn GetBlobData>,
pool: ConnectionPool<Core>,
) -> anyhow::Result<Self> {
let private_key = SecretKey::from_str(secrets.private_key.0.expose_secret().as_str())
.map_err(|e| anyhow::anyhow!("Failed to parse private key: {}", e))?;
let eigen_config = eigenda_client_rs::config::EigenConfig {
disperser_rpc: config.disperser_rpc,
settlement_layer_confirmation_depth: config.settlement_layer_confirmation_depth,
eigenda_eth_rpc: config.eigenda_eth_rpc.ok_or(anyhow::anyhow!(
"eigenda_eth_rpc is required for EigenClient"
))?,
eigenda_svc_manager_address: config.eigenda_svc_manager_address,
wait_for_finalization: config.wait_for_finalization,
authenticated: config.authenticated,
g1_url: config.g1_url,
g2_url: config.g2_url,
};
let private_key =
eigenda_client_rs::config::PrivateKey::from_str(secrets.private_key.0.expose_secret())
.map_err(|_| anyhow::anyhow!("Invalid private key"))?;
let eigen_secrets = eigenda_client_rs::config::EigenSecrets { private_key };
let get_blob_data = GetBlobFromDB { pool };
let client = EigenClient::new(eigen_config, eigen_secrets, Box::new(get_blob_data))
.await
.map_err(|e| anyhow::anyhow!("Eigen client Error: {:?}", e))?;
Ok(Self { client })
}
}

let client = RawEigenClient::new(private_key, config, get_blob_data).await?;
Ok(Self {
client: Arc::new(client),
})
#[derive(Debug, Clone)]
pub struct GetBlobFromDB {
pool: ConnectionPool<Core>,
}

#[async_trait::async_trait]
impl GetBlobData for GetBlobFromDB {
async fn get_blob_data(
&self,
input: &str,
) -> Result<Option<Vec<u8>>, Box<dyn Error + Send + Sync>> {
let mut conn = self.pool.connection_tagged("eigen_client").await?;
let batch = conn
.data_availability_dal()
.get_blob_data_by_blob_id(input)
.await?;
Ok(batch.map(|b| b.pubdata))
}

fn clone_boxed(&self) -> Box<dyn GetBlobData> {
Box::new(self.clone())
}
}

#[async_trait]
impl DataAvailabilityClient for EigenClient {
#[async_trait::async_trait]
impl DataAvailabilityClient for EigenDAClient {
async fn dispatch_blob(
&self,
_: u32, // batch number
Expand Down Expand Up @@ -77,6 +106,6 @@ impl DataAvailabilityClient for EigenClient {
}

fn blob_size_limit(&self) -> Option<usize> {
Some(RawEigenClient::blob_size_limit())
self.client.blob_size_limit()
}
}
Loading
Loading