Skip to content

feat(eigen-client-extra-features): address comments #395

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

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
39 changes: 9 additions & 30 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::str::FromStr;

use serde::Deserialize;
use zksync_basic_types::{secrets::PrivateKey, url::SensitiveUrl, Address, H160};
use zksync_basic_types::{secrets::PrivateKey, url::SensitiveUrl, Address};

/// Default address of the EigenDA service manager contract deployed on Holesky.
const DEFAULT_EIGENDA_SVC_MANAGER_ADDRESS: H160 = H160([
0xd4, 0xa7, 0xe1, 0xbd, 0x80, 0x15, 0x05, 0x72, 0x93, 0xf0, 0xd0, 0xa5, 0x57, 0x08, 0x8c, 0x28,
0x69, 0x42, 0xe8, 0x4b,
]);
#[derive(Clone, Debug, PartialEq, Deserialize)]
pub enum PointsSource {
Path(String),
/// g1_url, g2_url
Url((String, String)),
}

/// Configuration for the EigenDA remote disperser client.
#[derive(Clone, Debug, PartialEq, Deserialize)]
Expand All @@ -25,28 +24,8 @@ pub struct EigenConfig {
pub wait_for_finalization: bool,
/// Authenticated dispersal
pub authenticated: bool,
/// Optional path to downloaded points directory
pub points_dir: Option<String>,
/// Url to the file containing the G1 point used for KZG
pub g1_url: String,
/// Url to the file containing the G2 point used for KZG
pub g2_url: String,
}

impl Default for EigenConfig {
fn default() -> Self {
Self {
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
settlement_layer_confirmation_depth: 0,
eigenda_eth_rpc: Some(SensitiveUrl::from_str("https://ethereum-holesky-rpc.publicnode.com").unwrap()), // Safe to unwrap, never fails
eigenda_svc_manager_address: DEFAULT_EIGENDA_SVC_MANAGER_ADDRESS,
wait_for_finalization: false,
authenticated: false,
points_dir: None,
g1_url: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
g2_url: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".to_string(),
}
}
/// Points source
pub points_source: PointsSource,
}

