Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eigen-client-extra-features): Remove memstore #346

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 1 addition & 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,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 All @@ -57,13 +50,6 @@ message DisperserConfig {
optional string path_to_points = 13;
}

message EigenConfig {
oneof config {
MemStoreConfig mem_store = 1;
DisperserConfig disperser = 2;
}
}

message DataAvailabilityClient {
// oneof in protobuf allows for None
oneof config {
Expand Down
Loading
Loading