Skip to content

Commit

Permalink
feat(eigen-client-extra-features): Add option to download points (#361)
Browse files Browse the repository at this point in the history
* Add option to download points

* Fix test

* Fix clippy

* Change name to points source

* Fix test

* Fix test
  • Loading branch information
gianbelinche authored Nov 28, 2024
1 parent 163c41a commit cef9a89
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 48 deletions.
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 PointsSource {
Path(String),
Link(String),
}

impl Default for PointsSource {
fn default() -> Self {
PointsSource::Path("".to_string())
}
}
/// Configuration for the EigenDA remote disperser client.
#[derive(Clone, Debug, PartialEq, Deserialize, Default)]
pub struct EigenConfig {
Expand All @@ -22,8 +34,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_source: PointsSource,
/// Chain ID of the Ethereum network
pub chain_id: u64,
}
Expand Down
55 changes: 42 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,30 @@ 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")?,
settlement_layer_confirmation_depth: env::var(
"DA_SETTLEMENT_LAYER_CONFIRMATION_DEPTH",
)?
.parse()?,
eigenda_eth_rpc: env::var("DA_EIGENDA_ETH_RPC")?,
eigenda_svc_manager_address: env::var("DA_EIGENDA_SVC_MANAGER_ADDRESS")?,
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_source: match env::var("DA_POINTS_SOURCE")?.as_str() {
"Path" => zksync_config::configs::da_client::eigen::PointsSource::Path(
env::var("DA_POINTS_PATH")?,
),
"Link" => zksync_config::configs::da_client::eigen::PointsSource::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 +121,7 @@ mod tests {
configs::{
da_client::{
avail::{AvailClientConfig, AvailDefaultConfig},
eigen::PointsSource,
DAClientConfig::{self, ObjectStore},
},
object_store::ObjectStoreMode::GCS,
Expand Down Expand Up @@ -258,7 +286,8 @@ mod tests {
DA_WAIT_FOR_FINALIZATION=true
DA_AUTHENTICATED=false
DA_VERIFY_CERT=false
DA_PATH_TO_POINTS="resources"
DA_POINTS_SOURCE="Path"
DA_POINTS_PATH="resources"
DA_CHAIN_ID=1
"#;
lock.set_env(config);
Expand All @@ -276,7 +305,7 @@ mod tests {
wait_for_finalization: true,
authenticated: false,
verify_cert: false,
path_to_points: "resources".to_string(),
points_source: PointsSource::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 @@ -74,9 +77,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_source: match conf.points_source.clone() {
Some(proto::eigen_config::PointsSource::Path(path)) => {
let path = required(&path.path).context("path")?;
zksync_config::configs::da_client::eigen::PointsSource::Path(path.clone())
}
Some(proto::eigen_config::PointsSource::Link(link)) => {
let link = required(&link.link).context("link")?;
zksync_config::configs::da_client::eigen::PointsSource::Link(link.clone())
}
None => return Err(anyhow::anyhow!("Invalid Eigen DA configuration")),
},
chain_id: *required(&conf.chain_id).context("chain_id")?,
}),
proto::data_availability_client::Config::ObjectStore(conf) => {
Expand Down Expand Up @@ -127,7 +138,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_source: Some(match &config.points_source {
zksync_config::configs::da_client::eigen::PointsSource::Path(path) => {
proto::eigen_config::PointsSource::Path(Path {
path: Some(path.to_string()),
})
}
zksync_config::configs::da_client::eigen::PointsSource::Link(link) => {
proto::eigen_config::PointsSource::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 {
optional string disperser_rpc = 3;
optional int32 settlement_layer_confirmation_depth = 4;
Expand All @@ -46,8 +54,11 @@ message EigenConfig {
optional bool wait_for_finalization = 9;
optional bool authenticated = 10;
optional bool verify_cert = 11;
optional string path_to_points = 12;
optional uint64 chain_id = 13;
oneof points_source {
Path path = 12;
Link link = 13;
}
optional uint64 chain_id = 14;
reserved 1,2;
reserved "rpc_node_url","inclusion_polling_interval_ms";
}
Expand Down
11 changes: 6 additions & 5 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::PointsSource;
use zksync_types::secrets::PrivateKey;

use super::*;
Expand All @@ -110,7 +111,7 @@ mod tests {
wait_for_finalization: false,
authenticated: false,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points_source: PointsSource::Path("../../../resources".to_string()),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -152,7 +153,7 @@ mod tests {
wait_for_finalization: false,
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points_source: PointsSource::Path("../../../resources".to_string()),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -190,7 +191,7 @@ mod tests {
wait_for_finalization: true,
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points_source: PointsSource::Path("../../../resources".to_string()),
settlement_layer_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 @@ -234,7 +235,7 @@ mod tests {
wait_for_finalization: false,
authenticated: false,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points_source: PointsSource::Path("../../../resources".to_string()),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -275,7 +276,7 @@ mod tests {
wait_for_finalization: false,
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
points_source: PointsSource::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 @@ -29,7 +29,8 @@ da_client:
wait_for_finalization: false
authenticated: false
verify_cert: true
path_to_points: ./resources
link:
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 @@ -52,13 +52,14 @@ impl RawEigenClient {
rpc_url: config.eigenda_eth_rpc.clone(),
svc_manager_addr: config.eigenda_svc_manager_address.clone(),
max_blob_size: Self::BLOB_SIZE_LIMIT as u32,
path_to_points: config.path_to_points.clone(),
points: config.points_source.clone(),
settlement_layer_confirmation_depth: config.settlement_layer_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

0 comments on commit cef9a89

Please sign in to comment.