#[derive(Clone, Debug, PartialEq)]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions core/lib/dal/src/data_availability_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ impl DataAvailabilityDal<'_, '_> {
eth_commit_tx_id IS NULL
AND number != 0
AND data_availability.blob_id IS NULL
AND pubdata_input IS NOT NULL
AND sealed_at IS NOT NULL
ORDER BY
number
LIMIT
Expand Down Expand Up @@ -239,8 +237,6 @@ impl DataAvailabilityDal<'_, '_> {
WHERE
number != 0
AND data_availability.blob_id = $1
AND pubdata_input IS NOT NULL
AND sealed_at IS NOT NULL
ORDER BY
number
LIMIT
Expand Down
61 changes: 43 additions & 18 deletions core/lib/env_config/src/da_client.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
use std::env;
use std::{env, str::FromStr};

use zksync_config::configs::{
da_client::{
avail::{
AvailClientConfig, AvailSecrets, AVAIL_FULL_CLIENT_NAME, AVAIL_GAS_RELAY_CLIENT_NAME,
use zksync_basic_types::{url::SensitiveUrl, H160};
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 +39,29 @@ 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: Some(SensitiveUrl::from_str(&env::var("DA_EIGENDA_ETH_RPC")?)?),
eigenda_svc_manager_address: H160::from_str(&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")?,
),
"Url" => zksync_config::configs::da_client::eigen::PointsSource::Url((
env::var("DA_POINTS_LINK_G1")?,
env::var("DA_POINTS_LINK_G2")?,
)),
_ => anyhow::bail!("Unknown Eigen points type"),
},
}),
OBJECT_STORE_CLIENT_CONFIG_NAME => {
Self::ObjectStore(envy_load("da_object_store", "DA_")?)
}
Expand Down Expand Up @@ -97,6 +124,7 @@ mod tests {
configs::{
da_client::{
avail::{AvailClientConfig, AvailDefaultConfig},
eigen::PointsSource,
DAClientConfig::{self, ObjectStore},
},
object_store::ObjectStoreMode::GCS,
Expand Down Expand Up @@ -258,9 +286,8 @@ mod tests {
DA_EIGENDA_SVC_MANAGER_ADDRESS="0x0000000000000000000000000000000000000123"
DA_WAIT_FOR_FINALIZATION=true
DA_AUTHENTICATED=false
DA_POINTS_DIR="resources/"
DA_G1_URL="resources1"
DA_G2_URL="resources2"
DA_POINTS_SOURCE="Path"
DA_POINTS_PATH="resources"
"#;
lock.set_env(config);

Expand All @@ -276,9 +303,7 @@ mod tests {
.unwrap(),
wait_for_finalization: true,
authenticated: false,
points_dir: Some("resources/".to_string()),
g1_url: "resources1".to_string(),
g2_url: "resources2".to_string(),
points_source: PointsSource::Path("resources".to_string()),
})
);
}
Expand Down
32 changes: 26 additions & 6 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,20 @@ impl ProtoRepr for proto::DataAvailabilityClient {
wait_for_finalization: *required(&conf.wait_for_finalization)
.context("wait_for_finalization")?,
authenticated: *required(&conf.authenticated).context("authenticated")?,
points_dir: conf.points_dir.clone(),
g1_url: required(&conf.g1_url).context("g1_url")?.clone(),
g2_url: required(&conf.g2_url).context("g2_url")?.clone(),
points_source: match conf.points_source.clone() {
Some(proto::eigen_config::PointsSource::Path(path)) => {
zksync_config::configs::da_client::eigen::PointsSource::Path(path)
}
Some(proto::eigen_config::PointsSource::Url(url)) => {
let g1_url = required(&url.g1_url).context("g1_url")?;
let g2_url = required(&url.g2_url).context("g2_url")?;
zksync_config::configs::da_client::eigen::PointsSource::Url((
g1_url.to_owned(),
g2_url.to_owned(),
))
}
None => return Err(anyhow::anyhow!("Invalid Eigen DA configuration")),
},
}),
proto::data_availability_client::Config::ObjectStore(conf) => {
ObjectStore(object_store_proto::ObjectStore::read(conf)?)
Expand Down Expand Up @@ -135,9 +146,18 @@ impl ProtoRepr for proto::DataAvailabilityClient {
)),
wait_for_finalization: Some(config.wait_for_finalization),
authenticated: Some(config.authenticated),
g1_url: Some(config.g1_url.clone()),
g2_url: Some(config.g2_url.clone()),
points_dir: config.points_dir.as_ref().map(|a| a.to_string()),
points_source: Some(match &config.points_source {
zksync_config::configs::da_client::eigen::PointsSource::Path(path) => {
proto::eigen_config::PointsSource::Path(path.clone())
}
zksync_config::configs::da_client::eigen::PointsSource::Url((
g1_url,
g2_url,
)) => proto::eigen_config::PointsSource::Url(proto::Url {
g1_url: Some(g1_url.clone()),
g2_url: Some(g2_url.clone()),
}),
}),
}),
ObjectStore(config) => proto::data_availability_client::Config::ObjectStore(
object_store_proto::ObjectStore::build(config),
Expand Down
12 changes: 9 additions & 3 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,22 @@ message CelestiaConfig {
optional uint64 timeout_ms = 4;
}

message Url {
optional string g1_url = 1;
optional string g2_url = 2;
}

message EigenConfig {
optional string disperser_rpc = 3;
optional uint32 settlement_layer_confirmation_depth = 4;
optional string eigenda_eth_rpc = 5;
optional string eigenda_svc_manager_address = 6;
optional bool wait_for_finalization = 7;
optional bool authenticated = 8;
optional string g1_url = 9;
optional string g2_url = 10;
optional string points_dir = 11;
oneof points_source {
string path = 9;
Url url = 10;
}
reserved 1,2;
reserved "rpc_node_url","inclusion_polling_interval_ms";
}
Expand Down
12 changes: 6 additions & 6 deletions core/node/da_clients/src/eigen/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod tests {
use zksync_da_client::{types::DispatchResponse, DataAvailabilityClient};
use zksync_types::secrets::PrivateKey;

use crate::eigen::{blob_info::BlobInfo, EigenClient, GetBlobData};
use crate::eigen::{blob_info::BlobInfo, test_eigenda_config, EigenClient, GetBlobData};

impl EigenClient {
async fn get_blob_data(&self, blob_id: BlobInfo) -> anyhow::Result<Vec<u8>> {
Expand Down Expand Up @@ -157,7 +157,7 @@ mod tests {
#[tokio::test]
#[file_serial]
async fn test_non_auth_dispersal() {
let config = EigenConfig::default();
let config = test_eigenda_config();
let secrets = test_secrets();
let client = EigenClient::new(config.clone(), secrets, Arc::new(MockGetBlobData))
.await
Expand All @@ -184,7 +184,7 @@ mod tests {
async fn test_auth_dispersal() {
let config = EigenConfig {
authenticated: true,
..EigenConfig::default()
..test_eigenda_config()
};
let secrets = test_secrets();
let client = EigenClient::new(config.clone(), secrets, Arc::new(MockGetBlobData))
Expand Down Expand Up @@ -213,7 +213,7 @@ mod tests {
let config = EigenConfig {
wait_for_finalization: true,
authenticated: true,
..EigenConfig::default()
..test_eigenda_config()
};
let secrets = test_secrets();

Expand Down Expand Up @@ -242,7 +242,7 @@ mod tests {
async fn test_settlement_layer_confirmation_depth() {
let config = EigenConfig {
settlement_layer_confirmation_depth: 5,
..EigenConfig::default()
..test_eigenda_config()
};
let secrets = test_secrets();
let client = EigenClient::new(config.clone(), secrets, Arc::new(MockGetBlobData))
Expand Down Expand Up @@ -271,7 +271,7 @@ mod tests {
let config = EigenConfig {
settlement_layer_confirmation_depth: 5,
authenticated: true,
..EigenConfig::default()
..test_eigenda_config()
};
let secrets = test_secrets();
let client = EigenClient::new(config.clone(), secrets, Arc::new(MockGetBlobData))
Expand Down
21 changes: 21 additions & 0 deletions core/node/da_clients/src/eigen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,24 @@ pub(crate) mod disperser {
pub(crate) mod common {
include!("generated/common.rs");
}

#[cfg(test)]
pub fn test_eigenda_config() -> zksync_config::EigenConfig {
use std::str::FromStr;

zksync_config::EigenConfig {
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
settlement_layer_confirmation_depth: 0,
eigenda_eth_rpc: Some(zksync_basic_types::url::SensitiveUrl::from_str("https://ethereum-holesky-rpc.publicnode.com").unwrap()), // Safe to unwrap, never fails
eigenda_svc_manager_address: zksync_basic_types::H160([
0xd4, 0xa7, 0xe1, 0xbd, 0x80, 0x15, 0x05, 0x72, 0x93, 0xf0, 0xd0, 0xa5, 0x57, 0x08, 0x8c,
0x28, 0x69, 0x42, 0xe8, 0x4b,
]), // DEFAULT_EIGENDA_SVC_MANAGER_ADDRESS
wait_for_finalization: false,
authenticated: false,
points_source: zksync_config::configs::da_client::eigen::PointsSource::Url((
"https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
"https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".to_string(),
))
}
}
8 changes: 4 additions & 4 deletions core/node/da_clients/src/eigen/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) struct RawEigenClient {
private_key: SecretKey,
pub config: EigenConfig,
verifier: Verifier,
get_blob_data: Arc<dyn GetBlobData>,
blob_data_provider: Arc<dyn GetBlobData>,
}

pub(crate) const DATA_CHUNK_SIZE: usize = 32;
Expand Down Expand Up @@ -70,7 +70,7 @@ impl RawEigenClient {
private_key,
config: cfg,
verifier,
get_blob_data,
blob_data_provider: get_blob_data,
})
}

Expand Down Expand Up @@ -161,7 +161,7 @@ impl RawEigenClient {
.map_err(|e| anyhow::anyhow!("Failed to convert blob info: {}", e))?;

let data = self.get_blob_data(blob_info.clone()).await?;
let data_db = self.get_blob_data.get_blob_data(request_id).await?;
let data_db = self.blob_data_provider.get_blob_data(request_id).await?;
if let Some(data_db) = data_db {
if data_db != data {
return Err(anyhow::anyhow!(
Expand All @@ -177,9 +177,9 @@ impl RawEigenClient {
.verifier
.verify_inclusion_data_against_settlement_layer(&blob_info)
.await;
// in case of an error, the dispatcher will retry, so the need to return None
if let Err(e) = result {
match e {
// in case of an error, the dispatcher will retry, so the need to return None
VerificationError::EmptyHash => return Ok(None),
_ => return Err(anyhow::anyhow!("Failed to verify inclusion data: {:?}", e)),
}
Expand Down
Loading
Loading