verbs_rs/db/
types.rs

1use alloy_primitives::{Address, B256, U256 as AlloyU256};
2use ethers_core::types::{H160, H256, U256};
3use revm::primitives::AccountInfo;
4
5pub trait ToAlloy {
6    type To;
7    fn to_alloy(self) -> Self::To;
8}
9
10impl ToAlloy for H256 {
11    type To = B256;
12
13    #[inline(always)]
14    fn to_alloy(self) -> Self::To {
15        B256::new(self.0)
16    }
17}
18
19impl ToAlloy for U256 {
20    type To = AlloyU256;
21
22    #[inline(always)]
23    fn to_alloy(self) -> Self::To {
24        AlloyU256::from_limbs(self.0)
25    }
26}
27
28pub trait ToEthers {
29    type To;
30
31    fn to_ethers(self) -> Self::To;
32}
33
34impl ToEthers for Address {
35    type To = H160;
36
37    #[inline(always)]
38    fn to_ethers(self) -> Self::To {
39        H160(self.0 .0)
40    }
41}
42
43impl ToEthers for B256 {
44    type To = H256;
45
46    #[inline(always)]
47    fn to_ethers(self) -> Self::To {
48        H256(self.0)
49    }
50}
51
52/// Cache of requests made by a [super::ForkDb]
53///
54/// Data structure designed to store a history
55/// of data/account requests made by a
56/// [super::ForkDb] over the course of a
57/// simulation. This cache can be inserted into
58/// [super::LocalDB] in subsequent simulations
59/// to avoid the overhead of making remote
60/// requests.
61///
62#[derive(Debug, Clone)]
63pub struct RequestCache {
64    pub start_timestamp: AlloyU256,
65    pub start_block_number: AlloyU256,
66    pub accounts: Vec<(Address, AccountInfo)>,
67    pub storage: Vec<(Address, AlloyU256, AlloyU256)>,
68}