Skip to content

Commit

Permalink
Remove todos
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Nov 20, 2024
1 parent d252a4d commit c0c3378
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 10 deletions.
2 changes: 2 additions & 0 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub struct EigenConfig {
pub verify_cert: bool,
/// Path to the file containing the points used for KZG
pub path_to_points: String,
/// Chain ID of the Ethereum network
pub chain_id: u64,
}

#[derive(Clone, Debug, PartialEq)]
Expand Down
2 changes: 2 additions & 0 deletions core/lib/env_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ mod tests {
DA_AUTHENTICATED=false
DA_VERIFY_CERT=false
DA_PATH_TO_POINTS="resources"
DA_CHAIN_ID=1
"#;
lock.set_env(config);

Expand All @@ -278,6 +279,7 @@ mod tests {
authenticated: false,
verify_cert: false,
path_to_points: "resources".to_string(),
chain_id: 1
})
);
}
Expand Down
2 changes: 2 additions & 0 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl ProtoRepr for proto::DataAvailabilityClient {
path_to_points: required(&conf.path_to_points)
.context("path_to_points")?
.clone(),
chain_id: *required(&conf.chain_id).context("chain_id")?,
}),
proto::data_availability_client::Config::ObjectStore(conf) => {
ObjectStore(object_store_proto::ObjectStore::read(conf)?)
Expand Down Expand Up @@ -125,6 +126,7 @@ impl ProtoRepr for proto::DataAvailabilityClient {
authenticated: Some(config.authenticated),
verify_cert: Some(config.verify_cert),
path_to_points: Some(config.path_to_points.clone()),
chain_id: Some(config.chain_id),
}),
ObjectStore(config) => proto::data_availability_client::Config::ObjectStore(
object_store_proto::ObjectStore::build(config),
Expand Down
1 change: 1 addition & 0 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ message EigenConfig {
optional bool authenticated = 11;
optional bool verify_cert = 12;
optional string path_to_points = 13;
optional uint64 chain_id = 14;
}

message DataAvailabilityClient {
Expand Down
6 changes: 6 additions & 0 deletions core/node/da_clients/src/eigen/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ mod tests {
authenticated: false,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
private_key: PrivateKey::from_str(
Expand Down Expand Up @@ -151,6 +152,7 @@ mod tests {
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
private_key: PrivateKey::from_str(
Expand Down Expand Up @@ -190,6 +192,7 @@ mod tests {
eth_confirmation_depth: 0,
eigenda_eth_rpc: "https://ethereum-holesky-rpc.publicnode.com".to_string(),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
private_key: PrivateKey::from_str(
Expand Down Expand Up @@ -228,6 +231,7 @@ mod tests {
eth_confirmation_depth: 0,
eigenda_eth_rpc: "https://ethereum-holesky-rpc.publicnode.com".to_string(),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
private_key: PrivateKey::from_str(
Expand Down Expand Up @@ -262,6 +266,7 @@ mod tests {
authenticated: false,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
private_key: PrivateKey::from_str(
Expand Down Expand Up @@ -301,6 +306,7 @@ mod tests {
authenticated: true,
verify_cert: true,
path_to_points: "../../../resources".to_string(),
chain_id: 17000,
};
let secrets = EigenSecrets {
private_key: PrivateKey::from_str(
Expand Down
1 change: 1 addition & 0 deletions core/node/da_clients/src/eigen/eigenda-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ da_client:
authenticated: false
verify_cert: true
path_to_points: ./resources
chain_id: <your_chain_id>
```
Also set the private key in `etc/env/file_based/secrets.yaml`:
Expand Down
2 changes: 2 additions & 0 deletions core/node/da_clients/src/eigen/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ impl RawEigenClient {
max_blob_size: config.blob_size_limit,
path_to_points: config.path_to_points.clone(),
eth_confirmation_depth: config.eth_confirmation_depth.max(0) as u32,
private_key: hex::encode(private_key.secret_bytes()),
chain_id: config.chain_id,
};
let verifier = Verifier::new(verifier_config)
.map_err(|e| anyhow::anyhow!(format!("Failed to create verifier {:?}", e)))?;
Expand Down
45 changes: 35 additions & 10 deletions core/node/da_clients/src/eigen/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub struct VerifierConfig {
pub max_blob_size: u32,
pub path_to_points: String,
pub eth_confirmation_depth: u32,
pub private_key: String,
pub chain_id: u64,
}

/// Verifier used to verify the integrity of the blob info
Expand All @@ -54,6 +56,12 @@ pub struct Verifier {
}

impl Verifier {
const DEFAULT_PRIORITY_FEE_PER_GAS: u64 = 100;
#[cfg(test)]
const FILE_PATH: &str = "./src/eigen/generated/EigenDAServiceManager.json";

#[cfg(not(test))]
const FILE_PATH: &str = "./core/node/da_clients/src/eigen/generated/EigenDAServiceManager.json";
pub fn new(cfg: VerifierConfig) -> Result<Self, VerificationError> {
let srs_points_to_load = cfg.max_blob_size / 32;
let kzg = Kzg::setup(
Expand All @@ -76,20 +84,19 @@ impl Verifier {
let client = Box::new(client) as Box<DynClient<L1>>;
let signing_client = PKSigningClient::new_raw(
K256PrivateKey::from_bytes(
zksync_types::H256::from_str(
"0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6", // todo
)
.map_err(|_| VerificationError::ServiceManagerError)?,
zksync_types::H256::from_str(&cfg.private_key)
.map_err(|_| VerificationError::ServiceManagerError)?,
)
.map_err(|_| VerificationError::ServiceManagerError)?, //tms_private_key.clone(),
.map_err(|_| VerificationError::ServiceManagerError)?,
H160::from_str(&cfg.svc_manager_addr)
.map_err(|_| VerificationError::ServiceManagerError)?, // self.contracts_config.diamond_proxy_addr,
100, // self.config.default_priority_fee_per_gas,
SLChainId(17000), //chain id
.map_err(|_| VerificationError::ServiceManagerError)?,
Self::DEFAULT_PRIORITY_FEE_PER_GAS,
SLChainId(cfg.chain_id),
client,
);
let file = File::open("./src/eigen/generated/EigenDAServiceManager.json") // todo
.map_err(|_| VerificationError::ServiceManagerError)?;

let file =
File::open(Self::FILE_PATH).map_err(|_| VerificationError::ServiceManagerError)?;
let reader = BufReader::new(file);
let contract =
Contract::load(reader).map_err(|_| VerificationError::ServiceManagerError)?;
Expand Down Expand Up @@ -503,6 +510,9 @@ mod test {
max_blob_size: 2 * 1024 * 1024,
path_to_points: "../../../resources".to_string(),
eth_confirmation_depth: 0,
private_key: "0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6"
.to_string(),
chain_id: 17000,
})
.unwrap();
let commitment = G1Commitment {
Expand All @@ -529,6 +539,9 @@ mod test {
max_blob_size: 2 * 1024 * 1024,
path_to_points: "../../../resources".to_string(),
eth_confirmation_depth: 0,
private_key: "0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6"
.to_string(),
chain_id: 17000,
})
.unwrap();
let cert = BlobInfo {
Expand Down Expand Up @@ -616,6 +629,9 @@ mod test {
max_blob_size: 2 * 1024 * 1024,
path_to_points: "../../../resources".to_string(),
eth_confirmation_depth: 0,
private_key: "0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6"
.to_string(),
chain_id: 17000,
})
.unwrap();
let blob_header = BlobHeader {
Expand Down Expand Up @@ -659,6 +675,9 @@ mod test {
max_blob_size: 2 * 1024 * 1024,
path_to_points: "../../../resources".to_string(),
eth_confirmation_depth: 0,
private_key: "0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6"
.to_string(),
chain_id: 17000,
})
.unwrap();

Expand All @@ -685,6 +704,9 @@ mod test {
max_blob_size: 2 * 1024 * 1024,
path_to_points: "../../../resources".to_string(),
eth_confirmation_depth: 0,
private_key: "0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6"
.to_string(),
chain_id: 17000,
})
.unwrap();
let cert = BlobInfo {
Expand Down Expand Up @@ -772,6 +794,9 @@ mod test {
max_blob_size: 2 * 1024 * 1024,
path_to_points: "../../../resources".to_string(),
eth_confirmation_depth: 0,
private_key: "0xd08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6"
.to_string(),
chain_id: 17000,
})
.unwrap();
let cert = BlobInfo {
Expand Down

0 comments on commit c0c3378

Please sign in to comment.