From e64cc2e65469ae367c6eaca7a0d21b8ac9130da4 Mon Sep 17 00:00:00 2001 From: Juan Munoz Date: Fri, 1 Nov 2024 18:24:00 -0300 Subject: [PATCH] initial commit --- core/node/da_clients/src/eigen/client.rs | 38 ++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/core/node/da_clients/src/eigen/client.rs b/core/node/da_clients/src/eigen/client.rs index 5df7b1b02fb0..377181e7690b 100644 --- a/core/node/da_clients/src/eigen/client.rs +++ b/core/node/da_clients/src/eigen/client.rs @@ -1,5 +1,6 @@ use std::{str::FromStr, sync::Arc}; +use anyhow::anyhow; use async_trait::async_trait; use secp256k1::SecretKey; use subxt_signer::ExposeSecret; @@ -9,7 +10,7 @@ use zksync_da_client::{ DataAvailabilityClient, }; -use super::sdk::RawEigenClient; +use super::{blob_info::BlobInfo, sdk::RawEigenClient}; use crate::utils::to_non_retriable_da_error; #[derive(Debug, Clone)] @@ -59,8 +60,19 @@ impl DataAvailabilityClient for EigenClient { Ok(DispatchResponse::from(blob_id)) } - async fn get_inclusion_data(&self, _: &str) -> Result, DAError> { - Ok(Some(InclusionData { data: vec![] })) + async fn get_inclusion_data(&self, blob_id: &str) -> Result, DAError> { + let rlp_encoded_bytes = hex::decode(blob_id).map_err(|_| DAError { + error: anyhow!("Failed to decode blob_id"), + is_retriable: false, + })?; + let blob_info: BlobInfo = rlp::decode(&rlp_encoded_bytes).map_err(|_| DAError { + error: anyhow!("Failed to decode blob_info"), + is_retriable: false, + })?; + let inclusion_data = blob_info.blob_verification_proof.inclusion_proof; + Ok(Some(InclusionData { + data: inclusion_data, + })) } fn clone_boxed(&self) -> Box { @@ -89,6 +101,7 @@ mod tests { use super::*; use crate::eigen::blob_info::BlobInfo; + #[tokio::test] async fn test_non_auth_dispersal() { let config = EigenConfig::Disperser(DisperserConfig { @@ -114,10 +127,18 @@ mod tests { let result = client.dispatch_blob(0, data.clone()).await.unwrap(); let blob_info: BlobInfo = rlp::decode(&hex::decode(result.blob_id.clone()).unwrap()).unwrap(); - // TODO: once get inclusion data is added, check it + let expected_inclusion_data = blob_info.blob_verification_proof.inclusion_proof; + let actual_inclusion_data = client + .get_inclusion_data(&result.blob_id) + .await + .unwrap() + .unwrap() + .data; + assert_eq!(expected_inclusion_data, actual_inclusion_data); let retrieved_data = client.get_blob_data(&result.blob_id).await.unwrap(); assert_eq!(retrieved_data.unwrap(), data); } + #[tokio::test] async fn test_auth_dispersal() { let config = EigenConfig::Disperser(DisperserConfig { @@ -143,7 +164,14 @@ mod tests { let result = client.dispatch_blob(0, data.clone()).await.unwrap(); let blob_info: BlobInfo = rlp::decode(&hex::decode(result.blob_id.clone()).unwrap()).unwrap(); - // TODO: once get inclusion data is added, check it + let expected_inclusion_data = blob_info.blob_verification_proof.inclusion_proof; + let actual_inclusion_data = client + .get_inclusion_data(&result.blob_id) + .await + .unwrap() + .unwrap() + .data; + assert_eq!(expected_inclusion_data, actual_inclusion_data); let retrieved_data = client.get_blob_data(&result.blob_id).await.unwrap(); assert_eq!(retrieved_data.unwrap(), data); }