Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eigen-client-extra-features): get inclusion data #324

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions core/node/da_clients/src/eigen/client.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)]
Expand Down Expand Up @@ -59,8 +60,19 @@ impl DataAvailabilityClient for EigenClient {
Ok(DispatchResponse::from(blob_id))
}

async fn get_inclusion_data(&self, _: &str) -> Result<Option<InclusionData>, DAError> {
Ok(Some(InclusionData { data: vec![] }))
async fn get_inclusion_data(&self, blob_id: &str) -> Result<Option<InclusionData>, 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<dyn DataAvailabilityClient> {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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);
}
Expand Down
Loading