From ad183e8f6c7dcb2e573f1ebcfbfd0d1d9c4c8ba2 Mon Sep 17 00:00:00 2001 From: Juan Munoz Date: Fri, 10 Jan 2025 14:28:26 -0300 Subject: [PATCH] combine `JoinError` with `KzgError` --- core/node/da_clients/src/eigen/verifier.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/core/node/da_clients/src/eigen/verifier.rs b/core/node/da_clients/src/eigen/verifier.rs index 35541ccda3d0..d4d6ce9de8a2 100644 --- a/core/node/da_clients/src/eigen/verifier.rs +++ b/core/node/da_clients/src/eigen/verifier.rs @@ -42,12 +42,20 @@ impl VerifierClient for PKSigningClient { } } +#[derive(Debug, thiserror::Error)] +pub enum KzgError { + #[error("Kzg setup error: {0}")] + Setup(String), + #[error(transparent)] + Internal(#[from] rust_kzg_bn254::errors::KzgError), +} + #[derive(Debug, thiserror::Error)] pub enum VerificationError { #[error("Service manager error")] ServiceManagerError, #[error(transparent)] - KzgError(#[from] rust_kzg_bn254::errors::KzgError), + Kzg(#[from] KzgError), #[error("Wrong proof")] WrongProof, #[error("Different commitments: expected {expected:?}, got {actual:?}")] @@ -71,8 +79,6 @@ pub enum VerificationError { CommitmentNotOnCorrectSubgroup(G1Affine), #[error("Link Error: {0}")] LinkError(String), - #[error(transparent)] - JoinError(#[from] tokio::task::JoinError), } /// Configuration for the verifier used for authenticated dispersals @@ -152,7 +158,11 @@ impl Verifier { "".to_string(), ) }); - let kzg = kzg_handle.await??; + + let kzg = kzg_handle + .await + .map_err(|e| VerificationError::Kzg(KzgError::Setup(e.to_string())))? + .map_err(KzgError::Internal)?; Ok(Self { kzg, @@ -166,7 +176,7 @@ impl Verifier { let blob = Blob::from_bytes_and_pad(blob); self.kzg .blob_to_kzg_commitment(&blob, PolynomialFormat::InEvaluationForm) - .map_err(VerificationError::KzgError) + .map_err(|e| VerificationError::Kzg(KzgError::Internal(e))) } /// Compare the given commitment with the commitment generated with the blob