Skip to content

Commit

Permalink
Merge branch 'eigen-client-extra-features' into eigen-client-docs-reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Nov 28, 2024
2 parents 836913b + 75090b6 commit 5684581
Show file tree
Hide file tree
Showing 9 changed files with 888 additions and 331 deletions.
20 changes: 15 additions & 5 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
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 {
/// URL of the Disperser RPC server
pub disperser_rpc: String,
/// Block height needed to reach in order to consider the blob finalized
/// a value less or equal to 0 means that the disperser will not wait for finalization
pub eth_confirmation_depth: i32,
pub settlement_layer_confirmation_depth: i32,
/// URL of the Ethereum RPC server
pub eigenda_eth_rpc: String,
/// Address of the service manager contract
pub eigenda_svc_manager_address: String,
/// Maximum size permitted for a blob in bytes
pub blob_size_limit: u32,
/// Maximun amount of time in milliseconds to wait for a status query response
pub status_query_timeout: u64,
/// Interval in milliseconds to query the status of a blob
Expand All @@ -24,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
61 changes: 44 additions & 17 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 @@ -250,16 +278,16 @@ mod tests {
DA_CLIENT="Eigen"
DA_EIGEN_CLIENT_TYPE="Disperser"
DA_DISPERSER_RPC="http://localhost:8080"
DA_ETH_CONFIRMATION_DEPTH=0
DA_SETTLEMENT_LAYER_CONFIRMATION_DEPTH=0
DA_EIGENDA_ETH_RPC="http://localhost:8545"
DA_EIGENDA_SVC_MANAGER_ADDRESS="0x123"
DA_BLOB_SIZE_LIMIT=1000
DA_STATUS_QUERY_TIMEOUT=2
DA_STATUS_QUERY_INTERVAL=3
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 @@ -269,16 +297,15 @@ mod tests {
actual,
DAClientConfig::Eigen(EigenConfig {
disperser_rpc: "http://localhost:8080".to_string(),
eth_confirmation_depth: 0,
settlement_layer_confirmation_depth: 0,
eigenda_eth_rpc: "http://localhost:8545".to_string(),
eigenda_svc_manager_address: "0x123".to_string(),
blob_size_limit: 1000,
status_query_timeout: 2,
status_query_interval: 3,
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
44 changes: 34 additions & 10 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 @@ -56,15 +59,16 @@ impl ProtoRepr for proto::DataAvailabilityClient {
disperser_rpc: required(&conf.disperser_rpc)
.context("disperser_rpc")?
.clone(),
eth_confirmation_depth: *required(&conf.eth_confirmation_depth)
.context("eth_confirmation_depth")?,
settlement_layer_confirmation_depth: *required(
&conf.settlement_layer_confirmation_depth,
)
.context("settlement_layer_confirmation_depth")?,
eigenda_eth_rpc: required(&conf.eigenda_eth_rpc)
.context("eigenda_eth_rpc")?
.clone(),
eigenda_svc_manager_address: required(&conf.eigenda_svc_manager_address)
.context("eigenda_svc_manager_address")?
.clone(),
blob_size_limit: *required(&conf.blob_size_limit).context("blob_size_limit")?,
status_query_timeout: *required(&conf.status_query_timeout)
.context("status_query_timeout")?,
status_query_interval: *required(&conf.status_query_interval)
Expand All @@ -73,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 @@ -116,16 +128,28 @@ impl ProtoRepr for proto::DataAvailabilityClient {
}
Eigen(config) => proto::data_availability_client::Config::Eigen(proto::EigenConfig {
disperser_rpc: Some(config.disperser_rpc.clone()),
eth_confirmation_depth: Some(config.eth_confirmation_depth),
settlement_layer_confirmation_depth: Some(
config.settlement_layer_confirmation_depth,
),
eigenda_eth_rpc: Some(config.eigenda_eth_rpc.clone()),
eigenda_svc_manager_address: Some(config.eigenda_svc_manager_address.clone()),
blob_size_limit: Some(config.blob_size_limit),
status_query_timeout: Some(config.status_query_timeout),
status_query_interval: Some(config.status_query_interval),
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
29 changes: 20 additions & 9 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,31 @@ 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;
optional int32 eth_confirmation_depth = 4;
optional int32 settlement_layer_confirmation_depth = 4;
optional string eigenda_eth_rpc = 5;
optional string eigenda_svc_manager_address = 6;
optional uint32 blob_size_limit = 7;
optional uint64 status_query_timeout = 8;
optional uint64 status_query_interval = 9;
optional bool wait_for_finalization = 10;
optional bool authenticated = 11;
optional bool verify_cert = 12;
optional string path_to_points = 13;
optional uint64 status_query_timeout = 7;
optional uint64 status_query_interval = 8;
optional bool wait_for_finalization = 9;
optional bool authenticated = 10;
optional bool verify_cert = 11;
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";
}

message DataAvailabilityClient {
Expand Down
Loading

0 comments on commit 5684581

Please sign in to comment.