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(eigenda): implement eigenDA client remaining features #3243

Open
wants to merge 133 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
fcecc81
add integration doc
juan518munoz Oct 31, 2024
2bcf78f
Reimplement eigen config (#320)
gianbelinche Nov 1, 2024
537cf92
feat(eigen-client-extra-feature): rlp encoding (#319)
juan518munoz Nov 1, 2024
f58e0bf
feat(eigen-client-extra-features): non auth dispersal (#318)
juan518munoz Nov 1, 2024
04b93e6
initial commit
juan518munoz Nov 1, 2024
c121eca
add spaces
juan518munoz Nov 1, 2024
4a38ee2
Revert wrong push
juan518munoz Nov 1, 2024
e64cc2e
initial commit
juan518munoz Nov 1, 2024
5b8665b
Merge pull request #324 from lambdaclass/eigen-client-get-inclusion-data
juanbono Nov 1, 2024
aa9f1b2
fix(eigen-client-extra-features): fix eigen config test (#323)
juan518munoz Nov 4, 2024
e033630
feat(eigen-client-extra-features): Eigen client memstore (#321)
gianbelinche Nov 5, 2024
b164870
feat(eigen-client-extra-features): blob size limit (#325)
juan518munoz Nov 5, 2024
f95bc1b
feat(eigen-client-extra-features): Add soft confirmations (#322)
gianbelinche Nov 5, 2024
9c06b40
feat(eigen-client-extra-features): Verifier (#326)
gianbelinche Nov 5, 2024
3b9e766
feat(eigen-client-extra-features): Eigen client documentation (#327)
juan518munoz Nov 5, 2024
6668ab9
feat(eigen-client-extra-features): Eth confirmation depth (#328)
gianbelinche Nov 7, 2024
cc9e2be
feat(eigen-client-extra-features): Remove unused custom quorum number…
gianbelinche Nov 7, 2024
9769a17
doc & cargo check all
juan518munoz Nov 7, 2024
91bb79b
clippy
juan518munoz Nov 7, 2024
cbe124e
Merge branch 'main' into eigen-client-merge-main
juan518munoz Nov 7, 2024
9c73b3f
update contracts submodule
juan518munoz Nov 7, 2024
94ecb52
Merge pull request #330 from lambdaclass/eigen-client-clippy-and-doc
juanbono Nov 8, 2024
342b476
Merge pull request #331 from lambdaclass/eigen-client-merge-main
juanbono Nov 8, 2024
077bc13
Merge branch 'main' into eigen-client-extra-features
juanbono Nov 8, 2024
c98726a
Update integration readme (#335)
gianbelinche Nov 11, 2024
991c340
update contracts submodule
juan518munoz Nov 12, 2024
f55a424
Merge pull request #337 from lambdaclass/eigen-client-contracts-submo…
juanbono Nov 12, 2024
f2fb12c
feat(eigen-client-extra-features): Remove kzgpad (#339)
gianbelinche Nov 15, 2024
b825d4f
Create eigendaservicemanager type (#340)
gianbelinche Nov 15, 2024
9561bc3
Change match to if (#341)
gianbelinche Nov 15, 2024
986a1d2
feat(eigen-client-eigen-features): Move dependencies (#342)
gianbelinche Nov 15, 2024
09ecfdd
feat(eigen-client-extra-features): Backon (#344)
gianbelinche Nov 19, 2024
a2ddcc3
Remove memstore (#346)
gianbelinche Nov 19, 2024
7d369a8
Add reserved to proto (#343)
gianbelinche Nov 21, 2024
a9c31a7
Remove extra config (#351)
gianbelinche Nov 21, 2024
6e1de82
feat(eigen-client-extra-features): Kzg bn254 crate (#352)
gianbelinche Nov 21, 2024
8d0b908
feat(eigen-client-extra-features): Remove Alloy Dependency (#349)
gianbelinche Nov 21, 2024
28c826c
Merge branch 'main' into eigen-client-extra-features-merge-main
gianbelinche Nov 22, 2024
68abc97
Fix cargo lock
gianbelinche Nov 22, 2024
99b153a
Merge pull request #354 from lambdaclass/eigen-client-extra-features-…
gianbelinche Nov 22, 2024
01b50ed
feat(eigen-client-extra-features): Move inclusion logic (#357)
gianbelinche Nov 28, 2024
daace34
feat(eigen-client-extra-features): Remove verify cert (#359)
gianbelinche Nov 28, 2024
99c6d42
feat(eigen-client-extra-features): Small changes (#358)
gianbelinche Nov 28, 2024
163c41a
feat(eigen-client-extra-features): minimal client changes (#362)
juan518munoz Nov 28, 2024
cef9a89
feat(eigen-client-extra-features): Add option to download points (#361)
gianbelinche Nov 28, 2024
75090b6
feat(eigen-client-extra-features): Replace third party dependant test…
juan518munoz Nov 28, 2024
7a61574
feat(eigen-client-extra-features): Remove steps to run from integrati…
gianbelinche Nov 28, 2024
bc90cc6
Merge branch 'main' into eigen-client-extra-features-and-main
gianbelinche Nov 28, 2024
87d450f
Update Cargo.lock
gianbelinche Nov 28, 2024
e2d4dab
Merge pull request #363 from lambdaclass/eigen-client-extra-features-…
gianbelinche Nov 29, 2024
4d1fadb
Merge branch 'main' into eigen-client-extra-features
juanbono Dec 3, 2024
4bb08b9
feat(eigen-client-pr-comments): Eigen client pr comments (#365)
gianbelinche Dec 6, 2024
0d01df7
Remove points (#366)
gianbelinche Dec 6, 2024
2100256
Merge branch 'main' into eigen-client-extra-features
gianbelinche Dec 6, 2024
83c3e13
Merge pull request #367 from lambdaclass/eigen-client-extra-main
gianbelinche Dec 6, 2024
fe8f68c
feat(eigen-client-extra-features): Fix PR comments (#369)
gianbelinche Dec 11, 2024
64a08bc
Merge branch 'main' into eigen-client-extra-features
gianbelinche Dec 11, 2024
8395cca
Cargo lock conflicts
gianbelinche Dec 11, 2024
f2d7941
Merge pull request #370 from lambdaclass/eigen-client-extra-main-merged
gianbelinche Dec 11, 2024
4b3c059
Solve comments (#372)
gianbelinche Dec 12, 2024
93b94b2
feat(eigen-client-extra-features): address PR comments (#375)
gianbelinche Dec 19, 2024
068f90f
Merge branch 'main' into eigen-client-extra-features
juanbono Jan 6, 2025
9e1ebfa
fix(eigen-client-extra-features): address comments (#383)
juan518munoz Jan 13, 2025
c007aa8
use `H160` for `DEFAULT_EIGENDA_SVC_MANAGER_ADDRESS`
juan518munoz Jan 17, 2025
2e7d6cc
`parse` instead of `from_str`
juan518munoz Jan 17, 2025
405b413
replace val with shif operation
juan518munoz Jan 17, 2025
9b6fe48
replace `.map_err` with `.context`
juan518munoz Jan 17, 2025
5a144ad
remove needless parentheses
juan518munoz Jan 17, 2025
2431a0c
use `div_ceil`
juan518munoz Jan 17, 2025
a880375
remove needles `Clone` derives
juan518munoz Jan 17, 2025
801aca6
remove redundant `to_vec()`
juan518munoz Jan 17, 2025
cd4c631
use `anyhow::bail!`
juan518munoz Jan 17, 2025
68825c4
remove needless `Option` and obscuring `anyhow::Result`
juan518munoz Jan 17, 2025
e3b6f17
move verifier test to separate file
juan518munoz Jan 17, 2025
2bded08
replace u64 constant with Duration
juan518munoz Jan 17, 2025
12d29c7
use `ethabi::encode()`
juan518munoz Jan 17, 2025
351d5a8
refactor `decode_bytes`
juan518munoz Jan 17, 2025
d312b51
wrap `G1Affine` inside of `Box` / fix clippy
juan518munoz Jan 17, 2025
57f608e
use `SensitiveUrl` for `eigenda_eth_rpc`
juan518munoz Jan 17, 2025
1832819
refactor `save_point` fn
juan518munoz Jan 17, 2025
3a97228
remove retriable error wrapping
juan518munoz Jan 17, 2025
5c4309d
replace `PKSigningClient` for simpler L1 Client
juan518munoz Jan 17, 2025
a66e9eb
remove chain id from `EigenConfig`
juan518munoz Jan 17, 2025
c89d8c2
use temp dir for kzg points
juan518munoz Jan 20, 2025
2880367
refactor `VerifierClient` trait
juan518munoz Jan 21, 2025
5a7e533
remove `VerifierConfig`
juan518munoz Jan 21, 2025
87d5e0d
fix eigen config not initializing correctly
juan518munoz Jan 21, 2025
ab6a374
merge branch `main` into `eigen-client-extra-features`
juan518munoz Jan 21, 2025
c3cb48c
fix/refactor mock tests
juan518munoz Jan 22, 2025
de8ad1a
remove unwraps
juan518munoz Jan 22, 2025
c476920
address comments/suggestions
juan518munoz Jan 22, 2025
d64acd2
improve Error handling
juan518munoz Jan 22, 2025
709adca
Merge branch 'eigen-client-extra-features-address-comments-third' int…
juan518munoz Jan 23, 2025
0b1397e
create temp file inside closure
juan518munoz Jan 23, 2025
e2ae59c
Merge branch 'eigen-client-extra-features-address-comments-third' int…
juan518munoz Jan 23, 2025
d3f1faf
Merge branch 'main' into eigen-client-extra-features-merge-main
juan518munoz Jan 23, 2025
bfcd206
add EigenDA to validium init cfg
juan518munoz Jan 24, 2025
278975c
update contracts submodule
juan518munoz Jan 24, 2025
56cda84
Remove unnecessary clone
gianbelinche Jan 27, 2025
cfba485
add eigenda validator
juan518munoz Jan 27, 2025
b0b080d
address comments
juan518munoz Jan 27, 2025
efdf1b4
address comments
juan518munoz Jan 28, 2025
2587277
update yarn.lock
juan518munoz Jan 28, 2025
28de691
change `path()` fn to return `&std::path::Path`
juan518munoz Jan 28, 2025
1870c2a
replace `Path(String)` for `Path(PathBuf)`
juan518munoz Jan 28, 2025
b68a43e
Merge branch 'eigen-client-extra-features-address-comments-third' int…
juan518munoz Jan 28, 2025
0575785
feat(eigen-cllient-extra-features): Address more comments (#386)
juan518munoz Jan 28, 2025
51e88d3
Merge remote-tracking branch 'origin/eigen-client-extra-features' int…
juan518munoz Jan 28, 2025
b33700b
run linter
juan518munoz Jan 28, 2025
2080f16
update genesis.yaml hashes
juan518munoz Jan 28, 2025
1273ed2
Merge pull request #387 from lambdaclass/eigen-client-extra-features-…
juan518munoz Jan 29, 2025
889b513
Merge branch 'main' into eigen-client-extra-features-merge
gianbelinche Jan 30, 2025
efa3a4b
Fix conflicts
gianbelinche Jan 30, 2025
9075650
Remove bad merge
gianbelinche Jan 30, 2025
f60bbf5
Update da validator type
gianbelinche Jan 30, 2025
da3fd9e
Fix error
gianbelinche Jan 30, 2025
2116030
Merge pull request #389 from lambdaclass/eigen-client-extra-features-…
gianbelinche Jan 30, 2025
d6eb001
Merge branch 'main' into eigen-client-extra-features-update-contracts
gianbelinche Feb 4, 2025
e17b879
Update contracts
gianbelinche Feb 4, 2025
ca4f11a
Merge pull request #394 from lambdaclass/eigen-client-extra-features-…
gianbelinche Feb 4, 2025
34df5ff
feat(eigen-client-extra-features): address comments (#395)
juan518munoz Feb 7, 2025
34e21b5
merge main
juan518munoz Feb 10, 2025
bdcb268
Merge pull request #396 from lambdaclass/eigen-client-extra-features-…
juan518munoz Feb 10, 2025
f0093c5
fix query
juan518munoz Feb 10, 2025
9810b37
suggestion
juan518munoz Feb 11, 2025
3c2e049
fix suggestion
juan518munoz Feb 11, 2025
b7306cc
fix hashes
juan518munoz Feb 12, 2025
c1936c3
Fix cargo deny (#398)
gianbelinche Feb 12, 2025
92b1ca6
Merge pull request #399 from lambdaclass/eigen-client-extra-features-…
juan518munoz Feb 12, 2025
ed37e47
Merge branch 'main' into eigen-client-extra-features
gianbelinche Feb 12, 2025
e5108bf
Format code
gianbelinche Feb 12, 2025
04a6bf4
feat(extra-features): Remove validators (#400)
gianbelinche Feb 13, 2025
1f79c36
Merge branch 'main' into eigen-client-extra-features
juanbono Feb 14, 2025
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
274 changes: 274 additions & 0 deletions core/Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ pbjson-types = "0.6.0"

# Eigen
tokio-stream = "0.1.16"
rust-kzg-bn254 = "0.2.1"
ark-bn254 = "0.5.0"
num-bigint = "0.4.6"
serial_test = { version = "3.1.1", features = ["file_locks"] }

# Here and below:
# We *always* pin the latest version of protocol to disallow accidental changes in the execution logic.
Expand Down
6 changes: 5 additions & 1 deletion core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ impl MainNodeBuilder {
}

let secrets = try_load_config!(self.secrets.data_availability);
let l1_secrets = try_load_config!(self.secrets.l1);
match (da_client_config, secrets) {
(DAClientConfig::Avail(config), DataAvailabilitySecrets::Avail(secret)) => {
self.node.add_layer(AvailWiringLayer::new(config, secret));
Expand All @@ -579,7 +580,10 @@ impl MainNodeBuilder {
.add_layer(CelestiaWiringLayer::new(config, secret));
}

(DAClientConfig::Eigen(config), DataAvailabilitySecrets::Eigen(secret)) => {
(DAClientConfig::Eigen(mut config), DataAvailabilitySecrets::Eigen(secret)) => {
if config.eigenda_eth_rpc.is_none() {
config.eigenda_eth_rpc = Some(l1_secrets.l1_rpc_url);
}
self.node.add_layer(EigenWiringLayer::new(config, secret));
}

Expand Down
29 changes: 25 additions & 4 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
use serde::Deserialize;
use zksync_basic_types::secrets::PrivateKey;
use zksync_basic_types::{secrets::PrivateKey, url::SensitiveUrl, Address};

#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
#[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)]
pub struct EigenConfig {
pub rpc_node_url: String,
pub inclusion_polling_interval_ms: u64,
/// URL of the Disperser RPC server
pub disperser_rpc: String,
slowli marked this conversation as resolved.
Show resolved Hide resolved
/// 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 settlement_layer_confirmation_depth: u32,
/// URL of the Ethereum RPC server
pub eigenda_eth_rpc: Option<SensitiveUrl>,
/// Address of the service manager contract
pub eigenda_svc_manager_address: Address,
/// Wait for the blob to be finalized before returning the response
pub wait_for_finalization: bool,
/// Authenticated dispersal
pub authenticated: bool,
/// 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.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX idx_blob_id_l1_batch_number ON data_availability (blob_id, l1_batch_number);
40 changes: 40 additions & 0 deletions core/lib/dal/src/data_availability_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,44 @@ impl DataAvailabilityDal<'_, '_> {
})
.collect())
}

/// Fetches the pubdata for the L1 batch with a given blob id.
pub async fn get_blob_data_by_blob_id(
&mut self,
blob_id: &str,
) -> DalResult<Option<L1BatchDA>> {
let row = sqlx::query!(
r#"
SELECT
number,
pubdata_input,
sealed_at
FROM
l1_batches
LEFT JOIN
data_availability
ON data_availability.l1_batch_number = l1_batches.number
WHERE
number != 0
AND data_availability.blob_id = $1
slowli marked this conversation as resolved.
Show resolved Hide resolved
ORDER BY
number
LIMIT
1
"#,
blob_id,
)
.instrument("get_blob_data_by_blob_id")
.with_arg("blob_id", &blob_id)
.fetch_optional(self.storage)
.await?
.map(|row| L1BatchDA {
// `unwrap` is safe here because we have a `WHERE` clause that filters out `NULL` values
pubdata: row.pubdata_input.unwrap(),
l1_batch_number: L1BatchNumber(row.number as u32),
sealed_at: row.sealed_at.unwrap().and_utc(),
});

Ok(row)
}
}
82 changes: 66 additions & 16 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, NO_DA_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, NO_DA_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,35 @@ 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")?,
dimazhornyk marked this conversation as resolved.
Show resolved Hide resolved
settlement_layer_confirmation_depth: env::var(
"DA_SETTLEMENT_LAYER_CONFIRMATION_DEPTH",
)?
.parse()?,
eigenda_eth_rpc: match env::var("DA_EIGENDA_ETH_RPC") {
// Use a specific L1 RPC URL for the EigenDA client.
Ok(url) => Some(SensitiveUrl::from_str(&url)?),
// Err means that the environment variable is not set.
// Use zkSync default L1 RPC for the EigenDA client.
Err(_) => None,
},
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 @@ -87,10 +120,14 @@ impl FromEnv for DataAvailabilitySecrets {

#[cfg(test)]
mod tests {
use std::str::FromStr;

use zksync_basic_types::url::SensitiveUrl;
use zksync_config::{
configs::{
da_client::{
avail::{AvailClientConfig, AvailDefaultConfig},
eigen::PointsSource,
DAClientConfig::{self, ObjectStore},
},
object_store::ObjectStoreMode::GCS,
Expand Down Expand Up @@ -244,17 +281,30 @@ mod tests {
let mut lock = MUTEX.lock();
let config = r#"
DA_CLIENT="Eigen"
DA_RPC_NODE_URL="localhost:12345"
DA_INCLUSION_POLLING_INTERVAL_MS="1000"
DA_DISPERSER_RPC="http://localhost:8080"
DA_SETTLEMENT_LAYER_CONFIRMATION_DEPTH=0
DA_EIGENDA_ETH_RPC="http://localhost:8545"
DA_EIGENDA_SVC_MANAGER_ADDRESS="0x0000000000000000000000000000000000000123"
DA_WAIT_FOR_FINALIZATION=true
DA_AUTHENTICATED=false
DA_POINTS_SOURCE="Path"
DA_POINTS_PATH="resources"
"#;
lock.set_env(config);

let actual = DAClientConfig::from_env().unwrap();
assert_eq!(
actual,
DAClientConfig::Eigen(EigenConfig {
rpc_node_url: "localhost:12345".to_string(),
inclusion_polling_interval_ms: 1000,
disperser_rpc: "http://localhost:8080".to_string(),
settlement_layer_confirmation_depth: 0,
eigenda_eth_rpc: Some(SensitiveUrl::from_str("http://localhost:8545").unwrap()),
eigenda_svc_manager_address: "0x0000000000000000000000000000000000000123"
.parse()
.unwrap(),
wait_for_finalization: true,
authenticated: false,
points_source: PointsSource::Path("resources".to_string()),
})
);
}
Expand Down
3 changes: 1 addition & 2 deletions core/lib/env_config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use anyhow::Context as _;
use serde::de::DeserializeOwned;

mod api;
Expand Down Expand Up @@ -44,5 +43,5 @@ pub trait FromEnv: Sized {
pub fn envy_load<T: DeserializeOwned>(name: &str, prefix: &str) -> anyhow::Result<T> {
envy::prefixed(prefix)
.from_env()
.with_context(|| format!("Cannot load config <{name}>"))
.map_err(|e| anyhow::anyhow!("Failed to load {} from env: {}", name, e))
}
72 changes: 65 additions & 7 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::str::FromStr;

use anyhow::Context;
use zksync_config::configs::{
self,
Expand All @@ -9,8 +11,15 @@ use zksync_config::configs::{
},
};
use zksync_protobuf::{required, ProtoRepr};
use zksync_types::url::SensitiveUrl;

use crate::proto::{da_client as proto, object_store as object_store_proto};
use crate::{
parse_h160,
proto::{
da_client::{self as proto},
object_store as object_store_proto,
},
};

impl ProtoRepr for proto::DataAvailabilityClient {
type Type = configs::DAClientConfig;
Expand Down Expand Up @@ -53,11 +62,36 @@ impl ProtoRepr for proto::DataAvailabilityClient {
timeout_ms: *required(&conf.timeout_ms).context("timeout_ms")?,
}),
proto::data_availability_client::Config::Eigen(conf) => Eigen(EigenConfig {
rpc_node_url: required(&conf.rpc_node_url)
.context("rpc_node_url")?
disperser_rpc: required(&conf.disperser_rpc)
.context("disperser_rpc")?
.clone(),
inclusion_polling_interval_ms: *required(&conf.inclusion_polling_interval_ms)
.context("inclusion_polling_interval_ms")?,
settlement_layer_confirmation_depth: *required(
&conf.settlement_layer_confirmation_depth,
)
.context("settlement_layer_confirmation_depth")?,
eigenda_eth_rpc: Some(SensitiveUrl::from_str(
required(&conf.eigenda_eth_rpc).context("eigenda_eth_rpc")?,
)?),
eigenda_svc_manager_address: required(&conf.eigenda_svc_manager_address)
.and_then(|x| parse_h160(x))
.context("eigenda_svc_manager_address")?,
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)) => {
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 @@ -98,8 +132,32 @@ impl ProtoRepr for proto::DataAvailabilityClient {
})
}
Eigen(config) => proto::data_availability_client::Config::Eigen(proto::EigenConfig {
rpc_node_url: Some(config.rpc_node_url.clone()),
inclusion_polling_interval_ms: Some(config.inclusion_polling_interval_ms),
disperser_rpc: Some(config.disperser_rpc.clone()),
settlement_layer_confirmation_depth: Some(
config.settlement_layer_confirmation_depth,
),
eigenda_eth_rpc: config
.eigenda_eth_rpc
.as_ref()
.map(|a| a.expose_str().to_string()),
eigenda_svc_manager_address: Some(format!(
"{:?}",
config.eigenda_svc_manager_address
)),
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.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
Loading
Loading