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

Method launch

crates/builder/core/src/test_utils/instance.rs:202–273  ·  view source on GitHub ↗

Core launch routine shared by all constructors. Builds the node through the runner's payload-service seam and applies caller-supplied [extensions](BaseNodeExtension) via the same [`NodeHooks`] pipeline used in production, plus an internal hook that captures the running node's transaction pool for tests.

(
        builder_config: BuilderConfig,
        node_config: NodeConfig<BaseChainSpec>,
        extensions: Vec<Box<dyn BaseNodeExtension>>,
    )

Source from the content-addressed store, hash-verified

200 /// [extensions](BaseNodeExtension) via the same [`NodeHooks`] pipeline used in production,
201 /// plus an internal hook that captures the running node's transaction pool for tests.
202 async fn launch(
203 builder_config: BuilderConfig,
204 node_config: NodeConfig<BaseChainSpec>,
205 extensions: Vec<Box<dyn BaseNodeExtension>>,
206 ) -> eyre::Result<Self> {
207 clear_otel_env_vars();
208 init_silenced_tracing();
209 let runtime = RuntimeBuilder::new(RuntimeConfig::default()).build()?;
210
211 let da_config = builder_config.da_config.clone();
212 let gas_limit_config = builder_config.gas_limit_config.clone();
213 let metering_provider = Arc::clone(&builder_config.metering_provider);
214
215 let base_node = BaseNode::new(RollupArgs::default())
216 .with_da_config(da_config)
217 .with_gas_limit_config(gas_limit_config);
218
219 let service_builder = FlashblocksServiceBuilder::new(builder_config.clone());
220 let components = service_builder.build_components(&base_node);
221
222 let (txpool_ready_tx, txpool_ready_rx) =
223 oneshot::channel::<AllTransactionsEvents<BasePooledTransaction>>();
224 let (pool_handle_tx, pool_handle_rx) =
225 oneshot::channel::<Arc<dyn ExternalTransactionPool>>();
226
227 // The node types fix the database to the concrete `DatabaseEnv`, so the test database must
228 // be a bare `DatabaseEnv` (not a `TempDatabase`) for the extension hook types to line up.
229 let (db, db_dir) = create_test_db_env(node_config.clone())?;
230
231 let builder = NodeBuilder::<_, BaseChainSpec>::new(node_config.clone())
232 .with_database(db)
233 .with_launch_context(runtime.clone())
234 .with_types_and_provider::<BaseNode, BlockchainProvider<_>>()
235 .with_components(components)
236 .with_add_ons(base_node.add_ons())
237 .on_component_initialized(move |_ctx| Ok(()));
238
239 // Apply caller-supplied extensions through the production hook pipeline, then append an
240 // internal node-started hook that captures the running node's transaction pool.
241 let hooks = extensions.into_iter().fold(NodeHooks::new(), |hooks, ext| ext.apply(hooks));
242 let hooks = hooks.add_node_started_hook(move |full_node| {
243 if txpool_ready_tx.send(full_node.pool.all_transactions_event_listener()).is_err() {
244 tracing::warn!("txpool ready receiver dropped before node-started hook fired");
245 }
246 let pool_handle: Arc<dyn ExternalTransactionPool> =
247 Arc::new(PoolHandle { pool: full_node.pool });
248 if pool_handle_tx.send(pool_handle).is_err() {
249 tracing::warn!("pool handle receiver dropped before node-started hook fired");
250 }
251 Ok(())
252 });
253
254 let node_handle = hooks.apply_to(builder).launch().await?;
255 let exit_future = node_handle.node_exit_future;
256 let node_handle: Box<dyn Any + Send> = Box::new(node_handle.node);
257
258 // Wait for the node-started hook to publish the pool handles.
259 let pool_monitor = txpool_ready_rx.await.expect("Failed to receive txpool ready signal");

Callers

nothing calls this directly

Calls 15

init_silenced_tracingFunction · 0.85
create_test_db_envFunction · 0.85
add_node_started_hookMethod · 0.80
apply_toMethod · 0.80
clear_otel_env_varsFunction · 0.70
newFunction · 0.50
buildMethod · 0.45
cloneMethod · 0.45
with_gas_limit_configMethod · 0.45
with_da_configMethod · 0.45
build_componentsMethod · 0.45

Tested by

no test coverage detected