Writes a private Compose environment with explicit scenario overrides.
(&self, config: &ScenarioConfig)
| 218 | |
| 219 | /// Writes a private Compose environment with explicit scenario overrides. |
| 220 | pub fn write_environment(&self, config: &ScenarioConfig) -> Result<()> { |
| 221 | let root = self.output.join("private/devnet").canonicalize()?; |
| 222 | if root.to_string_lossy().contains(['\n', '\r', '$', '#', '"', '\'', ',']) { |
| 223 | bail!("unsupported characters in output directory"); |
| 224 | } |
| 225 | let mut env = fs::read_to_string(self.repo.join("etc/docker/devnet-env"))?; |
| 226 | env.push_str(&format!( |
| 227 | "\nDEVNET_ROOT={}\nPROFILE=dev\nBASE_SUCCINCT_ELF_REQUIRE=0\nL1_CHAIN_ID={}\nL2_CHAIN_ID={}\nL1_SLOT_DURATION_OVERRIDE={}\nBASE_NODE_VERIFIER_L1_CONFS={}\n", |
| 228 | root.display(), |
| 229 | config.devnet.l1.chain_id, |
| 230 | config.devnet.l2.chain_id, |
| 231 | config.devnet.l1.slot_duration.0.as_secs(), |
| 232 | config.devnet.l2.verifier_l1_confirmations, |
| 233 | )); |
| 234 | for (name, activation) in &config.devnet.l2.forks { |
| 235 | env.push_str(&format!( |
| 236 | "L2_BASE_{}_BLOCK={}\n", |
| 237 | name.to_ascii_uppercase(), |
| 238 | activation.block().map_or_else(String::new, |block| block.to_string()) |
| 239 | )); |
| 240 | } |
| 241 | let path = self.output.join("private/compose.env"); |
| 242 | fs::write(&path, env)?; |
| 243 | Self::restrict(&path, false) |
| 244 | } |
| 245 | |
| 246 | /// Rejects container name collisions without adopting existing resources. |
| 247 | /// Docker assigns and binds the dynamically allocated host ports at startup. |