Starts an in-process builder node with the provided configuration.
(config: InProcessBuilderConfig)
| 90 | impl InProcessBuilder { |
| 91 | /// Starts an in-process builder node with the provided configuration. |
| 92 | pub async fn start(config: InProcessBuilderConfig) -> Result<Self> { |
| 93 | clear_otel_env_vars(); |
| 94 | |
| 95 | let tempdir = std::env::temp_dir(); |
| 96 | let random_id = nanoid!(); |
| 97 | let data_path = tempdir.join(format!("in-process-builder.{random_id}")); |
| 98 | let jwt_path = data_path.join("jwt.hex"); |
| 99 | |
| 100 | std::fs::create_dir_all(&data_path).wrap_err("Failed to create data directory")?; |
| 101 | std::fs::write(&jwt_path, config.jwt_secret.as_bytes().encode_hex().as_bytes()) |
| 102 | .wrap_err("Failed to write JWT secret")?; |
| 103 | |
| 104 | let runtime = RuntimeBuilder::new(RuntimeConfig::default()).build()?; |
| 105 | |
| 106 | let chain_spec = parse_genesis(&config.genesis_json)?; |
| 107 | |
| 108 | let flashblocks_port = config.flashblocks_port.unwrap_or_else(get_available_port); |
| 109 | let builder_config = BuilderConfig { |
| 110 | block_time: Duration::from_millis(2000), |
| 111 | flashblocks_ws_addr: SocketAddr::new(Ipv4Addr::LOCALHOST.into(), flashblocks_port), |
| 112 | flashblocks_interval: Duration::from_millis(200), |
| 113 | ..Default::default() |
| 114 | }; |
| 115 | |
| 116 | let flashblocks_ws_addr = builder_config.flashblocks_ws_addr; |
| 117 | |
| 118 | let da_config = builder_config.da_config.clone(); |
| 119 | let gas_limit_config = builder_config.gas_limit_config.clone(); |
| 120 | |
| 121 | let rollup_args = RollupArgs::default(); |
| 122 | |
| 123 | let base_node = BaseNode::new(rollup_args.clone()); |
| 124 | |
| 125 | let addons: base_node_runner::BaseAddOns< |
| 126 | _, |
| 127 | base_execution_rpc::BaseEthApiBuilder, |
| 128 | base_node_core::BasePayloadValidatorBuilder, |
| 129 | > = base_node |
| 130 | .add_ons_builder() |
| 131 | .with_sequencer(rollup_args.sequencer.clone()) |
| 132 | .with_da_config(da_config) |
| 133 | .with_gas_limit_config(gas_limit_config) |
| 134 | .build(); |
| 135 | |
| 136 | let (db, _db_path) = create_test_db(&data_path)?; |
| 137 | |
| 138 | let node_config = create_node_config(chain_spec, &data_path, &jwt_path, &config)?; |
| 139 | let p2p_port = node_config.network.port; |
| 140 | |
| 141 | let node_builder = NodeBuilder::new(node_config.clone()) |
| 142 | .with_database(db) |
| 143 | .with_launch_context(runtime.clone()) |
| 144 | .with_types::<BaseNode>() |
| 145 | .with_components( |
| 146 | base_node |
| 147 | .components() |
| 148 | .pool(pool_component(&rollup_args)) |
| 149 | .payload(FlashblocksServiceBuilder(builder_config)), |
nothing calls this directly
no test coverage detected