Skip to content

Commit

Permalink
Merge branch 'eigen-client-extra-features' into eigen-client-reserved…
Browse files Browse the repository at this point in the history
…-proto
  • Loading branch information
gianbelinche committed Nov 21, 2024
2 parents c04bcb6 + a2ddcc3 commit b245163
Show file tree
Hide file tree
Showing 13 changed files with 267 additions and 749 deletions.
254 changes: 52 additions & 202 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ pbjson-types = "0.6.0"

# Eigen
tokio-stream = "0.1.16"
alloy = { version = "0.3", features = ["full"] }
rust-kzg-bn254 = {git = "https://github.com/lambdaclass/rust-kzg-bn254", branch = "bump-ark"}
ark-bn254 = "0.5.0-alpha.0"
num-bigint = "0.4.6"
serial_test = "3.1.1"

# Here and below:
# We *always* pin the latest version of protocol to disallow accidental changes in the execution logic.
Expand Down
24 changes: 1 addition & 23 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
use serde::Deserialize;
use zksync_basic_types::secrets::PrivateKey;

pub const EIGEN_MEMSTORE_CLIENT_NAME: &str = "MemStore";
pub const EIGEN_DISPERSER_CLIENT_NAME: &str = "Disperser";

#[derive(Clone, Debug, PartialEq, Deserialize)]
pub enum EigenConfig {
MemStore(MemStoreConfig),
Disperser(DisperserConfig),
}

/// Configuration for the EigenDA in-memory client.
#[derive(Clone, Debug, PartialEq, Deserialize, Default)]
pub struct MemStoreConfig {
pub max_blob_size_bytes: u64,
/// Blob expiration time in seconds
pub blob_expiration: u64,
/// Latency in milliseconds for get operations
pub get_latency: u64,
/// Latency in milliseconds for put operations
pub put_latency: u64,
}

