From dec443ae5a6b34f3307f1d0fd14515bd981c4b1e Mon Sep 17 00:00:00 2001 From: Gianbelinche <39842759+gianbelinche@users.noreply.github.com> Date: Fri, 6 Dec 2024 11:48:26 -0300 Subject: [PATCH] Remove path to points in favor of links --- .../lib/config/src/configs/da_client/eigen.rs | 18 +++--------- core/lib/env_config/src/da_client.rs | 19 ++++-------- core/lib/protobuf_config/src/da_client.rs | 29 ++++--------------- .../src/proto/config/da_client.proto | 20 ++++--------- .../node/da_clients/src/eigen/client_tests.rs | 20 +++++++------ core/node/da_clients/src/eigen/sdk.rs | 3 +- core/node/da_clients/src/eigen/verifier.rs | 25 +++++----------- .../da_clients/src/eigen/verifier_tests.rs | 4 +-- 8 files changed, 43 insertions(+), 95 deletions(-) diff --git a/core/lib/config/src/configs/da_client/eigen.rs b/core/lib/config/src/configs/da_client/eigen.rs index f696c7112425..8a8f4d1d58a6 100644 --- a/core/lib/config/src/configs/da_client/eigen.rs +++ b/core/lib/config/src/configs/da_client/eigen.rs @@ -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 { @@ -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, } diff --git a/core/lib/env_config/src/da_client.rs b/core/lib/env_config/src/da_client.rs index a8d9287b2db3..9556438f23e2 100644 --- a/core/lib/env_config/src/da_client.rs +++ b/core/lib/env_config/src/da_client.rs @@ -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 => { @@ -118,7 +111,6 @@ mod tests { configs::{ da_client::{ avail::{AvailClientConfig, AvailDefaultConfig}, - eigen::PointsSource, DAClientConfig::{self, ObjectStore}, }, object_store::ObjectStoreMode::GCS, @@ -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); @@ -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 }) ); diff --git a/core/lib/protobuf_config/src/da_client.rs b/core/lib/protobuf_config/src/da_client.rs index 661f29fd26cc..9bd278ccd1a8 100644 --- a/core/lib/protobuf_config/src/da_client.rs +++ b/core/lib/protobuf_config/src/da_client.rs @@ -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, }; @@ -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) => { @@ -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( diff --git a/core/lib/protobuf_config/src/proto/config/da_client.proto b/core/lib/protobuf_config/src/proto/config/da_client.proto index e866749c42e6..dfa565bdddd5 100644 --- a/core/lib/protobuf_config/src/proto/config/da_client.proto +++ b/core/lib/protobuf_config/src/proto/config/da_client.proto @@ -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"; } diff --git a/core/node/da_clients/src/eigen/client_tests.rs b/core/node/da_clients/src/eigen/client_tests.rs index e80f8c9846ee..a46aa10c4470 100644 --- a/core/node/da_clients/src/eigen/client_tests.rs +++ b/core/node/da_clients/src/eigen/client_tests.rs @@ -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, @@ -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 { @@ -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 { @@ -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(), @@ -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 { @@ -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 { diff --git a/core/node/da_clients/src/eigen/sdk.rs b/core/node/da_clients/src/eigen/sdk.rs index 4189685f7a71..c2660c8414a3 100644 --- a/core/node/da_clients/src/eigen/sdk.rs +++ b/core/node/da_clients/src/eigen/sdk.rs @@ -56,7 +56,8 @@ 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, - 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()), diff --git a/core/node/da_clients/src/eigen/verifier.rs b/core/node/da_clients/src/eigen/verifier.rs index 9d8a3d16568c..c252c6c1bcfc 100644 --- a/core/node/da_clients/src/eigen/verifier.rs +++ b/core/node/da_clients/src/eigen/verifier.rs @@ -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}, @@ -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, @@ -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() { @@ -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 { - 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 { + 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()) } @@ -136,10 +130,7 @@ impl Verifier { signing_client: T, ) -> Result { 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"), "", diff --git a/core/node/da_clients/src/eigen/verifier_tests.rs b/core/node/da_clients/src/eigen/verifier_tests.rs index b1829df11aef..183aaa1ee582 100644 --- a/core/node/da_clients/src/eigen/verifier_tests.rs +++ b/core/node/da_clients/src/eigen/verifier_tests.rs @@ -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, @@ -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(),