forked from agglayer/agglayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
certifier.rs
44 lines (37 loc) · 1.26 KB
/
certifier.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use agglayer_types::LocalNetworkStateData;
use agglayer_types::{Certificate, Height, NetworkId};
use pessimistic_proof::local_exit_tree::hasher::Keccak256Hasher;
use pessimistic_proof::multi_batch_header::MultiBatchHeader;
use pessimistic_proof::LocalNetworkState;
use crate::error::CertificationError;
pub trait CertificateInput: Clone {
fn network_id(&self) -> NetworkId;
}
impl CertificateInput for Certificate {
fn network_id(&self) -> NetworkId {
self.network_id
}
}
#[derive(Debug, Clone)]
pub struct CertifierOutput {
pub certificate: Certificate,
pub height: Height,
pub new_state: LocalNetworkStateData,
pub network: NetworkId,
}
pub type CertifierResult = Result<CertifierOutput, CertificationError>;
/// Apply one Certificate on top of a local state and computes one proof.
#[async_trait::async_trait]
pub trait Certifier: Unpin + Send + Sync + 'static {
async fn certify(
&self,
full_state: LocalNetworkStateData,
network_id: NetworkId,
height: Height,
) -> CertifierResult;
async fn witness_execution(
&self,
certificate: &Certificate,
state: &mut LocalNetworkStateData,
) -> Result<(MultiBatchHeader<Keccak256Hasher>, LocalNetworkState), CertificationError>;
}