/// Configuration for the EigenDA remote disperser client.
#[derive(Clone, Debug, PartialEq, Deserialize, Default)]
pub struct DisperserConfig {
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
Expand Down
68 changes: 14 additions & 54 deletions core/lib/env_config/src/da_client.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
use std::env;

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

use crate::{envy_load, FromEnv};
Expand All @@ -38,17 +34,7 @@ impl FromEnv for DAClientConfig {
},
}),
CELESTIA_CLIENT_CONFIG_NAME => Self::Celestia(envy_load("da_celestia_config", "DA_")?),
EIGEN_CLIENT_CONFIG_NAME => match env::var("DA_EIGEN_CLIENT_TYPE")?.as_str() {
EIGEN_DISPERSER_CLIENT_NAME => Self::Eigen(EigenConfig::Disperser(envy_load(
"da_eigen_config_disperser",
"DA_",
)?)),
EIGEN_MEMSTORE_CLIENT_NAME => Self::Eigen(EigenConfig::MemStore(envy_load(
"da_eigen_config_memstore",
"DA_",
)?)),
_ => anyhow::bail!("Unknown Eigen DA client type"),
},
EIGEN_CLIENT_CONFIG_NAME => Self::Eigen(envy_load("da_eigen_config", "DA_")?),
OBJECT_STORE_CLIENT_CONFIG_NAME => {
Self::ObjectStore(envy_load("da_object_store", "DA_")?)
}
Expand Down Expand Up @@ -108,7 +94,6 @@ mod tests {
configs::{
da_client::{
avail::{AvailClientConfig, AvailDefaultConfig},
eigen::{DisperserConfig, MemStoreConfig},
DAClientConfig::{self, ObjectStore},
},
object_store::ObjectStoreMode::GCS,
Expand Down Expand Up @@ -259,32 +244,7 @@ mod tests {
}

#[test]
fn from_env_eigen_client_memstore() {
let mut lock = MUTEX.lock();
let config = r#"
DA_CLIENT="Eigen"
DA_EIGEN_CLIENT_TYPE="MemStore"
DA_MAX_BLOB_SIZE_BYTES=10
DA_BLOB_EXPIRATION=20
DA_GET_LATENCY=30
DA_PUT_LATENCY=40
"#;
lock.set_env(config);

let actual = DAClientConfig::from_env().unwrap();
assert_eq!(
actual,
DAClientConfig::Eigen(EigenConfig::MemStore(MemStoreConfig {
max_blob_size_bytes: 10,
blob_expiration: 20,
get_latency: 30,
put_latency: 40,
}))
);
}

#[test]
fn from_env_eigen_client_remote() {
fn from_env_eigen_client() {
let mut lock = MUTEX.lock();
let config = r#"
DA_CLIENT="Eigen"
Expand All @@ -306,7 +266,7 @@ mod tests {
let actual = DAClientConfig::from_env().unwrap();
assert_eq!(
actual,
DAClientConfig::Eigen(EigenConfig::Disperser(DisperserConfig {
DAClientConfig::Eigen(EigenConfig {
disperser_rpc: "http://localhost:8080".to_string(),
eth_confirmation_depth: 0,
eigenda_eth_rpc: "http://localhost:8545".to_string(),
Expand All @@ -318,7 +278,7 @@ mod tests {
authenticated: false,
verify_cert: false,
path_to_points: "resources".to_string(),
}))
})
);
}

Expand Down
122 changes: 39 additions & 83 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use zksync_config::configs::{
da_client::{
avail::{AvailClientConfig, AvailConfig, AvailDefaultConfig, AvailGasRelayConfig},
celestia::CelestiaConfig,
eigen::{DisperserConfig, EigenConfig, MemStoreConfig},
eigen::EigenConfig,
DAClientConfig::{Avail, Celestia, Eigen, ObjectStore},
},
};
Expand Down Expand Up @@ -52,53 +52,31 @@ impl ProtoRepr for proto::DataAvailabilityClient {
chain_id: required(&conf.chain_id).context("chain_id")?.clone(),
timeout_ms: *required(&conf.timeout_ms).context("timeout_ms")?,
}),
proto::data_availability_client::Config::Eigen(conf) => {
let config = required(&conf.config).context("config")?;
let eigen_config = match config {
proto::eigen_config::Config::MemStore(conf) => {
EigenConfig::MemStore(MemStoreConfig {
max_blob_size_bytes: *required(&conf.max_blob_size_bytes)
.context("max_blob_size_bytes")?,
blob_expiration: *required(&conf.blob_expiration)
.context("blob_expiration")?,
get_latency: *required(&conf.get_latency).context("get_latency")?,
put_latency: *required(&conf.put_latency).context("put_latency")?,
})
}
proto::eigen_config::Config::Disperser(conf) => {
EigenConfig::Disperser(DisperserConfig {
disperser_rpc: required(&conf.disperser_rpc)
.context("disperser_rpc")?
.clone(),
eth_confirmation_depth: *required(&conf.eth_confirmation_depth)
.context("eth_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)
.context("status_query_interval")?,
wait_for_finalization: *required(&conf.wait_for_finalization)
.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(),
})
}
};
Eigen(eigen_config)
}
proto::data_availability_client::Config::Eigen(conf) => Eigen(EigenConfig {
disperser_rpc: required(&conf.disperser_rpc)
.context("disperser_rpc")?
.clone(),
eth_confirmation_depth: *required(&conf.eth_confirmation_depth)
.context("eth_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)
.context("status_query_interval")?,
wait_for_finalization: *required(&conf.wait_for_finalization)
.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(),
}),
proto::data_availability_client::Config::ObjectStore(conf) => {
ObjectStore(object_store_proto::ObjectStore::read(conf)?)
}
Expand Down Expand Up @@ -135,41 +113,19 @@ impl ProtoRepr for proto::DataAvailabilityClient {
timeout_ms: Some(config.timeout_ms),
})
}
Eigen(config) => match config {
EigenConfig::MemStore(config) => {
proto::data_availability_client::Config::Eigen(proto::EigenConfig {
config: Some(proto::eigen_config::Config::MemStore(
proto::MemStoreConfig {
max_blob_size_bytes: Some(config.max_blob_size_bytes),
blob_expiration: Some(config.blob_expiration),
get_latency: Some(config.get_latency),
put_latency: Some(config.put_latency),
},
)),
})
}
EigenConfig::Disperser(config) => {
proto::data_availability_client::Config::Eigen(proto::EigenConfig {
config: Some(proto::eigen_config::Config::Disperser(
proto::DisperserConfig {
disperser_rpc: Some(config.disperser_rpc.clone()),
eth_confirmation_depth: Some(config.eth_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()),
},
)),
})
}
},
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),
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()),
}),
ObjectStore(config) => proto::data_availability_client::Config::ObjectStore(
object_store_proto::ObjectStore::build(config),
),
Expand Down
9 changes: 1 addition & 8 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ message CelestiaConfig {
optional uint64 timeout_ms = 4;
}

message MemStoreConfig {
optional uint64 max_blob_size_bytes = 3;
optional uint64 blob_expiration = 4;
optional uint64 get_latency = 5;
optional uint64 put_latency = 6;
}

message DisperserConfig {
message EigenConfig {
optional string disperser_rpc = 3;
optional int32 eth_confirmation_depth = 4;
optional string eigenda_eth_rpc = 5;
Expand Down
13 changes: 6 additions & 7 deletions core/node/da_clients/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ pbjson-types.workspace = true
# Eigen dependencies
tokio-stream.workspace = true
rlp.workspace = true
kzgpad-rs = { git = "https://github.com/Layr-Labs/kzgpad-rs.git", tag = "v0.1.0" }
rand.workspace = true
sha3.workspace = true
tiny-keccak.workspace = true
alloy = { version = "0.3", features = ["full"] }
ethabi = "16.0.0"
rust-kzg-bn254 = {git = "https://github.com/lambdaclass/rust-kzg-bn254", branch = "bump-ark"}
ark-bn254 = "0.5.0-alpha.0"
num-bigint = "0.4.6"
serial_test = "3.1.1"
alloy.workspace = true
ethabi.workspace = true
rust-kzg-bn254.workspace = true
ark-bn254.workspace = true
num-bigint.workspace = true
serial_test.workspace = true
Loading

0 comments on commit b245163

Please sign in to comment.