Skip to content

Commit

Permalink
clippy & doc
Browse files Browse the repository at this point in the history
  • Loading branch information
juan518munoz committed Nov 22, 2024
1 parent f3725c6 commit c47a0cd
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion core/node/da_clients/src/eigen/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion core/node/da_clients/src/eigen/eigenda-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ da_client:
disperser_rpc: <your_desired_disperser>
eth_confirmation_depth: -1
eigenda_eth_rpc: <your_desired_rpc>
eigenda_svc_manager_address: '0xD4A7E1Bd8015057293f0D0A557088c286942e84b'
eigenda_svc_manager_address: <svc_manager_addr>
blob_size_limit: 2097152
status_query_timeout: 1800000 # ms
status_query_interval: 5 # ms
Expand All @@ -34,6 +34,9 @@ da_client:
chain_id: <your_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
Expand Down
27 changes: 13 additions & 14 deletions get_all_blobs/src/blob_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct G1Commitment {
}

impl G1Commitment {
pub fn into_bytes(&self) -> Vec<u8> {
pub fn to_bytes(&self) -> Vec<u8> {
let mut bytes = vec![];
bytes.extend(&self.x.len().to_be_bytes());
bytes.extend(&self.x);
Expand Down Expand Up @@ -78,7 +78,7 @@ pub struct BlobQuorumParam {
}

impl BlobQuorumParam {
pub fn into_bytes(&self) -> Vec<u8> {
pub fn to_bytes(&self) -> Vec<u8> {
let mut bytes = vec![];
bytes.extend(&self.quorum_number.to_be_bytes());
bytes.extend(&self.adversary_threshold_percentage.to_be_bytes());
Expand Down Expand Up @@ -129,14 +129,14 @@ pub struct BlobHeader {
}

impl BlobHeader {
pub fn into_bytes(&self) -> Vec<u8> {
pub fn to_bytes(&self) -> Vec<u8> {
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
Expand Down Expand Up @@ -177,7 +177,6 @@ impl TryFrom<DisperserBlobHeader> 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,
Expand All @@ -195,7 +194,7 @@ pub struct BatchHeader {
}

impl BatchHeader {
pub fn into_bytes(&self) -> Vec<u8> {
pub fn to_bytes(&self) -> Vec<u8> {
let mut bytes = vec![];
bytes.extend(&self.batch_root.len().to_be_bytes());
bytes.extend(&self.batch_root);
Expand Down Expand Up @@ -251,9 +250,9 @@ pub struct BatchMetadata {
}

impl BatchMetadata {
pub fn into_bytes(&self) -> Vec<u8> {
pub fn to_bytes(&self) -> Vec<u8> {
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());

Expand Down Expand Up @@ -312,11 +311,11 @@ pub struct BlobVerificationProof {
}

impl BlobVerificationProof {
pub fn into_bytes(&self) -> Vec<u8> {
pub fn to_bytes(&self) -> Vec<u8> {
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());
Expand Down Expand Up @@ -372,12 +371,12 @@ pub struct BlobInfo {
}

impl BlobInfo {
pub fn into_bytes(&self) -> Vec<u8> {
pub fn to_bytes(&self) -> Vec<u8> {
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
}
Expand Down
4 changes: 2 additions & 2 deletions get_all_blobs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
40 changes: 20 additions & 20 deletions get_all_blobs/src/generated/disperser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -184,18 +184,18 @@ pub struct BlobVerificationProof {
pub inclusion_proof: ::prost::alloc::vec::Vec<u8>,
/// 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions get_all_blobs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const COMMIT_BATCHES_SELECTOR: &str = "6edd4f12";
async fn get_blob(commitment: &str) -> anyhow::Result<Vec<u8>> {
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)
Expand Down Expand Up @@ -111,9 +111,8 @@ async fn decode_blob_data_input(input: &[u8]) -> anyhow::Result<Vec<BlobData>> {

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)
}
}

Expand Down

0 comments on commit c47a0cd

Please sign in to comment.