@@ -53,44 +53,56 @@ Provides external API access to the node:
5353
5454## Component Customization
5555
56- Each component can be customized through Reth's builder pattern:
56+ Each component can be customized through Reth's builder pattern. You can replace individual components
57+ while keeping the defaults for others using ` EthereumNode::components() ` :
5758
5859``` rust
59- use reth_ethereum :: node :: {EthereumNode , NodeBuilder };
60-
61- let node = NodeBuilder :: new (config )
62- . with_types :: <EthereumNode >()
63- . with_components (| ctx | {
64- // Use the ComponentBuilder to customize components
65- ctx . components_builder ()
66- // Custom network configuration
67- . network (| network_builder | {
68- network_builder
69- . peer_manager (custom_peer_manager )
70- . build ()
71- })
72- // Custom transaction pool
73- . pool (| pool_builder | {
74- pool_builder
75- . validator (custom_validator )
76- . ordering (custom_ordering )
77- . build ()
78- })
79- // Custom consensus
80- . consensus (custom_consensus )
81- // Custom EVM configuration
82- . evm (| evm_builder | {
83- evm_builder
84- . with_precompiles (custom_precompiles )
85- . build ()
86- })
87- // Build all components
88- . build ()
89- })
90- . build ()
91- . await ? ;
60+ use reth_ethereum :: {
61+ cli :: interface :: Cli ,
62+ node :: {
63+ node :: EthereumAddOns ,
64+ EthereumNode ,
65+ },
66+ };
67+
68+ fn main () {
69+ Cli :: parse_args ()
70+ . run (| builder , _ | async move {
71+ let handle = builder
72+ // Use the default ethereum node types
73+ . with_types :: <EthereumNode >()
74+ // Configure the components of the node
75+ // Use default ethereum components but replace specific ones
76+ . with_components (
77+ EthereumNode :: components ()
78+ // Custom transaction pool
79+ . pool (CustomPoolBuilder :: default ())
80+ // Other customizable components:
81+ // .network(CustomNetworkBuilder::default())
82+ // .executor(CustomExecutorBuilder::default())
83+ // .consensus(CustomConsensusBuilder::default())
84+ // .payload(CustomPayloadBuilder::default())
85+ )
86+ . with_add_ons (EthereumAddOns :: default ())
87+ . launch ()
88+ . await ? ;
89+
90+ handle . wait_for_node_exit (). await
91+ })
92+ . unwrap ();
93+ }
9294```
9395
96+ Custom component builders must implement their respective traits (` PoolBuilder ` , ` NetworkBuilder ` ,
97+ ` ExecutorBuilder ` , ` ConsensusBuilder ` , ` PayloadServiceBuilder ` ). Each trait requires implementing
98+ an async ` build_* ` method that receives a ` BuilderContext ` with access to node configuration,
99+ providers, and task executors.
100+
101+ For complete working examples with full trait implementations, see:
102+ - [ custom-node-components] ( https://github.com/paradigmxyz/reth/tree/main/examples/custom-node-components ) - Custom transaction pool
103+ - [ custom-payload-builder] ( https://github.com/paradigmxyz/reth/tree/main/examples/custom-payload-builder ) - Custom payload builder
104+ - [ custom-evm] ( https://github.com/paradigmxyz/reth/tree/main/examples/custom-evm ) - Custom EVM configuration
105+
94106## Component Lifecycle
95107
96108Components follow a specific lifecycle starting from node builder initialization to shutdown:
0 commit comments