Starts a complete L2 network stack with builder, client, and all supporting services. # Errors Returns an error if any component fails to start.
(mut config: L2StackConfig)
| 194 | /// |
| 195 | /// Returns an error if any component fails to start. |
| 196 | pub async fn start(mut config: L2StackConfig) -> Result<Self> { |
| 197 | let container_config = config.container_config.as_ref(); |
| 198 | |
| 199 | let l1_rpc_url: Url = config.l1_rpc_url.parse().wrap_err("Invalid L1 RPC URL")?; |
| 200 | let l1_beacon_url: Url = config.l1_beacon_url.parse().wrap_err("Invalid L1 beacon URL")?; |
| 201 | |
| 202 | let mut rollup_config: RollupConfig = serde_json::from_slice(&config.rollup_config) |
| 203 | .wrap_err("Failed to parse rollup config")?; |
| 204 | if config.shadow_sequencers.as_ref().is_some_and(|shadow| shadow.start_block.is_some()) { |
| 205 | rollup_config.block_time = 2; |
| 206 | } |
| 207 | // op-deployer supplies the legacy interval in rollup.json, not the EL genesis. |
| 208 | let mut genesis: serde_json::Value = |
| 209 | serde_json::from_slice(&config.l2_genesis).wrap_err("Failed to parse L2 genesis")?; |
| 210 | genesis["config"]["blockTime"] = rollup_config.block_time.into(); |
| 211 | config.l2_genesis = serde_json::to_vec(&genesis)?; |
| 212 | let l1_chain_config: ChainConfig = serde_json::from_slice(&config.l1_genesis) |
| 213 | .wrap_err("Failed to parse L1 chain config")?; |
| 214 | let builder_chain_spec = |
| 215 | InProcessBuilderConfig::chain_spec_from_genesis_json(&config.l2_genesis) |
| 216 | .wrap_err("Failed to parse builder L2 chain spec")?; |
| 217 | |
| 218 | // 1. Start the builder (in-process EL). |
| 219 | let builder_config = InProcessBuilderConfig { |
| 220 | runtime: InProcessNodeRuntime::SystemTest, |
| 221 | chain_spec: builder_chain_spec, |
| 222 | datadir: config.builder_datadir, |
| 223 | jwt_secret: config.jwt_secret, |
| 224 | http_port: container_config.and_then(|c| c.builder_http_port), |
| 225 | ws_port: container_config.and_then(|c| c.builder_ws_port), |
| 226 | auth_port: container_config.and_then(|c| c.builder_auth_port), |
| 227 | p2p_port: container_config.and_then(|c| c.builder_p2p_port), |
| 228 | flashblocks_port: container_config.and_then(|c| c.builder_flashblocks_port), |
| 229 | metrics_port: None, |
| 230 | payload_builder_cutover: config.payload_builder_cutover, |
| 231 | validity_signature_mode: config.validity_signature_mode, |
| 232 | extra_extensions: config.extra_builder_extensions, |
| 233 | block_time: Duration::from_secs(rollup_config.block_time), |
| 234 | persistence_threshold: None, |
| 235 | persistence_backpressure_threshold: None, |
| 236 | txpool_max_transactions: None, |
| 237 | txpool_max_size_mb: None, |
| 238 | txpool_max_account_slots: None, |
| 239 | }; |
| 240 | let builder = InProcessBuilder::start(builder_config) |
| 241 | .await |
| 242 | .wrap_err("Failed to start in-process builder")?; |
| 243 | |
| 244 | // 2. Start builder consensus (in-process CL, Sequencer mode). |
| 245 | // The sequencer starts in stopped mode so that blocks are not produced until the |
| 246 | // validator is connected via P2P — otherwise the first blocks would be lost via gossip |
| 247 | // and the validator's EL would be unable to validate later blocks (missing parent). |
| 248 | let builder_consensus_config = InProcessConsensusConfig { |
| 249 | rollup_config: rollup_config.clone(), |
| 250 | l1_chain_config: l1_chain_config.clone(), |
| 251 | jwt_secret: config.jwt_secret, |
| 252 | l1_rpc_url: l1_rpc_url.clone(), |
| 253 | l1_beacon_url: l1_beacon_url.clone(), |
nothing calls this directly
no test coverage detected