From c47a0cdba9a0f2d89992ee315690bfd3e14fa5f4 Mon Sep 17 00:00:00 2001 From: Juan Munoz Date: Fri, 22 Nov 2024 15:46:42 -0300 Subject: [PATCH] clippy & doc --- core/node/da_clients/src/eigen/client.rs | 2 +- .../src/eigen/eigenda-integration.md | 5 ++- get_all_blobs/src/blob_info.rs | 27 ++++++------- get_all_blobs/src/client.rs | 4 +- get_all_blobs/src/generated/disperser.rs | 40 +++++++++---------- get_all_blobs/src/main.rs | 7 ++-- 6 files changed, 43 insertions(+), 42 deletions(-) diff --git a/core/node/da_clients/src/eigen/client.rs b/core/node/da_clients/src/eigen/client.rs index a97e173571f3..c8fd45a7dd8b 100644 --- a/core/node/da_clients/src/eigen/client.rs +++ b/core/node/da_clients/src/eigen/client.rs @@ -11,7 +11,7 @@ use zksync_da_client::{ }; use super::{blob_info::BlobInfo, sdk::RawEigenClient}; -use crate::utils::{to_non_retriable_da_error, to_retriable_da_error}; +use crate::utils::to_retriable_da_error; /// EigenClient is a client for the Eigen DA service. /// It can be configured to use one of two dispersal methods: diff --git a/core/node/da_clients/src/eigen/eigenda-integration.md b/core/node/da_clients/src/eigen/eigenda-integration.md index 86f0ccdd1520..ce9544e01025 100644 --- a/core/node/da_clients/src/eigen/eigenda-integration.md +++ b/core/node/da_clients/src/eigen/eigenda-integration.md @@ -23,7 +23,7 @@ da_client: disperser_rpc: eth_confirmation_depth: -1 eigenda_eth_rpc: - eigenda_svc_manager_address: '0xD4A7E1Bd8015057293f0D0A557088c286942e84b' + eigenda_svc_manager_address: blob_size_limit: 2097152 status_query_timeout: 1800000 # ms status_query_interval: 5 # ms @@ -34,6 +34,9 @@ da_client: chain_id: ``` +You can find the needed variables for holesky dispersal +[here](https://github.com/Layr-Labs/eigenda-proxy/blob/main/.env.example.holesky). + Also set the private key in `etc/env/file_based/secrets.yaml`: ```yaml diff --git a/get_all_blobs/src/blob_info.rs b/get_all_blobs/src/blob_info.rs index 05564e750bdd..caefe3391deb 100644 --- a/get_all_blobs/src/blob_info.rs +++ b/get_all_blobs/src/blob_info.rs @@ -32,7 +32,7 @@ pub struct G1Commitment { } impl G1Commitment { - pub fn into_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { let mut bytes = vec![]; bytes.extend(&self.x.len().to_be_bytes()); bytes.extend(&self.x); @@ -78,7 +78,7 @@ pub struct BlobQuorumParam { } impl BlobQuorumParam { - pub fn into_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { let mut bytes = vec![]; bytes.extend(&self.quorum_number.to_be_bytes()); bytes.extend(&self.adversary_threshold_percentage.to_be_bytes()); @@ -129,14 +129,14 @@ pub struct BlobHeader { } impl BlobHeader { - pub fn into_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { let mut bytes = vec![]; - bytes.extend(self.commitment.into_bytes()); + bytes.extend(self.commitment.to_bytes()); bytes.extend(&self.data_length.to_be_bytes()); bytes.extend(&self.blob_quorum_params.len().to_be_bytes()); for quorum in &self.blob_quorum_params { - bytes.extend(quorum.into_bytes()); + bytes.extend(quorum.to_bytes()); } bytes @@ -177,7 +177,6 @@ impl TryFrom for BlobHeader { .iter() .map(|param| BlobQuorumParam::from(param.clone())) .collect(); - let blob_quorum_params = blob_quorum_params; Ok(Self { commitment: G1Commitment::from(value.commitment.unwrap()), data_length: value.data_length, @@ -195,7 +194,7 @@ pub struct BatchHeader { } impl BatchHeader { - pub fn into_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { let mut bytes = vec![]; bytes.extend(&self.batch_root.len().to_be_bytes()); bytes.extend(&self.batch_root); @@ -251,9 +250,9 @@ pub struct BatchMetadata { } impl BatchMetadata { - pub fn into_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { let mut bytes = vec![]; - bytes.extend(self.batch_header.into_bytes()); + bytes.extend(self.batch_header.to_bytes()); bytes.extend(&self.signatory_record_hash); bytes.extend(&self.confirmation_block_number.to_be_bytes()); @@ -312,11 +311,11 @@ pub struct BlobVerificationProof { } impl BlobVerificationProof { - pub fn into_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { let mut bytes = vec![]; bytes.extend(&self.batch_id.to_be_bytes()); bytes.extend(&self.blob_index.to_be_bytes()); - bytes.extend(self.batch_medatada.into_bytes()); + bytes.extend(self.batch_medatada.to_bytes()); bytes.extend(&self.inclusion_proof.len().to_be_bytes()); bytes.extend(&self.inclusion_proof); bytes.extend(&self.quorum_indexes.len().to_be_bytes()); @@ -372,12 +371,12 @@ pub struct BlobInfo { } impl BlobInfo { - pub fn into_bytes(&self) -> Vec { + pub fn to_bytes(&self) -> Vec { let mut bytes = vec![]; - let blob_header_bytes = self.blob_header.into_bytes(); + let blob_header_bytes = self.blob_header.to_bytes(); bytes.extend(blob_header_bytes.len().to_be_bytes()); bytes.extend(blob_header_bytes); - let blob_verification_proof_bytes = self.blob_verification_proof.into_bytes(); + let blob_verification_proof_bytes = self.blob_verification_proof.to_bytes(); bytes.extend(blob_verification_proof_bytes); bytes } diff --git a/get_all_blobs/src/client.rs b/get_all_blobs/src/client.rs index 2b95d72b9400..0996b150a472 100644 --- a/get_all_blobs/src/client.rs +++ b/get_all_blobs/src/client.rs @@ -42,11 +42,11 @@ impl EigenClientRetriever { .unwrap() .into_inner(); - if get_response.data.len() == 0 { + if get_response.data.is_empty() { panic!("Empty data returned from Disperser") } let data = kzgpad_rs::remove_empty_byte_from_padded_bytes(&get_response.data); - return Ok(Some(data)); + Ok(Some(data)) } } diff --git a/get_all_blobs/src/generated/disperser.rs b/get_all_blobs/src/generated/disperser.rs index 16c330ae8e50..b2ff5edc183c 100644 --- a/get_all_blobs/src/generated/disperser.rs +++ b/get_all_blobs/src/generated/disperser.rs @@ -35,12 +35,12 @@ pub mod authenticated_reply { } /// BlobAuthHeader contains information about the blob for the client to verify and sign. /// - Once payments are enabled, the BlobAuthHeader will contain the KZG commitment to the blob, which the client -/// will verify and sign. Having the client verify the KZG commitment instead of calculating it avoids -/// the need for the client to have the KZG structured reference string (SRS), which can be large. -/// The signed KZG commitment prevents the disperser from sending a different blob to the DA Nodes -/// than the one the client sent. +/// will verify and sign. Having the client verify the KZG commitment instead of calculating it avoids +/// the need for the client to have the KZG structured reference string (SRS), which can be large. +/// The signed KZG commitment prevents the disperser from sending a different blob to the DA Nodes +/// than the one the client sent. /// - In the meantime, the BlobAuthHeader contains a simple challenge parameter is used to prevent -/// replay attacks in the event that a signature is leaked. +/// replay attacks in the event that a signature is leaked. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct BlobAuthHeader { @@ -184,18 +184,18 @@ pub struct BlobVerificationProof { pub inclusion_proof: ::prost::alloc::vec::Vec, /// indexes of quorums in BatchHeader.quorum_numbers that match the quorums in BlobHeader.blob_quorum_params /// Ex. BlobHeader.blob_quorum_params = [ - /// { - /// quorum_number = 0, - /// ... - /// }, - /// { - /// quorum_number = 3, - /// ... - /// }, - /// { - /// quorum_number = 5, - /// ... - /// }, + /// { + /// quorum_number = 0, + /// ... + /// }, + /// { + /// quorum_number = 3, + /// ... + /// }, + /// { + /// quorum_number = 5, + /// ... + /// }, /// ] /// BatchHeader.quorum_numbers = \[0, 5, 3\] => 0x000503 /// Then, quorum_indexes = \[0, 2, 1\] => 0x000201 @@ -246,11 +246,11 @@ pub struct BatchHeader { /// BlobStatus represents the status of a blob. /// The status of a blob is updated as the blob is processed by the disperser. /// The status of a blob can be queried by the client using the GetBlobStatus API. -/// Intermediate states are states that the blob can be in while being processed, and it can be updated to a differet state: +/// Intermediate states are states that the blob can be in while being processed, and it can be updated to a differet state: /// - PROCESSING /// - DISPERSING /// - CONFIRMED -/// Terminal states are states that will not be updated to a different state: +/// Terminal states are states that will not be updated to a different state: /// - FAILED /// - FINALIZED /// - INSUFFICIENT_SIGNATURES @@ -415,7 +415,7 @@ pub mod disperser_client { /// 2. The Disperser sends back a BlobAuthHeader message containing information for the client to /// verify and sign. /// 3. The client verifies the BlobAuthHeader and sends back the signed BlobAuthHeader in an - /// AuthenticationData message. + /// AuthenticationData message. /// 4. The Disperser verifies the signature and returns a DisperseBlobReply message. pub async fn disperse_blob_authenticated( &mut self, diff --git a/get_all_blobs/src/main.rs b/get_all_blobs/src/main.rs index 87a8ab21d420..215108d554ed 100644 --- a/get_all_blobs/src/main.rs +++ b/get_all_blobs/src/main.rs @@ -28,7 +28,7 @@ const COMMIT_BATCHES_SELECTOR: &str = "6edd4f12"; async fn get_blob(commitment: &str) -> anyhow::Result> { let client = EigenClientRetriever::new(EIGENDA_API_URL).await?; let data = client - .get_blob_data(&commitment) + .get_blob_data(commitment) .await? .ok_or_else(|| anyhow::anyhow!("Blob not found"))?; Ok(data) @@ -111,9 +111,8 @@ async fn decode_blob_data_input(input: &[u8]) -> anyhow::Result> { for pubdata_commitments in commit_batch_info.iter() { let pubdata_commitments_bytes = pubdata_commitments.as_bytes(); - match get_blob_from_pubdata_commitment(pubdata_commitments_bytes).await { - Ok(blob_data) => blobs.push(blob_data), - Err(_) => (), + if let Ok(blob_data) = get_blob_from_pubdata_commitment(pubdata_commitments_bytes).await { + blobs.push(blob_data) } }