MCPcopy Create free account
hub / github.com/base/base / new

Method new

crates/execution/runner/src/test_utils/node.rs:63–142  ·  view source on GitHub ↗

Launch a new local node with the provided extensions and chain spec.

(
        extensions: Vec<Box<dyn BaseNodeExtension>>,
        chain_spec: Arc<BaseChainSpec>,
    )

Source from the content-addressed store, hash-verified

61impl LocalNode {
62 /// Launch a new local node with the provided extensions and chain spec.
63 pub async fn new(
64 extensions: Vec<Box<dyn BaseNodeExtension>>,
65 chain_spec: Arc<BaseChainSpec>,
66 ) -> Result<Self> {
67 let exec = Runtime::test();
68
69 let network_config = NetworkArgs {
70 discovery: DiscoveryArgs { disable_discovery: true, ..DiscoveryArgs::default() },
71 ..NetworkArgs::default()
72 };
73
74 let unique_ipc_path = format!(
75 "/tmp/reth_engine_api_{}_{}_{:?}.ipc",
76 std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos(),
77 std::process::id(),
78 std::thread::current().id()
79 );
80
81 let mut rpc_args =
82 RpcServerArgs::default().with_unused_ports().with_http().with_auth_ipc().with_ws();
83 rpc_args.auth_ipc_path = unique_ipc_path;
84
85 let base_node = BaseNode::new(RollupArgs::default());
86
87 let (db, db_path) = Self::create_test_database()?;
88
89 let mut node_config = NodeConfig::new(Arc::clone(&chain_spec))
90 .with_network(network_config)
91 .with_rpc(rpc_args)
92 .with_unused_ports();
93
94 // The Engine API test harness builds blocks back-to-back and expects each canonical head to
95 // be immediately usable as the next payload parent. Persist canonical blocks immediately so
96 // follow-up payload validation can resolve parent headers from the database-backed paths
97 // that reth 2.3.0 now consults during state-root/proof work.
98 node_config.engine.persistence_threshold = 0;
99
100 let datadir_path = MaybePlatformPath::<DataDirPath>::from(db_path.clone());
101 node_config = node_config
102 .with_datadir_args(DatadirArgs { datadir: datadir_path, ..Default::default() });
103
104 let builder = NodeBuilder::new(node_config.clone())
105 .with_database(db)
106 .with_launch_context(exec.clone())
107 .with_types_and_provider::<BaseNode, BlockchainProvider<_>>()
108 .with_components(base_node.components())
109 .with_add_ons(base_node.add_ons())
110 .on_component_initialized(move |_ctx| Ok(()));
111
112 let NodeHandle { node: node_handle, node_exit_future } = extensions
113 .into_iter()
114 .fold(NodeHooks::new(), |b, ext| ext.apply(b))
115 .apply_to(builder)
116 .launch()
117 .await?;
118
119 let http_api_addr = node_handle
120 .rpc_server_handle()

Callers

nothing calls this directly

Calls 11

with_auth_ipcMethod · 0.80
with_httpMethod · 0.80
apply_toMethod · 0.80
into_iterMethod · 0.80
with_networkMethod · 0.45
cloneMethod · 0.45
componentsMethod · 0.45
add_onsMethod · 0.45
launchMethod · 0.45
applyMethod · 0.45
providerMethod · 0.45

Tested by

no test coverage detected