bankai_types/fetch/evm/
mod.rs1extern crate alloc;
2use alloc::vec::Vec;
3
4use alloy_primitives::{Address, FixedBytes, U256, hex::FromHex};
5use serde::{Deserialize, Serialize};
6
7use crate::{
8 fetch::evm::{
9 beacon::BeaconHeaderProof,
10 execution::{AccountProof, ExecutionHeaderProof, StorageSlotProof, TxProof},
11 },
12 proofs::{HashingFunctionDto, MmrProofDto},
13};
14
15pub mod beacon;
16pub mod execution;
17
18#[cfg_attr(feature = "std", derive(Debug))]
19#[derive(Serialize, Deserialize)]
20pub struct EvmProofs {
21 pub execution_header_proof: Option<Vec<ExecutionHeaderProof>>,
22 pub beacon_header_proof: Option<Vec<BeaconHeaderProof>>,
23 pub account_proof: Option<Vec<AccountProof>>,
24 pub storage_slot_proof: Option<Vec<StorageSlotProof>>,
25 pub tx_proof: Option<Vec<TxProof>>,
26}
27
28impl From<MmrProofDto> for MmrProof {
29 fn from(mmr_proof: MmrProofDto) -> Self {
30 MmrProof {
31 network_id: mmr_proof.network_id,
32 block_number: mmr_proof.block_number,
33 hashing_function: mmr_proof.hashing_function,
34 header_hash: FixedBytes::from_hex(mmr_proof.header_hash).unwrap(),
35 root: FixedBytes::from_hex(mmr_proof.root).unwrap(),
36 elements_index: mmr_proof.elements_index,
37 elements_count: mmr_proof.elements_count,
38 path: mmr_proof
39 .path
40 .iter()
41 .map(|h| FixedBytes::from_hex(h).unwrap())
42 .collect(),
43 peaks: mmr_proof
44 .peaks
45 .iter()
46 .map(|h| FixedBytes::from_hex(h).unwrap())
47 .collect(),
48 }
49 }
50}
51
52#[cfg(feature = "verifier-types")]
53#[cfg_attr(any(feature = "verifier-types", feature = "std"), derive(Debug))]
54#[derive(Clone, Serialize, Deserialize)]
55pub struct MmrProof {
56 pub network_id: u64,
57 pub block_number: u64,
58 pub hashing_function: HashingFunctionDto,
59 pub header_hash: FixedBytes<32>,
60 pub root: FixedBytes<32>,
61 pub elements_index: u64,
62 pub elements_count: u64,
63 pub path: Vec<FixedBytes<32>>,
64 pub peaks: Vec<FixedBytes<32>>,
65}
66
67#[derive(Debug)]
68pub struct EvmProofsRequest {
69 pub execution_header: Option<Vec<ExecutionHeaderProofRequest>>,
70 pub beacon_header: Option<Vec<BeaconHeaderProofRequest>>,
71 pub account: Option<Vec<AccountProofRequest>>,
72 pub storage_slot: Option<Vec<StorageSlotProofRequest>>,
73 pub tx_proof: Option<Vec<TxProofRequest>>,
74}
75
76#[derive(Debug)]
77pub struct ExecutionHeaderProofRequest {
78 pub network_id: u64,
79 pub block_number: u64,
80 pub hashing_function: HashingFunctionDto,
81 pub bankai_block_number: u64,
82}
83
84#[derive(Debug)]
85pub struct BeaconHeaderProofRequest {
86 pub network_id: u64,
87 pub slot: u64,
88 pub hashing_function: HashingFunctionDto,
89 pub bankai_block_number: u64,
90}
91
92#[derive(Debug)]
93pub struct AccountProofRequest {
94 pub network_id: u64,
95 pub block_number: u64,
96 pub address: Address,
97}
98
99#[derive(Debug)]
100pub struct StorageSlotProofRequest {
101 pub network_id: u64,
102 pub block_number: u64,
103 pub address: Address,
104 pub slot_keys: Vec<U256>,
105}
106
107#[derive(Debug)]
108pub struct TxProofRequest {
109 pub network_id: u64,
110 pub tx_hash: FixedBytes<32>,
111}