1#![allow(clippy::type_complexity, missing_debug_implementations)]
4
5use crate::{
6 common::WithConfigs,
7 components::NodeComponentsBuilder,
8 node::FullNode,
9 rpc::{RethRpcAddOns, RethRpcServerHandles, RpcContext},
10 BlockReaderFor, DebugNode, DebugNodeLauncher, EngineNodeLauncher, LaunchNode, Node,
11};
12use alloy_eips::eip4844::env_settings::EnvKzgSettings;
13use futures::Future;
14use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
15use reth_db_api::{database::Database, database_metrics::DatabaseMetrics};
16use reth_exex::ExExContext;
17use reth_network::{
18 transactions::{
19 config::{AnnouncementFilteringPolicy, StrictEthAnnouncementFilter},
20 TransactionPropagationPolicy, TransactionsManagerConfig,
21 },
22 NetworkBuilder, NetworkConfig, NetworkConfigBuilder, NetworkHandle, NetworkManager,
23 NetworkPrimitives,
24};
25use reth_node_api::{
26 FullNodeTypes, FullNodeTypesAdapter, NodeAddOns, NodeTypes, NodeTypesWithDBAdapter,
27};
28use reth_node_core::{
29 cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig},
30 dirs::{ChainPath, DataDirPath},
31 node_config::NodeConfig,
32 primitives::Head,
33};
34use reth_provider::{
35 providers::{BlockchainProvider, NodeTypesForProvider},
36 ChainSpecProvider, FullProvider,
37};
38use reth_tasks::TaskExecutor;
39use reth_transaction_pool::{PoolConfig, PoolTransaction, TransactionPool};
40use secp256k1::SecretKey;
41use std::sync::Arc;
42use tracing::{info, trace, warn};
43
44pub mod add_ons;
45
46mod states;
47pub use states::*;
48
49pub type RethFullAdapter<DB, Types> =
52 FullNodeTypesAdapter<Types, DB, BlockchainProvider<NodeTypesWithDBAdapter<Types, DB>>>;
53
54#[expect(clippy::doc_markdown)]
55#[cfg_attr(doc, aquamarine::aquamarine)]
56pub struct NodeBuilder<DB, ChainSpec> {
153 config: NodeConfig<ChainSpec>,
155 database: DB,
157}
158
159impl<ChainSpec> NodeBuilder<(), ChainSpec> {
160 pub const fn new(config: NodeConfig<ChainSpec>) -> Self {
162 Self { config, database: () }
163 }
164}
165
166impl<DB, ChainSpec> NodeBuilder<DB, ChainSpec> {
167 pub const fn config(&self) -> &NodeConfig<ChainSpec> {
169 &self.config
170 }
171
172 pub const fn config_mut(&mut self) -> &mut NodeConfig<ChainSpec> {
174 &mut self.config
175 }
176
177 pub const fn db(&self) -> &DB {
179 &self.database
180 }
181
182 pub const fn db_mut(&mut self) -> &mut DB {
184 &mut self.database
185 }
186
187 pub fn try_apply<F, R>(self, f: F) -> Result<Self, R>
189 where
190 F: FnOnce(Self) -> Result<Self, R>,
191 {
192 f(self)
193 }
194
195 pub fn try_apply_if<F, R>(self, cond: bool, f: F) -> Result<Self, R>
197 where
198 F: FnOnce(Self) -> Result<Self, R>,
199 {
200 if cond {
201 f(self)
202 } else {
203 Ok(self)
204 }
205 }
206
207 pub fn apply<F>(self, f: F) -> Self
209 where
210 F: FnOnce(Self) -> Self,
211 {
212 f(self)
213 }
214
215 pub fn apply_if<F>(self, cond: bool, f: F) -> Self
217 where
218 F: FnOnce(Self) -> Self,
219 {
220 if cond {
221 f(self)
222 } else {
223 self
224 }
225 }
226}
227
228impl<DB, ChainSpec: EthChainSpec> NodeBuilder<DB, ChainSpec> {
229 pub fn with_database<D>(self, database: D) -> NodeBuilder<D, ChainSpec> {
231 NodeBuilder { config: self.config, database }
232 }
233
234 pub const fn with_launch_context(self, task_executor: TaskExecutor) -> WithLaunchContext<Self> {
238 WithLaunchContext { builder: self, task_executor }
239 }
240
241 #[cfg(feature = "test-utils")]
243 pub fn testing_node(
244 self,
245 task_executor: TaskExecutor,
246 ) -> WithLaunchContext<
247 NodeBuilder<Arc<reth_db::test_utils::TempDatabase<reth_db::DatabaseEnv>>, ChainSpec>,
248 > {
249 let path = reth_db::test_utils::tempdir_path();
250 self.testing_node_with_datadir(task_executor, path)
251 }
252
253 #[cfg(feature = "test-utils")]
255 pub fn testing_node_with_datadir(
256 mut self,
257 task_executor: TaskExecutor,
258 datadir: impl Into<std::path::PathBuf>,
259 ) -> WithLaunchContext<
260 NodeBuilder<Arc<reth_db::test_utils::TempDatabase<reth_db::DatabaseEnv>>, ChainSpec>,
261 > {
262 let path = reth_node_core::dirs::MaybePlatformPath::<DataDirPath>::from(datadir.into());
263 self.config = self.config.with_datadir_args(reth_node_core::args::DatadirArgs {
264 datadir: path.clone(),
265 ..Default::default()
266 });
267
268 let data_dir =
269 path.unwrap_or_chain_default(self.config.chain.chain(), self.config.datadir.clone());
270
271 let db = reth_db::test_utils::create_test_rw_db_with_path(data_dir.db());
272
273 WithLaunchContext { builder: self.with_database(db), task_executor }
274 }
275}
276
277impl<DB, ChainSpec> NodeBuilder<DB, ChainSpec>
278where
279 DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
280 ChainSpec: EthChainSpec + EthereumHardforks,
281{
282 pub fn with_types<T>(self) -> NodeBuilderWithTypes<RethFullAdapter<DB, T>>
284 where
285 T: NodeTypesForProvider<ChainSpec = ChainSpec>,
286 {
287 self.with_types_and_provider()
288 }
289
290 pub fn with_types_and_provider<T, P>(
292 self,
293 ) -> NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>
294 where
295 T: NodeTypesForProvider<ChainSpec = ChainSpec>,
296 P: FullProvider<NodeTypesWithDBAdapter<T, DB>>,
297 {
298 NodeBuilderWithTypes::new(self.config, self.database)
299 }
300
301 pub fn node<N>(
305 self,
306 node: N,
307 ) -> NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>
308 where
309 N: Node<RethFullAdapter<DB, N>, ChainSpec = ChainSpec> + NodeTypesForProvider,
310 {
311 self.with_types().with_components(node.components_builder()).with_add_ons(node.add_ons())
312 }
313}
314
315pub struct WithLaunchContext<Builder> {
320 builder: Builder,
321 task_executor: TaskExecutor,
322}
323
324impl<Builder> WithLaunchContext<Builder> {
325 pub const fn task_executor(&self) -> &TaskExecutor {
327 &self.task_executor
328 }
329}
330
331impl<DB, ChainSpec> WithLaunchContext<NodeBuilder<DB, ChainSpec>> {
332 pub const fn config(&self) -> &NodeConfig<ChainSpec> {
334 self.builder.config()
335 }
336
337 pub const fn config_mut(&mut self) -> &mut NodeConfig<ChainSpec> {
339 self.builder.config_mut()
340 }
341}
342
343impl<DB, ChainSpec> WithLaunchContext<NodeBuilder<DB, ChainSpec>>
344where
345 DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
346 ChainSpec: EthChainSpec + EthereumHardforks,
347{
348 pub fn with_types<T>(self) -> WithLaunchContext<NodeBuilderWithTypes<RethFullAdapter<DB, T>>>
350 where
351 T: NodeTypesForProvider<ChainSpec = ChainSpec>,
352 {
353 WithLaunchContext { builder: self.builder.with_types(), task_executor: self.task_executor }
354 }
355
356 pub fn with_types_and_provider<T, P>(
358 self,
359 ) -> WithLaunchContext<NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>>
360 where
361 T: NodeTypesForProvider<ChainSpec = ChainSpec>,
362 P: FullProvider<NodeTypesWithDBAdapter<T, DB>>,
363 {
364 WithLaunchContext {
365 builder: self.builder.with_types_and_provider(),
366 task_executor: self.task_executor,
367 }
368 }
369
370 pub fn node<N>(
374 self,
375 node: N,
376 ) -> WithLaunchContext<
377 NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>,
378 >
379 where
380 N: Node<RethFullAdapter<DB, N>, ChainSpec = ChainSpec> + NodeTypesForProvider,
381 {
382 self.with_types().with_components(node.components_builder()).with_add_ons(node.add_ons())
383 }
384
385 pub async fn launch_node<N>(
391 self,
392 node: N,
393 ) -> eyre::Result<
394 <EngineNodeLauncher as LaunchNode<
395 NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>,
396 >>::Node,
397 >
398 where
399 N: Node<RethFullAdapter<DB, N>, ChainSpec = ChainSpec> + NodeTypesForProvider,
400 N::AddOns: RethRpcAddOns<
401 NodeAdapter<
402 RethFullAdapter<DB, N>,
403 <N::ComponentsBuilder as NodeComponentsBuilder<RethFullAdapter<DB, N>>>::Components,
404 >,
405 >,
406 EngineNodeLauncher: LaunchNode<
407 NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>,
408 >,
409 {
410 self.node(node).launch().await
411 }
412}
413
414impl<T: FullNodeTypes> WithLaunchContext<NodeBuilderWithTypes<T>> {
415 pub fn with_components<CB>(
417 self,
418 components_builder: CB,
419 ) -> WithLaunchContext<NodeBuilderWithComponents<T, CB, ()>>
420 where
421 CB: NodeComponentsBuilder<T>,
422 {
423 WithLaunchContext {
424 builder: self.builder.with_components(components_builder),
425 task_executor: self.task_executor,
426 }
427 }
428}
429
430impl<T, CB> WithLaunchContext<NodeBuilderWithComponents<T, CB, ()>>
431where
432 T: FullNodeTypes,
433 CB: NodeComponentsBuilder<T>,
434{
435 pub fn with_add_ons<AO>(
438 self,
439 add_ons: AO,
440 ) -> WithLaunchContext<NodeBuilderWithComponents<T, CB, AO>>
441 where
442 AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
443 {
444 WithLaunchContext {
445 builder: self.builder.with_add_ons(add_ons),
446 task_executor: self.task_executor,
447 }
448 }
449}
450
451impl<T, CB, AO> WithLaunchContext<NodeBuilderWithComponents<T, CB, AO>>
452where
453 T: FullNodeTypes,
454 CB: NodeComponentsBuilder<T>,
455 AO: RethRpcAddOns<NodeAdapter<T, CB::Components>>,
456{
457 pub const fn config(&self) -> &NodeConfig<<T::Types as NodeTypes>::ChainSpec> {
459 &self.builder.config
460 }
461
462 pub const fn config_mut(&mut self) -> &mut NodeConfig<<T::Types as NodeTypes>::ChainSpec> {
464 &mut self.builder.config
465 }
466
467 pub const fn db(&self) -> &T::DB {
469 &self.builder.adapter.database
470 }
471
472 pub const fn db_mut(&mut self) -> &mut T::DB {
474 &mut self.builder.adapter.database
475 }
476
477 pub fn try_apply<F, R>(self, f: F) -> Result<Self, R>
479 where
480 F: FnOnce(Self) -> Result<Self, R>,
481 {
482 f(self)
483 }
484
485 pub fn try_apply_if<F, R>(self, cond: bool, f: F) -> Result<Self, R>
487 where
488 F: FnOnce(Self) -> Result<Self, R>,
489 {
490 if cond {
491 f(self)
492 } else {
493 Ok(self)
494 }
495 }
496
497 pub fn apply<F>(self, f: F) -> Self
499 where
500 F: FnOnce(Self) -> Self,
501 {
502 f(self)
503 }
504
505 pub fn apply_if<F>(self, cond: bool, f: F) -> Self
507 where
508 F: FnOnce(Self) -> Self,
509 {
510 if cond {
511 f(self)
512 } else {
513 self
514 }
515 }
516
517 pub fn on_component_initialized<F>(self, hook: F) -> Self
519 where
520 F: FnOnce(NodeAdapter<T, CB::Components>) -> eyre::Result<()> + Send + 'static,
521 {
522 Self {
523 builder: self.builder.on_component_initialized(hook),
524 task_executor: self.task_executor,
525 }
526 }
527
528 pub fn on_node_started<F>(self, hook: F) -> Self
530 where
531 F: FnOnce(FullNode<NodeAdapter<T, CB::Components>, AO>) -> eyre::Result<()>
532 + Send
533 + 'static,
534 {
535 Self { builder: self.builder.on_node_started(hook), task_executor: self.task_executor }
536 }
537
538 pub fn map_add_ons<F>(self, f: F) -> Self
561 where
562 F: FnOnce(AO) -> AO,
563 {
564 Self { builder: self.builder.map_add_ons(f), task_executor: self.task_executor }
565 }
566
567 pub fn on_rpc_started<F>(self, hook: F) -> Self
569 where
570 F: FnOnce(
571 RpcContext<'_, NodeAdapter<T, CB::Components>, AO::EthApi>,
572 RethRpcServerHandles,
573 ) -> eyre::Result<()>
574 + Send
575 + 'static,
576 {
577 Self { builder: self.builder.on_rpc_started(hook), task_executor: self.task_executor }
578 }
579
580 pub fn extend_rpc_modules<F>(self, hook: F) -> Self
615 where
616 F: FnOnce(RpcContext<'_, NodeAdapter<T, CB::Components>, AO::EthApi>) -> eyre::Result<()>
617 + Send
618 + 'static,
619 {
620 Self { builder: self.builder.extend_rpc_modules(hook), task_executor: self.task_executor }
621 }
622
623 pub fn install_exex<F, R, E>(self, exex_id: impl Into<String>, exex: F) -> Self
629 where
630 F: FnOnce(ExExContext<NodeAdapter<T, CB::Components>>) -> R + Send + 'static,
631 R: Future<Output = eyre::Result<E>> + Send,
632 E: Future<Output = eyre::Result<()>> + Send,
633 {
634 Self {
635 builder: self.builder.install_exex(exex_id, exex),
636 task_executor: self.task_executor,
637 }
638 }
639
640 pub fn install_exex_if<F, R, E>(self, cond: bool, exex_id: impl Into<String>, exex: F) -> Self
646 where
647 F: FnOnce(ExExContext<NodeAdapter<T, CB::Components>>) -> R + Send + 'static,
648 R: Future<Output = eyre::Result<E>> + Send,
649 E: Future<Output = eyre::Result<()>> + Send,
650 {
651 if cond {
652 self.install_exex(exex_id, exex)
653 } else {
654 self
655 }
656 }
657
658 pub async fn launch_with<L>(self, launcher: L) -> eyre::Result<L::Node>
660 where
661 L: LaunchNode<NodeBuilderWithComponents<T, CB, AO>>,
662 {
663 launcher.launch_node(self.builder).await
664 }
665
666 pub fn launch_with_fn<L, R>(self, launcher: L) -> R
668 where
669 L: FnOnce(Self) -> R,
670 {
671 launcher(self)
672 }
673
674 pub const fn check_launch(self) -> Self {
678 self
679 }
680
681 pub async fn launch(
683 self,
684 ) -> eyre::Result<<EngineNodeLauncher as LaunchNode<NodeBuilderWithComponents<T, CB, AO>>>::Node>
685 where
686 EngineNodeLauncher: LaunchNode<NodeBuilderWithComponents<T, CB, AO>>,
687 {
688 let launcher = self.engine_api_launcher();
689 self.builder.launch_with(launcher).await
690 }
691
692 pub fn launch_with_debug_capabilities(
697 self,
698 ) -> <DebugNodeLauncher as LaunchNode<NodeBuilderWithComponents<T, CB, AO>>>::Future
699 where
700 T::Types: DebugNode<NodeAdapter<T, CB::Components>>,
701 DebugNodeLauncher: LaunchNode<NodeBuilderWithComponents<T, CB, AO>>,
702 {
703 let Self { builder, task_executor } = self;
704
705 let engine_tree_config = builder.config.engine.tree_config();
706
707 let launcher = DebugNodeLauncher::new(EngineNodeLauncher::new(
708 task_executor,
709 builder.config.datadir(),
710 engine_tree_config,
711 ));
712 builder.launch_with(launcher)
713 }
714
715 pub fn engine_api_launcher(&self) -> EngineNodeLauncher {
718 let engine_tree_config = self.builder.config.engine.tree_config();
719 EngineNodeLauncher::new(
720 self.task_executor.clone(),
721 self.builder.config.datadir(),
722 engine_tree_config,
723 )
724 }
725}
726
727pub struct BuilderContext<Node: FullNodeTypes> {
729 pub(crate) head: Head,
731 pub(crate) provider: Node::Provider,
733 pub(crate) executor: TaskExecutor,
735 pub(crate) config_container: WithConfigs<<Node::Types as NodeTypes>::ChainSpec>,
737}
738
739impl<Node: FullNodeTypes> BuilderContext<Node> {
740 pub const fn new(
742 head: Head,
743 provider: Node::Provider,
744 executor: TaskExecutor,
745 config_container: WithConfigs<<Node::Types as NodeTypes>::ChainSpec>,
746 ) -> Self {
747 Self { head, provider, executor, config_container }
748 }
749
750 pub const fn provider(&self) -> &Node::Provider {
752 &self.provider
753 }
754
755 pub const fn head(&self) -> Head {
757 self.head
758 }
759
760 pub const fn config(&self) -> &NodeConfig<<Node::Types as NodeTypes>::ChainSpec> {
762 &self.config_container.config
763 }
764
765 pub const fn config_mut(&mut self) -> &mut NodeConfig<<Node::Types as NodeTypes>::ChainSpec> {
767 &mut self.config_container.config
768 }
769
770 pub const fn reth_config(&self) -> &reth_config::Config {
772 &self.config_container.toml_config
773 }
774
775 pub const fn task_executor(&self) -> &TaskExecutor {
779 &self.executor
780 }
781
782 pub fn chain_spec(&self) -> Arc<<Node::Types as NodeTypes>::ChainSpec> {
784 self.provider().chain_spec()
785 }
786
787 pub const fn is_dev(&self) -> bool {
789 self.config().dev.dev
790 }
791
792 pub fn pool_config(&self) -> PoolConfig {
794 self.config().txpool.pool_config()
795 }
796
797 pub const fn kzg_settings(&self) -> eyre::Result<EnvKzgSettings> {
799 Ok(EnvKzgSettings::Default)
800 }
801
802 pub fn payload_builder_config(&self) -> impl PayloadBuilderConfig {
804 self.config().builder.clone()
805 }
806
807 pub fn start_network<N, Pool>(
812 &self,
813 builder: NetworkBuilder<(), (), N>,
814 pool: Pool,
815 ) -> NetworkHandle<N>
816 where
817 N: NetworkPrimitives,
818 Pool: TransactionPool<
819 Transaction: PoolTransaction<
820 Consensus = N::BroadcastedTransaction,
821 Pooled = N::PooledTransaction,
822 >,
823 > + Unpin
824 + 'static,
825 Node::Provider: BlockReaderFor<N>,
826 {
827 self.start_network_with(
828 builder,
829 pool,
830 self.config().network.transactions_manager_config(),
831 self.config().network.tx_propagation_policy,
832 )
833 }
834
835 pub fn start_network_with<Pool, N, Policy>(
843 &self,
844 builder: NetworkBuilder<(), (), N>,
845 pool: Pool,
846 tx_config: TransactionsManagerConfig,
847 propagation_policy: Policy,
848 ) -> NetworkHandle<N>
849 where
850 N: NetworkPrimitives,
851 Pool: TransactionPool<
852 Transaction: PoolTransaction<
853 Consensus = N::BroadcastedTransaction,
854 Pooled = N::PooledTransaction,
855 >,
856 > + Unpin
857 + 'static,
858 Node::Provider: BlockReaderFor<N>,
859 Policy: TransactionPropagationPolicy<N>,
860 {
861 self.start_network_with_policies(
862 builder,
863 pool,
864 tx_config,
865 propagation_policy,
866 StrictEthAnnouncementFilter::default(),
867 )
868 }
869
870 pub fn start_network_with_policies<Pool, N, PropPolicy, AnnPolicy>(
879 &self,
880 builder: NetworkBuilder<(), (), N>,
881 pool: Pool,
882 tx_config: TransactionsManagerConfig,
883 propagation_policy: PropPolicy,
884 announcement_policy: AnnPolicy,
885 ) -> NetworkHandle<N>
886 where
887 N: NetworkPrimitives,
888 Pool: TransactionPool<
889 Transaction: PoolTransaction<
890 Consensus = N::BroadcastedTransaction,
891 Pooled = N::PooledTransaction,
892 >,
893 > + Unpin
894 + 'static,
895 Node::Provider: BlockReaderFor<N>,
896 PropPolicy: TransactionPropagationPolicy<N>,
897 AnnPolicy: AnnouncementFilteringPolicy<N>,
898 {
899 let (handle, network, txpool, eth) = builder
900 .transactions_with_policies(pool, tx_config, propagation_policy, announcement_policy)
901 .request_handler(self.provider().clone())
902 .split_with_handle();
903
904 self.executor.spawn_critical_blocking("p2p txpool", Box::pin(txpool));
905 self.executor.spawn_critical_blocking("p2p eth request handler", Box::pin(eth));
906
907 let default_peers_path = self.config().datadir().known_peers();
908 let known_peers_file = self.config().network.persistent_peers_file(default_peers_path);
909 self.executor.spawn_critical_with_graceful_shutdown_signal(
910 "p2p network task",
911 |shutdown| {
912 Box::pin(network.run_until_graceful_shutdown(shutdown, |network| {
913 if let Some(peers_file) = known_peers_file {
914 let num_known_peers = network.num_known_peers();
915 trace!(target: "reth::cli", peers_file=?peers_file, num_peers=%num_known_peers, "Saving current peers");
916 match network.write_peers_to_file(peers_file.as_path()) {
917 Ok(_) => {
918 info!(target: "reth::cli", peers_file=?peers_file, "Wrote network peers to file");
919 }
920 Err(err) => {
921 warn!(target: "reth::cli", %err, "Failed to write network peers to file");
922 }
923 }
924 }
925 }))
926 },
927 );
928
929 handle
930 }
931
932 fn network_secret(&self, data_dir: &ChainPath<DataDirPath>) -> eyre::Result<SecretKey> {
934 let secret_key = self.config().network.secret_key(data_dir.p2p_secret())?;
935 Ok(secret_key)
936 }
937
938 pub fn build_network_config<N>(
940 &self,
941 network_builder: NetworkConfigBuilder<N>,
942 ) -> NetworkConfig<Node::Provider, N>
943 where
944 N: NetworkPrimitives,
945 Node::Types: NodeTypes<ChainSpec: Hardforks>,
946 {
947 network_builder.build(self.provider.clone())
948 }
949}
950
951impl<Node: FullNodeTypes<Types: NodeTypes<ChainSpec: Hardforks>>> BuilderContext<Node> {
952 pub async fn network_builder<N>(&self) -> eyre::Result<NetworkBuilder<(), (), N>>
954 where
955 N: NetworkPrimitives,
956 {
957 let network_config = self.network_config()?;
958 let builder = NetworkManager::builder(network_config).await?;
959 Ok(builder)
960 }
961
962 pub fn network_config<N>(&self) -> eyre::Result<NetworkConfig<Node::Provider, N>>
964 where
965 N: NetworkPrimitives,
966 {
967 let network_builder = self.network_config_builder();
968 Ok(self.build_network_config(network_builder?))
969 }
970
971 pub fn network_config_builder<N>(&self) -> eyre::Result<NetworkConfigBuilder<N>>
973 where
974 N: NetworkPrimitives,
975 {
976 let secret_key = self.network_secret(&self.config().datadir())?;
977 let default_peers_path = self.config().datadir().known_peers();
978 let builder = self
979 .config()
980 .network
981 .network_config(
982 self.reth_config(),
983 self.config().chain.clone(),
984 secret_key,
985 default_peers_path,
986 )
987 .with_task_executor(Box::new(self.executor.clone()))
988 .set_head(self.head);
989
990 Ok(builder)
991 }
992}
993
994impl<Node: FullNodeTypes> std::fmt::Debug for BuilderContext<Node> {
995 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
996 f.debug_struct("BuilderContext")
997 .field("head", &self.head)
998 .field("provider", &std::any::type_name::<Node::Provider>())
999 .field("executor", &self.executor)
1000 .field("config", &self.config())
1001 .finish()
1002 }
1003}