snowbridge_verification_primitives/
lib.rs1#![cfg_attr(not(feature = "std"), no_std)]
5use codec::{Decode, DecodeWithMemTracking, Encode};
6use frame_support::PalletError;
7use scale_info::TypeInfo;
8use snowbridge_beacon_primitives::{BeaconHeader, ExecutionProof};
9use sp_core::{H160, H256};
10use sp_std::prelude::*;
11
12pub mod receipt;
13
14pub trait Verifier {
16 fn verify(event: &Log, proof: &Proof) -> Result<(), VerificationError>;
17}
18
19#[derive(Clone, Encode, Decode, DecodeWithMemTracking, Debug, PalletError, TypeInfo)]
20#[cfg_attr(feature = "std", derive(PartialEq))]
21pub enum VerificationError {
22 HeaderNotFound,
24 LogNotFound,
26 InvalidLog,
28 InvalidProof,
30 InvalidExecutionProof(#[codec(skip)] &'static str),
32 Halted,
35}
36
37#[derive(Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, Debug, TypeInfo)]
39pub struct EventProof {
40 pub event_log: Log,
42 pub proof: Proof,
44}
45
46#[derive(Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, Debug, TypeInfo)]
48pub struct Log {
49 pub address: H160,
50 pub topics: Vec<H256>,
51 pub data: Vec<u8>,
52 pub tx_index: u64,
53}
54
55#[derive(Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, Debug, TypeInfo)]
57pub struct Proof {
58 pub receipt_proof: Vec<Vec<u8>>,
60 pub execution_proof: ExecutionProof,
62}
63
64#[derive(Clone, Debug)]
65pub struct EventFixture {
66 pub event: EventProof,
67 pub finalized_header: BeaconHeader,
68 pub block_roots_root: H256,
69}