tycho_simulation/evm/engine_db/engine_db_interface.rs
1use std::collections::HashMap;
2
3use alloy::primitives::{Address, U256};
4use revm::{state::AccountInfo, DatabaseRef};
5use tycho_client::feed::BlockHeader;
6
7pub trait EngineDatabaseInterface: DatabaseRef + Send + Sync {
8 type Error;
9
10 /// Sets up a single account
11 ///
12 /// Full control over setting up an accounts. Allows to set up EOAs as
13 /// well as smart contracts.
14 ///
15 /// # Arguments
16 ///
17 /// * `address` - Address of the account
18 /// * `account` - The account information
19 /// * `permanent_storage` - Storage to init the account with this storage can only be updated
20 /// manually.
21 /// * `mocked` - Whether this account should be considered mocked. For mocked accounts, nothing
22 /// is downloaded from a node; all data must be inserted manually.
23 fn init_account(
24 &self,
25 address: Address,
26 account: AccountInfo,
27 permanent_storage: Option<HashMap<U256, U256>>,
28 mocked: bool,
29 ) -> Result<(), <Self as EngineDatabaseInterface>::Error>;
30
31 fn clear_temp_storage(&mut self) -> Result<(), <Self as EngineDatabaseInterface>::Error>;
32
33 /// Gets the block header that this database is operating at.
34 ///
35 /// # Returns
36 ///
37 /// * `Option<BlockHeader>` - The current block header, or None if no block is set
38 fn get_current_block(&self) -> Option<BlockHeader>;
39}