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-extra-features): Add option to download points #361

Merged
merged 7 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 14 additions & 2 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
use serde::Deserialize;
use zksync_basic_types::secrets::PrivateKey;

#[derive(Clone, Debug, PartialEq, Deserialize)]
pub enum Points {
gianbelinche marked this conversation as resolved.
Show resolved Hide resolved
Path(String),
Link(String),
}

impl Default for Points {
fn default() -> Self {
Points::Path("".to_string())
}
}
/// Configuration for the EigenDA remote disperser client.
#[derive(Clone, Debug, PartialEq, Deserialize, Default)]
pub struct EigenConfig {
Expand All @@ -24,8 +36,8 @@ pub struct EigenConfig {
pub authenticated: bool,
/// Verify the certificate of dispatched blobs
pub verify_cert: bool,
/// Path to the file containing the points used for KZG
pub path_to_points: String,
/// Path or link to the file containing the points used for KZG
pub points: Points,
/// Chain ID of the Ethereum network
pub chain_id: u64,
}
Expand Down
53 changes: 40 additions & 13 deletions core/lib/env_config/src/da_client.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
use std::env;

use zksync_config::configs::{
da_client::{
avail::{
AvailClientConfig, AvailSecrets, AVAIL_FULL_CLIENT_NAME, AVAIL_GAS_RELAY_CLIENT_NAME,
use zksync_config::{
configs::{
da_client::{
avail::{
AvailClientConfig, AvailSecrets, AVAIL_FULL_CLIENT_NAME,
AVAIL_GAS_RELAY_CLIENT_NAME,
},
celestia::CelestiaSecrets,
eigen::EigenSecrets,
DAClientConfig, AVAIL_CLIENT_CONFIG_NAME, CELESTIA_CLIENT_CONFIG_NAME,
EIGEN_CLIENT_CONFIG_NAME, OBJECT_STORE_CLIENT_CONFIG_NAME,
},
celestia::CelestiaSecrets,
eigen::EigenSecrets,
DAClientConfig, AVAIL_CLIENT_CONFIG_NAME, CELESTIA_CLIENT_CONFIG_NAME,
EIGEN_CLIENT_CONFIG_NAME, OBJECT_STORE_CLIENT_CONFIG_NAME,
secrets::DataAvailabilitySecrets,
AvailConfig,
},
secrets::DataAvailabilitySecrets,
AvailConfig,
EigenConfig,
};

use crate::{envy_load, FromEnv};
Expand All @@ -34,7 +38,28 @@ impl FromEnv for DAClientConfig {
},
}),
CELESTIA_CLIENT_CONFIG_NAME => Self::Celestia(envy_load("da_celestia_config", "DA_")?),
EIGEN_CLIENT_CONFIG_NAME => Self::Eigen(envy_load("da_eigen_config", "DA_")?),
EIGEN_CLIENT_CONFIG_NAME => Self::Eigen(EigenConfig {
disperser_rpc: env::var("DA_DISPERSER_RPC")?,
eth_confirmation_depth: env::var("DA_ETH_CONFIRMATION_DEPTH")?.parse()?,
eigenda_eth_rpc: env::var("DA_EIGENDA_ETH_RPC")?,
eigenda_svc_manager_address: env::var("DA_EIGENDA_SVC_MANAGER_ADDRESS")?,
blob_size_limit: env::var("DA_BLOB_SIZE_LIMIT")?.parse()?,
status_query_timeout: env::var("DA_STATUS_QUERY_TIMEOUT")?.parse()?,
status_query_interval: env::var("DA_STATUS_QUERY_INTERVAL")?.parse()?,
wait_for_finalization: env::var("DA_WAIT_FOR_FINALIZATION")?.parse()?,
authenticated: env::var("DA_AUTHENTICATED")?.parse()?,
verify_cert: env::var("DA_VERIFY_CERT")?.parse()?,
points: match env::var("DA_POINTS")?.as_str() {
"Path" => zksync_config::configs::da_client::eigen::Points::Path(env::var(
"DA_POINTS_PATH",
)?),
"Link" => zksync_config::configs::da_client::eigen::Points::Link(env::var(
"DA_POINTS_LINK",
)?),
_ => anyhow::bail!("Unknown Eigen points type"),
},
chain_id: env::var("DA_CHAIN_ID")?.parse()?,
}),
OBJECT_STORE_CLIENT_CONFIG_NAME => {
Self::ObjectStore(envy_load("da_object_store", "DA_")?)
}
Expand Down Expand Up @@ -94,6 +119,7 @@ mod tests {
configs::{
da_client::{
avail::{AvailClientConfig, AvailDefaultConfig},
eigen::Points,
DAClientConfig::{self, ObjectStore},
},
object_store::ObjectStoreMode::GCS,
Expand Down Expand Up @@ -259,7 +285,8 @@ mod tests {
DA_WAIT_FOR_FINALIZATION=true
DA_AUTHENTICATED=false
DA_VERIFY_CERT=false
DA_PATH_TO_POINTS="resources"
DA_POINTS="Path"
DA_POINTS_PATH="resources"
DA_CHAIN_ID=1
"#;
lock.set_env(config);
Expand All @@ -278,7 +305,7 @@ mod tests {
wait_for_finalization: true,
authenticated: false,
verify_cert: false,
path_to_points: "resources".to_string(),
points: Points::Path("resources".to_string()),
chain_id: 1
})
);
Expand Down
32 changes: 27 additions & 5 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use zksync_config::configs::{
};
use zksync_protobuf::{required, ProtoRepr};

use crate::proto::{da_client as proto, object_store as object_store_proto};
use crate::proto::{
da_client::{self as proto, Link, Path},
object_store as object_store_proto,
};

impl ProtoRepr for proto::DataAvailabilityClient {
type Type = configs::DAClientConfig;
Expand Down Expand Up @@ -73,9 +76,17 @@ impl ProtoRepr for proto::DataAvailabilityClient {
.context("wait_for_finalization")?,
authenticated: *required(&conf.authenticated).context("authenticated")?,
verify_cert: *required(&conf.verify_cert).context("verify_cert")?,
path_to_points: required(&conf.path_to_points)
.context("path_to_points")?
.clone(),
points: match conf.points.clone() {
Some(proto::eigen_config::Points::Path(path)) => {
let path = required(&path.path).context("path")?;
zksync_config::configs::da_client::eigen::Points::Path(path.clone())
}
Some(proto::eigen_config::Points::Link(link)) => {
let link = required(&link.link).context("link")?;
zksync_config::configs::da_client::eigen::Points::Link(link.clone())
}
None => return Err(anyhow::anyhow!("Invalid Eigen DA configuration")),

Choose a reason for hiding this comment

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

why Anyhow instead of adding a proper error type?

Copy link
Author

Choose a reason for hiding this comment

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

That is how it is done for the other clients

},
chain_id: *required(&conf.chain_id).context("chain_id")?,
}),
proto::data_availability_client::Config::ObjectStore(conf) => {
Expand Down Expand Up @@ -125,7 +136,18 @@ impl ProtoRepr for proto::DataAvailabilityClient {
wait_for_finalization: Some(config.wait_for_finalization),
authenticated: Some(config.authenticated),
verify_cert: Some(config.verify_cert),
path_to_points: Some(config.path_to_points.clone()),
points: Some(match &config.points {
zksync_config::configs::da_client::eigen::Points::Path(path) => {
proto::eigen_config::Points::Path(Path {
path: Some(path.to_string()),
})
}
zksync_config::configs::da_client::eigen::Points::Link(link) => {
proto::eigen_config::Points::Link(Link {
link: Some(link.to_string()),
})
}
}),
chain_id: Some(config.chain_id),
}),
ObjectStore(config) => proto::data_availability_client::Config::ObjectStore(
Expand Down
15 changes: 13 additions & 2 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ message CelestiaConfig {
optional uint64 timeout_ms = 4;
}

message Path {
optional string path = 1;
}

message Link {
optional string link = 1;
}

message EigenConfig {
reserved 1,2;
optional string disperser_rpc = 3;
Expand All @@ -48,8 +56,11 @@ message EigenConfig {
optional bool wait_for_finalization = 10;
optional bool authenticated = 11;
optional bool verify_cert = 12;
optional string path_to_points = 13;
optional uint64 chain_id = 14;
oneof points {
Path path = 13;
Link link = 14;
}
optional uint64 chain_id = 15;
}

message DataAvailabilityClient {
Expand Down
13 changes: 7 additions & 6 deletions core/node/da_clients/src/eigen/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl EigenClient {
#[cfg(test)]
mod tests {
use serial_test::serial;
use zksync_config::configs::da_client::eigen::Points;
use zksync_types::secrets::PrivateKey;

use super::*;
Expand All @@ -111,7 +112,7 @@ mod tests {
wait_for_finalization: false,
authenticated: false,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points: Points::Path("../../../resources".to_string()),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -151,7 +152,7 @@ mod tests {
wait_for_finalization: false,
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points: Points::Path("../../../resources".to_string()),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -188,7 +189,7 @@ mod tests {
wait_for_finalization: true,
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points: Points::Path("../../../resources".to_string()),
eth_confirmation_depth: 0,
eigenda_eth_rpc: "https://ethereum-holesky-rpc.publicnode.com".to_string(),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
Expand Down Expand Up @@ -227,7 +228,7 @@ mod tests {
wait_for_finalization: true,
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points: Points::Path("../../../resources".to_string()),
eth_confirmation_depth: 0,
eigenda_eth_rpc: "https://ethereum-holesky-rpc.publicnode.com".to_string(),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
Expand Down Expand Up @@ -265,7 +266,7 @@ mod tests {
wait_for_finalization: false,
authenticated: false,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points: Points::Path("../../../resources".to_string()),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -305,7 +306,7 @@ mod tests {
wait_for_finalization: false,
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points: Points::Path("../../../resources".to_string()),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down
3 changes: 2 additions & 1 deletion core/node/da_clients/src/eigen/eigenda-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ da_client:
wait_for_finalization: false
authenticated: false
verify_cert: true
path_to_points: ./resources
points:
link: <link_to_points>
chain_id: <your_chain_id>
```

Expand Down
3 changes: 2 additions & 1 deletion core/node/da_clients/src/eigen/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ impl RawEigenClient {
rpc_url: config.eigenda_eth_rpc.clone(),
svc_manager_addr: config.eigenda_svc_manager_address.clone(),
max_blob_size: config.blob_size_limit,
path_to_points: config.path_to_points.clone(),
points: config.points.clone(),
eth_confirmation_depth: config.eth_confirmation_depth.max(0) as u32,
private_key: hex::encode(private_key.secret_bytes()),
chain_id: config.chain_id,
};
let verifier = Verifier::new(verifier_config)
.await
.map_err(|e| anyhow::anyhow!(format!("Failed to create verifier {:?}", e)))?;
Ok(RawEigenClient {
client,
Expand Down
Loading
Loading