agglayer_types/certificate/header/status.rs
1use std::fmt;
2
3use crate::CertificateStatusError;
4
5#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
6pub enum CertificateStatus {
7 /// Received certificate from the network, nothing checked yet.
8 ///
9 /// Certificate will stay in this state until rate-limiting is lifted or an
10 /// epoch-change event is triggered. A pending certificate can then be
11 /// processed by the agglayer to be proven, or it could end up in error.
12 Pending,
13
14 /// Pessimistic proof has been generated for the certificate and stored in
15 /// the rocksdb in the agglayer node.
16 Proven,
17
18 /// Settlement of the certificate's proof has already been started on L1
19 /// (and acknowledged by its RPC) by issuing a contract call to the
20 /// RollupManager, but the associated transaction has not yet seen
21 /// enough confirmations.
22 ///
23 /// The certificate can move from Candidate to Settled if the associated
24 /// transaction is accepted and the transaction receipt is a success. If the
25 /// transaction receipt fails, the certificate will end up in Error.
26 Candidate,
27
28 /// Hit some error while moving the certificate through the pipeline.
29 ///
30 /// For example, proving failed (Pending -> InError), L1 reorg'd (Candidate
31 /// -> InError)... See the documentation of `CertificateStatusError` for
32 /// more details.
33 ///
34 /// Note that a certificate can be InError in agglayer but settled on L1,
35 /// eg. if there was an error in agglayer but the certificate was valid
36 /// and settled on L1.
37 InError { error: Box<CertificateStatusError> },
38
39 /// Transaction to settle the certificate was completed successfully on L1.
40 Settled,
41}
42
43impl fmt::Display for CertificateStatus {
44 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
45 match self {
46 CertificateStatus::Pending => write!(f, "Pending"),
47 CertificateStatus::Proven => write!(f, "Proven"),
48 CertificateStatus::Candidate => write!(f, "Candidate"),
49 CertificateStatus::InError { error } => write!(f, "InError: {error}"),
50 CertificateStatus::Settled => write!(f, "Settled"),
51 }
52 }
53}
54
55impl CertificateStatus {
56 pub fn error(err: CertificateStatusError) -> Self {
57 CertificateStatus::InError {
58 error: Box::new(err),
59 }
60 }
61}