Skip to content

Commit

Permalink
replace String type with Address
Browse files Browse the repository at this point in the history
  • Loading branch information
juan518munoz committed Jan 7, 2025
1 parent e7fb0e5 commit aa57afc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
8 changes: 5 additions & 3 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::str::FromStr;

use serde::Deserialize;
use zksync_basic_types::secrets::PrivateKey;
use zksync_basic_types::{secrets::PrivateKey, Address, H160};
/// Configuration for the EigenDA remote disperser client.
#[derive(Clone, Debug, PartialEq, Deserialize)]
pub struct EigenConfig {
Expand All @@ -11,7 +13,7 @@ pub struct EigenConfig {
/// URL of the Ethereum RPC server
pub eigenda_eth_rpc: Option<String>,
/// Address of the service manager contract
pub eigenda_svc_manager_address: String,
pub eigenda_svc_manager_address: Address,
/// Wait for the blob to be finalized before returning the response
pub wait_for_finalization: bool,
/// Authenticated dispersal
Expand All @@ -30,7 +32,7 @@ impl Default for EigenConfig {
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
settlement_layer_confirmation_depth: 0,
eigenda_eth_rpc: Some("https://ethereum-holesky-rpc.publicnode.com".to_string()),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
eigenda_svc_manager_address: H160::from_str("0xD4A7E1Bd8015057293f0D0A557088c286942e84b").unwrap(),
wait_for_finalization: false,
authenticated: false,
g1_url: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
Expand Down
10 changes: 8 additions & 2 deletions core/lib/env_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ impl FromEnv for DataAvailabilitySecrets {

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

use zksync_basic_types::H160;
use zksync_config::{
configs::{
da_client::{
Expand Down Expand Up @@ -251,7 +254,7 @@ mod tests {
DA_DISPERSER_RPC="http://localhost:8080"
DA_SETTLEMENT_LAYER_CONFIRMATION_DEPTH=0
DA_EIGENDA_ETH_RPC="http://localhost:8545"
DA_EIGENDA_SVC_MANAGER_ADDRESS="0x123"
DA_EIGENDA_SVC_MANAGER_ADDRESS="0x0000000000000000000000000000000000000123"
DA_WAIT_FOR_FINALIZATION=true
DA_AUTHENTICATED=false
DA_G1_URL="resources1"
Expand All @@ -267,7 +270,10 @@ mod tests {
disperser_rpc: "http://localhost:8080".to_string(),
settlement_layer_confirmation_depth: 0,
eigenda_eth_rpc: Some("http://localhost:8545".to_string()),
eigenda_svc_manager_address: "0x123".to_string(),
eigenda_svc_manager_address: H160::from_str(
"0x0000000000000000000000000000000000000123"
)
.unwrap(),
wait_for_finalization: true,
authenticated: false,
g1_url: "resources1".to_string(),
Expand Down
18 changes: 12 additions & 6 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ use zksync_config::configs::{
};
use zksync_protobuf::{required, ProtoRepr};

use crate::proto::{
da_client::{self 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 {
Expand Down Expand Up @@ -65,8 +68,8 @@ impl ProtoRepr for proto::DataAvailabilityClient {
.context("settlement_layer_confirmation_depth")?,
eigenda_eth_rpc: required(&conf.eigenda_eth_rpc).ok().cloned(),
eigenda_svc_manager_address: required(&conf.eigenda_svc_manager_address)
.context("eigenda_svc_manager_address")?
.clone(),
.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")?,
Expand Down Expand Up @@ -116,7 +119,10 @@ impl ProtoRepr for proto::DataAvailabilityClient {
config.settlement_layer_confirmation_depth,
),
eigenda_eth_rpc: config.eigenda_eth_rpc.clone(),
eigenda_svc_manager_address: Some(config.eigenda_svc_manager_address.clone()),
eigenda_svc_manager_address: Some(format!(
"{:?}",
config.eigenda_svc_manager_address
)),
wait_for_finalization: Some(config.wait_for_finalization),
authenticated: Some(config.authenticated),
g1_url: Some(config.g1_url.clone()),
Expand Down
4 changes: 2 additions & 2 deletions core/node/da_clients/src/eigen/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use url::Url;
use zksync_config::EigenConfig;
use zksync_da_client::types::DAError;
use zksync_eth_client::clients::PKSigningClient;
use zksync_types::{url::SensitiveUrl, Address, K256PrivateKey, SLChainId};
use zksync_types::{url::SensitiveUrl, K256PrivateKey, SLChainId};
use zksync_web3_decl::client::{Client, DynClient, L1};

use super::{
Expand Down Expand Up @@ -60,7 +60,7 @@ impl RawEigenClient {
.eigenda_eth_rpc
.clone()
.ok_or(anyhow::anyhow!("EigenDA ETH RPC not set"))?,
svc_manager_addr: Address::from_str(&config.eigenda_svc_manager_address)?,
svc_manager_addr: config.eigenda_svc_manager_address,
max_blob_size: Self::BLOB_SIZE_LIMIT as u32,
g1_url: Url::parse(&config.g1_url)?,
g2_url: Url::parse(&config.g2_url)?,
Expand Down
1 change: 0 additions & 1 deletion core/node/da_clients/src/eigen/verifier_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ mod test {

#[async_trait::async_trait]
impl VerifierClient for MockVerifierClient {

async fn block_number(&self) -> EnrichedClientResult<U64> {
Ok(U64::from(42))
}
Expand Down

0 comments on commit aa57afc

Please sign in to comment.