Skip to content

Commit

Permalink
Change string to address
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Dec 17, 2024
1 parent 26a5546 commit 6dd94d4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::Deserialize;
use zksync_basic_types::secrets::PrivateKey;
use zksync_basic_types::{secrets::PrivateKey, Address};
/// Configuration for the EigenDA remote disperser client.
#[derive(Clone, Debug, PartialEq, Deserialize, Default)]
pub struct EigenConfig {
Expand All @@ -11,7 +11,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 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::Address;
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="0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
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: Address::from_str(
"0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
)
.unwrap(),
wait_for_finalization: true,
authenticated: false,
g1_url: "resources1".to_string(),
Expand Down
12 changes: 8 additions & 4 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,6 +11,7 @@ use zksync_config::configs::{
},
};
use zksync_protobuf::{required, ProtoRepr};
use zksync_types::Address;

use crate::proto::{
da_client::{self as proto},
Expand Down Expand Up @@ -64,9 +67,10 @@ 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(),
eigenda_svc_manager_address: Address::from_str(
required(&conf.eigenda_svc_manager_address)
.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 +120,7 @@ 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(config.eigenda_svc_manager_address.to_string()),
wait_for_finalization: Some(config.wait_for_finalization),
authenticated: Some(config.authenticated),
g1_url: Some(config.g1_url.clone()),
Expand Down
12 changes: 6 additions & 6 deletions core/node/da_clients/src/eigen/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod tests {
types::{DAError, DispatchResponse},
DataAvailabilityClient,
};
use zksync_types::secrets::PrivateKey;
use zksync_types::{secrets::PrivateKey, Address};

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

Expand Down Expand Up @@ -72,7 +72,7 @@ mod tests {
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: Address::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 Expand Up @@ -112,7 +112,7 @@ mod tests {
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: Address::from_str("0xD4A7E1Bd8015057293f0D0A557088c286942e84b").unwrap(),
wait_for_finalization: false,
authenticated: true,
g1_url: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
Expand Down Expand Up @@ -156,7 +156,7 @@ mod tests {
g2_url: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g2.point.powerOf2".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: Address::from_str("0xD4A7E1Bd8015057293f0D0A557088c286942e84b").unwrap(),
chain_id: 17000,
};
let secrets = EigenSecrets {
Expand Down Expand Up @@ -192,7 +192,7 @@ mod tests {
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
settlement_layer_confirmation_depth: 5,
eigenda_eth_rpc: Some("https://ethereum-holesky-rpc.publicnode.com".to_string()),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
eigenda_svc_manager_address:Address::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 Expand Up @@ -232,7 +232,7 @@ mod tests {
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
settlement_layer_confirmation_depth: 5,
eigenda_eth_rpc: Some("https://ethereum-holesky-rpc.publicnode.com".to_string()),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
eigenda_svc_manager_address: Address::from_str("0xD4A7E1Bd8015057293f0D0A557088c286942e84b").unwrap(),
wait_for_finalization: false,
authenticated: true,
g1_url: "https://github.com/Layr-Labs/eigenda-proxy/raw/2fd70b99ef5bf137d7bbca3461cf9e1f2c899451/resources/g1.point".to_string(),
Expand Down
6 changes: 3 additions & 3 deletions core/node/da_clients/src/eigen/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tonic::{
use zksync_config::EigenConfig;
use zksync_da_client::types::DAError;
use zksync_eth_client::clients::PKSigningClient;
use zksync_types::{url::SensitiveUrl, K256PrivateKey, SLChainId, H160};
use zksync_types::{url::SensitiveUrl, K256PrivateKey, SLChainId};
use zksync_web3_decl::client::{Client, DynClient, L1};

use super::{
Expand Down Expand Up @@ -58,7 +58,7 @@ impl<T: GetBlobData> RawEigenClient<T> {
.eigenda_eth_rpc
.clone()
.ok_or(anyhow::anyhow!("EigenDA ETH RPC not set"))?,
svc_manager_addr: config.eigenda_svc_manager_address.clone(),
svc_manager_addr: config.eigenda_svc_manager_address,
max_blob_size: Self::BLOB_SIZE_LIMIT as u32,
g1_url: config.g1_url.clone(),
g2_url: config.g2_url.clone(),
Expand All @@ -74,7 +74,7 @@ impl<T: GetBlobData> RawEigenClient<T> {
K256PrivateKey::from_bytes(zksync_types::H256::from_str(
&verifier_config.private_key,
)?)?,
H160::from_str(&verifier_config.svc_manager_addr)?,
verifier_config.svc_manager_addr,
Verifier::DEFAULT_PRIORITY_FEE_PER_GAS,
SLChainId(verifier_config.chain_id),
query_client,
Expand Down
22 changes: 7 additions & 15 deletions core/node/da_clients/src/eigen/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fs::File, io::copy, path::Path, str::FromStr};
use std::{collections::HashMap, fs::File, io::copy, path::Path};

use ark_bn254::{Fq, G1Affine};
use ethabi::{encode, ParamType, Token};
Expand All @@ -9,7 +9,7 @@ use zksync_basic_types::web3::CallRequest;
use zksync_eth_client::{clients::PKSigningClient, EnrichedClientResult};
use zksync_types::{
web3::{self, BlockId, BlockNumber},
H160, U256, U64,
Address, U256, U64,
};

use super::blob_info::{BatchHeader, BlobHeader, BlobInfo, G1Commitment};
Expand Down Expand Up @@ -68,7 +68,7 @@ pub enum VerificationError {
#[derive(Debug, Clone)]
pub struct VerifierConfig {
pub rpc_url: String,
pub svc_manager_addr: String,
pub svc_manager_addr: Address,
pub max_blob_size: u32,
pub g1_url: String,
pub g2_url: String,
Expand Down Expand Up @@ -342,10 +342,7 @@ impl Verifier {
data.append(batch_id_vec.to_vec().as_mut());

let call_request = CallRequest {
to: Some(
H160::from_str(&self.cfg.svc_manager_addr)
.map_err(|_| VerificationError::ServiceManagerError)?,
),
to: Some(self.cfg.svc_manager_addr),
data: Some(zksync_basic_types::web3::Bytes(data)),
..Default::default()
};
Expand Down Expand Up @@ -445,10 +442,8 @@ impl Verifier {
let data = func_selector.to_vec();

let call_request = CallRequest {
to: Some(
H160::from_str(&self.cfg.svc_manager_addr)
.map_err(|_| VerificationError::ServiceManagerError)?,
),
to: Some(self.cfg.svc_manager_addr),

data: Some(zksync_basic_types::web3::Bytes(data)),
..Default::default()
};
Expand All @@ -474,10 +469,7 @@ impl Verifier {
let func_selector = ethabi::short_signature("quorumNumbersRequired", &[]);
let data = func_selector.to_vec();
let call_request = CallRequest {
to: Some(
H160::from_str(&self.cfg.svc_manager_addr)
.map_err(|_| VerificationError::ServiceManagerError)?,
),
to: Some(self.cfg.svc_manager_addr),
data: Some(zksync_basic_types::web3::Bytes(data)),
..Default::default()
};
Expand Down
8 changes: 3 additions & 5 deletions core/node/da_clients/src/eigen/verifier_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod test {
use zksync_types::{
url::SensitiveUrl,
web3::{BlockId, Bytes, CallRequest},
K256PrivateKey, SLChainId, H160, U64,
Address, K256PrivateKey, SLChainId, H160, U64,
};
use zksync_web3_decl::client::{Client, DynClient, L1};

Expand All @@ -21,7 +21,7 @@ mod test {
fn get_verifier_config() -> VerifierConfig {
VerifierConfig {
rpc_url: "https://ethereum-holesky-rpc.publicnode.com".to_string(),
svc_manager_addr: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
svc_manager_addr: Address::from_str("0xD4A7E1Bd8015057293f0D0A557088c286942e84b").unwrap(),
max_blob_size: 2 * 1024 * 1024,
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(),
Expand Down Expand Up @@ -82,9 +82,7 @@ mod test {
)
.map_err(|_| VerificationError::ServiceManagerError)
.unwrap(),
zksync_types::H160::from_str(&cfg.svc_manager_addr)
.map_err(|_| VerificationError::ServiceManagerError)
.unwrap(),
cfg.svc_manager_addr,
Verifier::DEFAULT_PRIORITY_FEE_PER_GAS,
SLChainId(cfg.chain_id),
query_client,
Expand Down

0 comments on commit 6dd94d4

Please sign in to comment.