mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
docs(node-core): add document of build_blockchain_tree (#7120)
Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@ -9,7 +9,7 @@ use std::future::Future;
|
||||
pub trait PayloadServiceBuilder<Node: FullNodeTypes, Pool: TransactionPool>: Send {
|
||||
/// Spawns the payload service and returns the handle to it.
|
||||
///
|
||||
/// The [BuilderContext] is provided to allow give to access the node's configuration.
|
||||
/// The [BuilderContext] is provided to allow access to the node's configuration.
|
||||
fn spawn_payload_service(
|
||||
self,
|
||||
ctx: &BuilderContext<Node>,
|
||||
|
||||
@ -36,11 +36,11 @@ pub trait Node<N>: NodeTypes + Clone {
|
||||
|
||||
/// The type that configures stateless node types, the node's primitive types.
|
||||
pub trait NodeTypes: Send + Sync + 'static {
|
||||
/// The node's primitive types.
|
||||
/// The node's primitive types, defining basic operations and structures.
|
||||
type Primitives: NodePrimitives;
|
||||
/// The node's engine types.
|
||||
/// The node's engine types, defining the interaction with the consensus engine.
|
||||
type Engine: EngineTypes;
|
||||
/// The node's evm configuration.
|
||||
/// The node's EVM configuration, defining settings for the Ethereum Virtual Machine.
|
||||
type Evm: ConfigureEvm;
|
||||
|
||||
/// Returns the node's evm config.
|
||||
|
||||
@ -28,7 +28,10 @@ use tracing::{debug, info, warn};
|
||||
/// Interval of reporting node state.
|
||||
const INFO_MESSAGE_INTERVAL: Duration = Duration::from_secs(25);
|
||||
|
||||
/// The current high-level state of the node.
|
||||
/// The current high-level state of the node, including the node's database environemt, network
|
||||
/// connections, current processing stage, and the latest block information. It provides
|
||||
/// methods to handle different types of events that affect the node's state, such as pipeline
|
||||
/// events, network events, and consensus engine events.
|
||||
struct NodeState<DB> {
|
||||
/// Database environment.
|
||||
/// Used for freelist calculation reported in the "Status" log message.
|
||||
|
||||
@ -403,7 +403,48 @@ impl NodeConfig {
|
||||
Ok(builder)
|
||||
}
|
||||
|
||||
/// Build the blockchain tree
|
||||
/// Builds the blockchain tree for the node.
|
||||
///
|
||||
/// This method configures the blockchain tree, which is a critical component of the node,
|
||||
/// responsible for managing the blockchain state, including blocks, transactions, and receipts.
|
||||
/// It integrates with the consensus mechanism and the EVM for executing transactions.
|
||||
///
|
||||
/// # Parameters
|
||||
/// - `provider_factory`: A factory for creating various blockchain-related providers, such as
|
||||
/// for accessing the database or static files.
|
||||
/// - `consensus`: The consensus configuration, which defines how the node reaches agreement on
|
||||
/// the blockchain state with other nodes.
|
||||
/// - `prune_config`: Configuration for pruning old blockchain data. This helps in managing the
|
||||
/// storage space efficiently. It's important to validate this configuration to ensure it does
|
||||
/// not lead to unintended data loss.
|
||||
/// - `sync_metrics_tx`: A transmitter for sending synchronization metrics. This is used for
|
||||
/// monitoring the node's synchronization process with the blockchain network.
|
||||
/// - `tree_config`: Configuration for the blockchain tree, including any parameters that affect
|
||||
/// its structure or performance.
|
||||
/// - `evm_config`: The EVM (Ethereum Virtual Machine) configuration, which affects how smart
|
||||
/// contracts and transactions are executed. Proper validation of this configuration is
|
||||
/// crucial for the correct execution of transactions.
|
||||
///
|
||||
/// # Returns
|
||||
/// A `ShareableBlockchainTree` instance, which provides access to the blockchain state and
|
||||
/// supports operations like block insertion, state reversion, and transaction execution.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust,ignore
|
||||
/// let tree = config.build_blockchain_tree(
|
||||
/// provider_factory,
|
||||
/// consensus,
|
||||
/// prune_config,
|
||||
/// sync_metrics_tx,
|
||||
/// BlockchainTreeConfig::default(),
|
||||
/// evm_config,
|
||||
/// )?;
|
||||
/// ```
|
||||
///
|
||||
/// # Note
|
||||
/// Ensure that all configurations passed to this method are validated beforehand to prevent
|
||||
/// runtime errors. Specifically, `prune_config` and `evm_config` should be checked to ensure
|
||||
/// they meet the node's operational requirements.
|
||||
pub fn build_blockchain_tree<DB, EvmConfig>(
|
||||
&self,
|
||||
provider_factory: ProviderFactory<DB>,
|
||||
|
||||
Reference in New Issue
Block a user