Skip to content

Commit cbf6cae

Browse files
Handle new Espresso fields in the config.
1 parent 89d8cfc commit cbf6cae

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

utils/ethereum/host/src/host.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,21 @@ impl OPSuccinctHost for SingleChainOPSuccinctHost {
5252
fetcher: &OPSuccinctDataFetcher,
5353
_: u64,
5454
) -> Result<Option<u64>> {
55-
let finalized_l2_block_number = fetcher.get_l2_header(BlockId::finalized()).await?;
56-
Ok(Some(finalized_l2_block_number.number))
55+
// Use safe head instead of finalized for devnet/testing scenarios where
56+
// altDA finalization may not be working properly.
57+
// Controlled by USE_SAFE_HEAD_FOR_PROPOSALS env var.
58+
let use_safe_head = std::env::var("USE_SAFE_HEAD_FOR_PROPOSALS")
59+
.map(|v| v.to_lowercase() == "true" || v == "1")
60+
.unwrap_or(false);
61+
62+
let block_id = if use_safe_head {
63+
BlockId::safe()
64+
} else {
65+
BlockId::finalized()
66+
};
67+
68+
let l2_block_number = fetcher.get_l2_header(block_id).await?;
69+
Ok(Some(l2_block_number.number))
5770
}
5871

5972
async fn calculate_safe_l1_head(

utils/host/src/fetcher.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,22 @@ impl OPSuccinctDataFetcher {
313313
async fn fetch_and_save_rollup_config(
314314
rpc_config: &RPCConfig,
315315
) -> Result<(CeloRollupConfig, PathBuf)> {
316-
let rollup_config: CeloRollupConfig =
316+
// Fetch raw JSON first to handle unknown fields (e.g., Espresso's batch_authenticator_address)
317+
let mut raw_config: Value =
317318
Self::fetch_rpc_data(&rpc_config.l2_node_rpc, "optimism_rollupConfig", vec![]).await?;
318319

320+
// Strip unknown fields that are not part of the standard rollup config
321+
// This allows compatibility with Espresso and other forks that add custom fields
322+
if let Some(obj) = raw_config.as_object_mut() {
323+
// Remove Espresso-specific fields that CeloRollupConfig doesn't recognize
324+
obj.remove("batch_authenticator_address");
325+
obj.remove("caff_node_config");
326+
}
327+
328+
// Deserialize the cleaned config
329+
let rollup_config: CeloRollupConfig = serde_json::from_value(raw_config.clone())
330+
.with_context(|| format!("Failed to parse rollup config: {:?}", raw_config))?;
331+
319332
// Create configs directory if it doesn't exist
320333
let rollup_config_dir = PathBuf::from("configs/L2");
321334
fs::create_dir_all(&rollup_config_dir)?;

0 commit comments

Comments
 (0)