simular_core/
snapshot.rs

1//!
2//! Containers for serializing EVM state information
3//!
4use revm::primitives::{Address, Bytes, U256};
5use serde::{Deserialize, Serialize};
6use std::collections::BTreeMap;
7
8/// Source of the snapshop.  Either from a fork or the local in-memory database.
9#[derive(Clone, Debug, Serialize, Deserialize, Default)]
10pub enum SnapShotSource {
11    Memory,
12    #[default]
13    Fork,
14}
15
16/// A single AccountRecord and it's associated storage. `SnapShot` stores
17/// a map of Accounts.
18#[derive(Clone, Debug, Serialize, Deserialize)]
19pub struct SnapShotAccountRecord {
20    pub nonce: u64,
21    pub balance: U256,
22    pub code: Bytes,
23    pub storage: BTreeMap<U256, U256>,
24}
25
26/// The high-level objects containing all the snapshot information.
27#[derive(Clone, Debug, Default, Serialize, Deserialize)]
28pub struct SnapShot {
29    pub source: SnapShotSource,
30    pub block_num: u64,
31    pub timestamp: u64,
32    pub accounts: BTreeMap<Address, SnapShotAccountRecord>,
33}