cfx_executor/
lib.rs

1//! Conflux Executor: A Rust crate for the core logic of executing transactions
2//! on the Conflux blockchain. It encapsulates all the necessary logic for a
3//! consensus node during execution, focusing solely on the execution logic
4//! without enhanced features like tracing or trace processing.
5
6#[macro_use]
7extern crate log;
8#[macro_use]
9extern crate lazy_static;
10#[macro_use]
11extern crate cfx_util_macros;
12use substrate_bn as bn;
13
14/// Ethereum Builtins: Implements Ethereum's builtin contracts, ranging from
15/// address `0x1` to `0x9`.
16mod builtin;
17
18/// Execution Context: Implements the context during the execution, like
19/// caller's information and block information. It also ensures compatibility
20/// with the context interface of the EVM interpreter.
21pub mod context;
22
23/// Transaction Execution Entry: Manages the execution of transactions.
24/// It is responsible for receiving transactions, performing checks according to
25/// the Conflux specification, and submitting them to the execution engine.
26pub mod executive;
27
28/// Conflux Internal Contracts: Implements Conflux's builtin contracts.  
29pub mod internal_contract;
30
31/// Execution Engine Object: Serves as a factory for specifications, builtin
32/// contracts (including internal contracts), and the EVM interpreter.
33pub mod machine;
34
35/// Tool Macros
36mod macros;
37
38/// Observability Interface: Defines a trait for extending functionality.
39/// Extensions can implement this trait to observe detailed aspects of the
40/// execution process.
41pub mod observer;
42
43/// Stack Management for Execution Engine: Conflux's execution engine is
44/// stack-based. This module manages the stack operations, mainly handling the
45/// logic related to pushing and popping frames.
46pub mod stack;
47
48/// Transaction Execution Tracker: Tracks and records consensus-matters details
49/// during transaction execution.
50pub mod substate;
51
52/// Specification Control: Enables fine-grained control over the engine's
53/// behavior during the execution of different blocks, allowing the engine to
54/// achieve backward compatibility with different versions of the Conflux
55/// specification per hardfork.
56pub mod spec;
57
58/// Ledger State: Acts as a caching and checkpoint layer built upon semantically
59/// meaningful database interfaces for the execution.
60pub mod state;
61
62pub use internal_contract::{InternalContractMap, InternalContractTrait};
63pub use observer as executive_observer;
64
65/// Common tools for test
66#[cfg(test)]
67mod tests {
68    use cfx_types::H256;
69    use hex_literal::hex;
70    // Mock transaction hash for tests not contruct an actual transaction.
71    pub const MOCK_TX_HASH: H256 = H256(hex!(
72        "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
73    ));
74}