rust_eigen_client/
errors.rs

1use ark_bn254::G1Affine;
2use tokio::sync::mpsc::error::SendError;
3use tonic::{transport::Error as TonicError, Status};
4
5use crate::{blob_info::BlobQuorumParam, eth_client::RpcErrorResponse, generated::disperser};
6
7/// Errors returned by this crate
8#[derive(Debug, thiserror::Error)]
9pub enum EigenClientError {
10    #[error(transparent)]
11    EthClient(#[from] EthClientError),
12    #[error(transparent)]
13    Verification(#[from] VerificationError),
14    #[error(transparent)]
15    Communication(#[from] CommunicationError),
16    #[error(transparent)]
17    BlobStatus(#[from] BlobStatusError),
18    #[error(transparent)]
19    Conversion(#[from] ConversionError),
20    #[error(transparent)]
21    Config(#[from] ConfigError),
22}
23
24#[derive(Debug, thiserror::Error)]
25pub enum ConfigError {
26    #[error("Private Key Error")]
27    PrivateKey,
28    #[error("ETH RPC URL not set")]
29    NoEthRpcUrl,
30    #[error(transparent)]
31    Secp(#[from] secp256k1::Error),
32    #[error(transparent)]
33    Tonic(#[from] TonicError),
34}
35
36#[derive(Debug, thiserror::Error)]
37pub enum CommunicationError {
38    #[error("No response from server")]
39    NoResponseFromServer,
40    #[error("No payload in response")]
41    NoPayloadInResponse,
42    #[error("Failed to get blob data")]
43    FailedToGetBlob,
44    #[error("Failed to send DisperseBlobRequest: {0}")]
45    DisperseBlob(SendError<disperser::AuthenticatedRequest>),
46    #[error("Failed to send AuthenticationData: {0}")]
47    AuthenticationData(SendError<disperser::AuthenticatedRequest>),
48    #[error("Error from server: {0}")]
49    ErrorFromServer(String),
50    #[error(transparent)]
51    Secp(#[from] secp256k1::Error),
52    #[error(transparent)]
53    Hex(#[from] hex::FromHexError),
54    #[error(transparent)]
55    BlobProvider(#[from] Box<dyn std::error::Error + Send + Sync>),
56}
57
58#[derive(Debug, thiserror::Error)]
59pub enum BlobStatusError {
60    #[error("Blob still processing")]
61    BlobStillProcessing,
62    #[error("Blob dispatched failed")]
63    BlobDispatchedFailed,
64    #[error("Insufficient signatures")]
65    InsufficientSignatures,
66    #[error("No blob header in response")]
67    NoBlobHeaderInResponse,
68    #[error("Received unknown blob status")]
69    ReceivedUnknownBlobStatus,
70    #[error(transparent)]
71    Prost(#[from] prost::DecodeError),
72    #[error(transparent)]
73    Status(#[from] Status),
74}
75
76/// Errors specific to conversion
77#[derive(Debug, thiserror::Error)]
78pub enum ConversionError {
79    #[error("Failed to convert {0}")]
80    NotPresent(String),
81    #[error("Failed to cast {0}")]
82    Cast(String),
83}
84
85/// Errors for the EthClient
86#[derive(Debug, thiserror::Error)]
87pub enum EthClientError {
88    #[error(transparent)]
89    HTTPClient(#[from] reqwest::Error),
90    #[error(transparent)]
91    SerdeJSON(#[from] serde_json::Error),
92    #[error("RPC: {0}")]
93    Rpc(RpcErrorResponse),
94}
95
96#[derive(Debug, thiserror::Error)]
97pub enum KzgError {
98    #[error("Kzg setup error: {0}")]
99    Setup(String),
100    #[error(transparent)]
101    Internal(#[from] rust_kzg_bn254::errors::KzgError),
102}
103
104#[derive(Debug, thiserror::Error)]
105pub enum ServiceManagerError {
106    #[error(transparent)]
107    EthClient(#[from] EthClientError),
108    #[error("Decoding error: {0}")]
109    Decoding(String),
110}
111
112/// Errors for the Verifier
113#[derive(Debug, thiserror::Error)]
114pub enum VerificationError {
115    #[error(transparent)]
116    ServiceManager(#[from] ServiceManagerError),
117    #[error(transparent)]
118    Kzg(#[from] KzgError),
119    #[error("Wrong proof")]
120    WrongProof,
121    #[error("Different commitments: expected {expected:?}, got {actual:?}")]
122    DifferentCommitments {
123        expected: Box<G1Affine>,
124        actual: Box<G1Affine>,
125    },
126    #[error("Different roots: expected {expected:?}, got {actual:?}")]
127    DifferentRoots { expected: String, actual: String },
128    #[error("Empty hashes")]
129    EmptyHash,
130    #[error("Different hashes: expected {expected:?}, got {actual:?}")]
131    DifferentHashes { expected: String, actual: String },
132    #[error("Wrong quorum params: {blob_quorum_params:?}")]
133    WrongQuorumParams { blob_quorum_params: BlobQuorumParam },
134    #[error("Quorum not confirmed")]
135    QuorumNotConfirmed,
136    #[error("Commitment not on curve: {0}")]
137    CommitmentNotOnCurve(G1Affine),
138    #[error("Commitment not on correct subgroup: {0}")]
139    CommitmentNotOnCorrectSubgroup(G1Affine),
140    #[error("Point download error: {0}")]
141    PointDownloadError(String),
142    #[error("Data Mismatch")]
143    DataMismatch,
144    #[error(transparent)]
145    Conversion(#[from] ConversionError),
146}