evm/backend/mod.rs
1//! # Backend-related traits and implementations
2//!
3//! A backend exposes external information that is available to an EVM
4//! interpreter. This includes block information such as the current coinbase,
5//! block gas limit, etc, as well as the state such as account balance, storage
6//! and code.
7//!
8//! Backends have layers, representing information that may be committed or
9//! discard after the current call stack finishes. Due to the vast differences of
10//! how different backends behave (for example, in some backends like wasm,
11//! pushing/poping layers are dealt by extern functions), layers are handled
12//! internally inside a backend.
13
14mod in_memory;
15mod overlayed;
16
17use evm_interpreter::ExitError;
18
19pub use self::in_memory::{
20 InMemoryAccount, InMemoryBackend, InMemoryEnvironment, InMemorySuicideInfo,
21};
22pub use self::overlayed::{OverlayedBackend, OverlayedChangeSet};
23pub use evm_interpreter::runtime::{RuntimeBackend, RuntimeBaseBackend, RuntimeEnvironment};
24
25/// Backend with layers that can transactionally be committed or discarded.
26pub trait TransactionalBackend {
27 /// Push a new substate layer into the backend.
28 fn push_substate(&mut self);
29 /// Pop the last substate layer from the backend, either committing or
30 /// discarding it.
31 ///
32 /// The caller is expected to maintain balance of push/pop, and the backend
33 /// are free to panic if it does not.
34 fn pop_substate(&mut self, strategy: crate::MergeStrategy) -> Result<(), ExitError>;
35}