Skip to content

Commit

Permalink
fix: EigenDA retrieve blob logic (#267)
Browse files Browse the repository at this point in the history
* initial commit

* remove unwraps
  • Loading branch information
juan518munoz authored Sep 17, 2024
1 parent 3b16f66 commit ff3eac9
Showing 1 changed file with 32 additions and 55 deletions.
87 changes: 32 additions & 55 deletions core/node/da_clients/src/eigen_da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt::Debug;
use async_trait::async_trait;
use zksync_config::configs::da_client::eigen_da::EigenDAConfig;
use zksync_da_client::{
types::{self, InclusionData},
types::{self, DAError, InclusionData},
DataAvailabilityClient,
};

Expand Down Expand Up @@ -31,62 +31,40 @@ impl DataAvailabilityClient for EigenDAClient {
_batch_number: u32,
blob_data: Vec<u8>,
) -> Result<types::DispatchResponse, types::DAError> {
tracing::info!("Dispatching blob to Eigen DA");
let response = self
.client
.post(format!("{}/put/", self.config.api_node_url))
.header(http::header::CONTENT_TYPE, "application/octet-stream")
.body(blob_data)
.send()
.await
.unwrap();
.map_err(to_retriable_error)?;

let request_id = response.bytes().await.unwrap().to_vec();
let request_id = response
.bytes()
.await
.map_err(to_non_retriable_da_error)?
.to_vec();
Ok(types::DispatchResponse {
blob_id: hex::encode(request_id),
})
}
async fn get_inclusion_data(
&self,
_blob_id: &str,
blob_id: &str,
) -> anyhow::Result<Option<types::InclusionData>, types::DAError> {
// let request_id = hex::decode(blob_id).unwrap();
// let blob_status_reply = self
// .disperser
// .lock()
// .await
// .get_blob_status(BlobStatusRequest { request_id })
// .await
// .unwrap()
// .into_inner();
// let blob_status = blob_status_reply.status();
// match blob_status {
// BlobStatus::Unknown => Err(to_retriable_error(anyhow::anyhow!(
// "Blob status is unknown"
// ))),
// BlobStatus::Processing => Err(to_retriable_error(anyhow::anyhow!(
// "Blob is being processed"
// ))),
// BlobStatus::Confirmed => Err(to_retriable_error(anyhow::anyhow!(
// "Blob is confirmed but not finalized"
// ))),
// BlobStatus::Failed => Err(to_non_retriable_error(anyhow::anyhow!("Blob has failed"))),
// BlobStatus::InsufficientSignatures => Err(to_non_retriable_error(anyhow::anyhow!(
// "Insufficient signatures for blob"
// ))),
// BlobStatus::Dispersing => Err(to_retriable_error(anyhow::anyhow!(
// "Blob is being dispersed"
// ))),
// BlobStatus::Finalized => Ok(Some(types::InclusionData {
// data: blob_status_reply
// .info
// .unwrap()
// .blob_verification_proof
// .unwrap()
// .inclusion_proof,
// })),
// }
Ok(Some(InclusionData { data: vec![] }))
let response = self
.client
.get(format!("{}/get/0x{}", self.config.api_node_url, blob_id))
.send()
.await
.map_err(to_retriable_error)?;
let data = response
.bytes()
.await
.map_err(to_non_retriable_da_error)?
.to_vec();
Ok(Some(InclusionData { data }))
}

fn clone_boxed(&self) -> Box<dyn DataAvailabilityClient> {
Expand All @@ -100,17 +78,16 @@ impl DataAvailabilityClient for EigenDAClient {

// Note: This methods should be uncommented if the `get_inclusion_data` method
// implementation gets uncommented.
//
// fn to_retriable_error(error: anyhow::Error) -> types::DAError {
// types::DAError {
// error,
// is_retriable: true,
// }
// }
fn to_retriable_error(error: impl Into<anyhow::Error>) -> DAError {
DAError {
error: error.into(),
is_retriable: true,
}
}

// fn to_non_retriable_error(error: anyhow::Error) -> types::DAError {
// types::DAError {
// error,
// is_retriable: false,
// }
// }
fn to_non_retriable_da_error(error: impl Into<anyhow::Error>) -> DAError {
DAError {
error: error.into(),
is_retriable: false,
}
}

0 comments on commit ff3eac9

Please sign in to comment.