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::{RuntimeDebug, H160, H256};
10use sp_std::prelude::*;
11
12pub trait Verifier {
14 fn verify(event: &Log, proof: &Proof) -> Result<(), VerificationError>;
15}
16
17#[derive(Clone, Encode, Decode, DecodeWithMemTracking, RuntimeDebug, PalletError, TypeInfo)]
18#[cfg_attr(feature = "std", derive(PartialEq))]
19pub enum VerificationError {
20 HeaderNotFound,
22 LogNotFound,
24 InvalidLog,
26 InvalidProof,
28 InvalidExecutionProof(#[codec(skip)] &'static str),
30}
31
32#[derive(Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, RuntimeDebug, TypeInfo)]
34pub struct EventProof {
35 pub event_log: Log,
37 pub proof: Proof,
39}
40
41#[derive(Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, RuntimeDebug, TypeInfo)]
43pub struct Log {
44 pub address: H160,
45 pub topics: Vec<H256>,
46 pub data: Vec<u8>,
47}
48
49#[derive(Clone, Encode, Decode, DecodeWithMemTracking, PartialEq, RuntimeDebug, TypeInfo)]
51pub struct Proof {
52 pub receipt_proof: Vec<Vec<u8>>,
54 pub execution_proof: ExecutionProof,
56}
57
58#[derive(Clone, RuntimeDebug)]
59pub struct EventFixture {
60 pub event: EventProof,
61 pub finalized_header: BeaconHeader,
62 pub block_roots_root: H256,
63}