arbiter_core/lib.rs
1//! ```text
2//! _ _____ ____ _____ _______ ______ _____
3//! / \ | __ \| _ \_ _|__ __| ____| __ \
4//! / \ | |__) | |_) || | | | | |__ | |__) |
5//! / / \ \ | _ /| _ < | | | | | __| | _ /
6//! / _____ \| | \ \| |_) || |_ | | | |____| | \ \
7//! /_/ \_\_| \_\____/_____| |_| |______|_| \_\
8//! ```
9//!
10//! `arbiter-core` is designed to facilitate agent-based simulations of Ethereum
11//! smart contracts in a local environment.
12//!
13//! With a primary emphasis on ease of use and performance, it employs the
14//! [`revm`](https://crates.io/crates/revm) (Rust EVM) to provide a local
15//! execution environment that closely simulates the Ethereum blockchain but
16//! without associated overheads like networking latency.
17//!
18//! Key Features:
19//! - **Environment Handling**: Detailed setup and control mechanisms for
20//! running the Ethereum-like blockchain environment.
21//! - **Middleware Implementation**: Customized middleware to reduce overhead
22//! and provide optimal performance.
23//!
24//! For a detailed guide on getting started, check out the
25//! [Arbiter Github page](https://github.com/primitivefinance/arbiter/).
26//!
27//! For specific module-level information and examples, navigate to the
28//! respective module documentation below.
29
30#![warn(missing_docs)]
31
32pub mod console;
33pub mod coprocessor;
34pub mod database;
35pub mod environment;
36pub mod errors;
37pub mod events;
38pub mod middleware;
39
40use std::{
41 collections::{BTreeMap, HashMap},
42 convert::Infallible,
43 fmt::Debug,
44 sync::{Arc, RwLock},
45};
46
47use async_trait::async_trait;
48use ethers::types::{Address as eAddress, Filter, Log as eLog, H256, U256 as eU256, U64};
49use revm::{
50 db::{CacheDB, EmptyDB},
51 interpreter::{CallInputs, CallOutcome},
52 primitives::{AccountInfo, Address, Bytes, ExecutionResult, Log, TxEnv, U256},
53 Database, Evm, EvmContext, Inspector,
54};
55use serde::{Deserialize, Serialize};
56use tokio::sync::broadcast::{Receiver as BroadcastReceiver, Sender as BroadcastSender};
57use tracing::{debug, error, info, trace, warn};
58
59use crate::{database::ArbiterDB, environment::Broadcast, errors::ArbiterCoreError};