Skip to content

Commit

Permalink
Remove path to points in favor of links
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Dec 6, 2024
1 parent f555519 commit dec443a
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 95 deletions.
18 changes: 4 additions & 14 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
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 @@ -28,8 +16,10 @@ pub struct EigenConfig {
pub wait_for_finalization: bool,
/// Authenticated dispersal
pub authenticated: bool,
/// Path or link to the file containing the points used for KZG
pub points_source: PointsSource,
/// Link to the file containing the G1 point used for KZG
pub g1_link: String,
/// Link to the file containing the G2 point used for KZG
pub g2_link: String,
/// Chain ID of the Ethereum network
pub chain_id: u64,
}
Expand Down
19 changes: 6 additions & 13 deletions core/lib/env_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,8 @@ impl FromEnv for DAClientConfig {
eigenda_svc_manager_address: env::var("DA_EIGENDA_SVC_MANAGER_ADDRESS")?,
wait_for_finalization: env::var("DA_WAIT_FOR_FINALIZATION")?.parse()?,
authenticated: env::var("DA_AUTHENTICATED")?.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"),
},
g1_link: env::var("DA_G1_LINK")?.parse()?,
g2_link: env::var("DA_G2_LINK")?.parse()?,
chain_id: env::var("DA_CHAIN_ID")?.parse()?,
}),
OBJECT_STORE_CLIENT_CONFIG_NAME => {
Expand Down Expand Up @@ -118,7 +111,6 @@ mod tests {
configs::{
da_client::{
avail::{AvailClientConfig, AvailDefaultConfig},
eigen::PointsSource,
DAClientConfig::{self, ObjectStore},
},
object_store::ObjectStoreMode::GCS,
Expand Down Expand Up @@ -280,8 +272,8 @@ mod tests {
DA_EIGENDA_SVC_MANAGER_ADDRESS="0x123"
DA_WAIT_FOR_FINALIZATION=true
DA_AUTHENTICATED=false
DA_POINTS_SOURCE="Path"
DA_POINTS_PATH="resources"
DA_G1_LINK="resources1"
DA_G2_LINK="resources2"
DA_CHAIN_ID=1
"#;
lock.set_env(config);
Expand All @@ -296,7 +288,8 @@ mod tests {
eigenda_svc_manager_address: "0x123".to_string(),
wait_for_finalization: true,
authenticated: false,
points_source: PointsSource::Path("resources".to_string()),
g1_link: "resources1".to_string(),
g2_link: "resources2".to_string(),
chain_id: 1
})
);
Expand Down
29 changes: 5 additions & 24 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use zksync_config::configs::{
use zksync_protobuf::{required, ProtoRepr};

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

Expand Down Expand Up @@ -72,17 +72,8 @@ impl ProtoRepr for proto::DataAvailabilityClient {
wait_for_finalization: *required(&conf.wait_for_finalization)
.context("wait_for_finalization")?,
authenticated: *required(&conf.authenticated).context("authenticated")?,
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")),
},
g1_link: required(&conf.g1_link).context("g1_link")?.clone(),
g2_link: required(&conf.g2_link).context("g2_link")?.clone(),
chain_id: *required(&conf.chain_id).context("chain_id")?,
}),
proto::data_availability_client::Config::ObjectStore(conf) => {
Expand Down Expand Up @@ -130,18 +121,8 @@ impl ProtoRepr for proto::DataAvailabilityClient {
eigenda_svc_manager_address: Some(config.eigenda_svc_manager_address.clone()),
wait_for_finalization: Some(config.wait_for_finalization),
authenticated: Some(config.authenticated),
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()),
})
}
}),
g1_link: Some(config.g1_link.clone()),
g2_link: Some(config.g2_link.clone()),
chain_id: Some(config.chain_id),
}),
ObjectStore(config) => proto::data_availability_client::Config::ObjectStore(
Expand Down
20 changes: 5 additions & 15 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,16 @@ 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;
optional string eigenda_eth_rpc = 5;
optional string eigenda_svc_manager_address = 6;
optional bool wait_for_finalization = 8;
optional bool authenticated = 9;
oneof points_source {
Path path = 10;
Link link = 11;
}
optional uint64 chain_id = 12;
optional bool wait_for_finalization = 7;
optional bool authenticated = 8;
optional string g1_link = 9;
optional string g2_link = 10;
optional uint64 chain_id = 11;
reserved 1,2;
reserved "rpc_node_url","inclusion_polling_interval_ms";
}
Expand Down
20 changes: 11 additions & 9 deletions core/node/da_clients/src/eigen/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ mod tests {

use backon::{ConstantBuilder, Retryable};
use serial_test::serial;
use zksync_config::{
configs::da_client::eigen::{EigenSecrets, PointsSource},
EigenConfig,
};
use zksync_config::{configs::da_client::eigen::EigenSecrets, EigenConfig};
use zksync_da_client::{
types::{DAError, DispatchResponse},
DataAvailabilityClient,
Expand Down Expand Up @@ -78,7 +75,8 @@ mod tests {
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
wait_for_finalization: false,
authenticated: false,
points_source: PointsSource::Path("../../../resources".to_string()),
g1_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
g2_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -117,7 +115,8 @@ mod tests {
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
wait_for_finalization: false,
authenticated: true,
points_source: PointsSource::Path("../../../resources".to_string()),
g1_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
g2_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -153,7 +152,8 @@ mod tests {
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
wait_for_finalization: true,
authenticated: true,
points_source: PointsSource::Path("../../../resources".to_string()),
g1_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
g2_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".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 @@ -195,7 +195,8 @@ mod tests {
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
wait_for_finalization: false,
authenticated: false,
points_source: PointsSource::Path("../../../resources".to_string()),
g1_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
g2_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -234,7 +235,8 @@ mod tests {
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
wait_for_finalization: false,
authenticated: true,
points_source: PointsSource::Path("../../../resources".to_string()),
g1_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
g2_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
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 @@ -56,7 +56,8 @@ impl<T: GetBlobData> RawEigenClient<T> {
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,
points: config.points_source.clone(),
g1_link: config.g1_link.clone(),
g2_link: config.g2_link.clone(),
settlement_layer_confirmation_depth: config.settlement_layer_confirmation_depth.max(0)
as u32,
private_key: hex::encode(private_key.secret_bytes()),
Expand Down
25 changes: 8 additions & 17 deletions core/node/da_clients/src/eigen/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rust_kzg_bn254::{blob::Blob, kzg::Kzg, polynomial::PolynomialFormat};
use tiny_keccak::{Hasher, Keccak};
use url::Url;
use zksync_basic_types::web3::CallRequest;
use zksync_config::configs::da_client::eigen::PointsSource;
use zksync_eth_client::{clients::PKSigningClient, EnrichedClientResult};
use zksync_types::{
web3::{self, BlockId, BlockNumber},
Expand Down Expand Up @@ -71,7 +70,8 @@ pub struct VerifierConfig {
pub rpc_url: String,
pub svc_manager_addr: String,
pub max_blob_size: u32,
pub points: PointsSource,
pub g1_link: String,
pub g2_link: String,
pub settlement_layer_confirmation_depth: u32,
pub private_key: String,
pub chain_id: u64,
Expand Down Expand Up @@ -102,14 +102,8 @@ impl Verifier {
pub const SRSORDER: u32 = 268435456; // 2 ^ 28

async fn save_point(link: String, point: String) -> Result<(), VerificationError> {
let mut url_base = Url::parse(&link).map_err(|_| VerificationError::LinkError)?;
if !url_base.as_str().ends_with('/') {
url_base.set_path(&format!("{}/", url_base.path()));
}
let url_g1 = url_base
.join(&point)
.map_err(|_| VerificationError::LinkError)?;
let response = reqwest::get(url_g1)
let url = Url::parse(&link).map_err(|_| VerificationError::LinkError)?;
let response = reqwest::get(url)
.await
.map_err(|_| VerificationError::LinkError)?;
if !response.status().is_success() {
Expand All @@ -125,9 +119,9 @@ impl Verifier {
copy(&mut content.as_ref(), &mut file).map_err(|_| VerificationError::LinkError)?;
Ok(())
}
async fn save_points(link: String) -> Result<String, VerificationError> {
Self::save_point(link.clone(), "g1.point".to_string()).await?;
Self::save_point(link.clone(), "g2.point.powerOf2".to_string()).await?;
async fn save_points(link_g1: String, link_g2: String) -> Result<String, VerificationError> {
Self::save_point(link_g1.clone(), "g1.point".to_string()).await?;
Self::save_point(link_g2.clone(), "g2.point.powerOf2".to_string()).await?;

Ok(".".to_string())
}
Expand All @@ -136,10 +130,7 @@ impl Verifier {
signing_client: T,
) -> Result<Self, VerificationError> {
let srs_points_to_load = cfg.max_blob_size / 32;
let path = match cfg.points.clone() {
PointsSource::Path(path) => path,
PointsSource::Link(link) => Self::save_points(link).await?,
};
let path = Self::save_points(cfg.clone().g1_link, cfg.clone().g2_link).await?;
let kzg = Kzg::setup(
&format!("{}{}", path, "/g1.point"),
"",
Expand Down
4 changes: 2 additions & 2 deletions core/node/da_clients/src/eigen/verifier_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
mod test {
use std::{collections::HashMap, str::FromStr};

use zksync_config::configs::da_client::eigen::PointsSource;
use zksync_eth_client::{clients::PKSigningClient, EnrichedClientResult};
use zksync_types::{
url::SensitiveUrl,
Expand All @@ -24,7 +23,8 @@ mod test {
rpc_url: "https://ethereum-holesky-rpc.publicnode.com".to_string(),
svc_manager_addr: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
max_blob_size: 2 * 1024 * 1024,
points: PointsSource::Path("../../../resources".to_string()),
g1_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
g2_link: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".to_string(),
settlement_layer_confirmation_depth: 0,
private_key: "0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6"
.to_string(),
Expand Down

0 comments on commit dec443a

Please sign in to comment.