Last active
September 18, 2025 19:51
-
-
Save 0xvangrim/6822b607e196aff4c5fce1e0033982a4 to your computer and use it in GitHub Desktop.
ChainSpec mismatch in Malda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// PoC: SOURCE=ETH, DEST=Linea, no L1 inclusion → routes to hardcoded Linea ChainSpec branch | |
| /// This demonstrates the wrong-spec code path without relying on on-chain verification. | |
| /// It confirms: | |
| /// - Non-OpStack path (OpEvmInput is None) | |
| /// - Validators later expect ETH_MAINNET_CHAIN_SPEC for SOURCE=ETH | |
| /// - The builder else-branch used LINEA_MAINNET_CHAIN_SPEC (hardcoded) | |
| #[tokio::test] | |
| async fn test_poc_wrong_chain_spec_eth_non_opstack_no_inclusion() { | |
| use alloy::transports::http::reqwest::Url; | |
| use risc0_steel::ethereum::{EthEvmEnv, ETH_MAINNET_CHAIN_SPEC}; | |
| use risc0_steel::host::BlockNumberOrTag as BlockRisc0; | |
| // Requires: export RPC_URL_ETHEREUM | |
| let latest_block = EthEvmEnv::builder() | |
| .rpc(Url::parse(get_rpc_url("ETHEREUM", false, false)).unwrap()) | |
| .block_number_or_tag(BlockRisc0::Latest) | |
| .chain_spec(Ð_MAINNET_CHAIN_SPEC) | |
| .build() | |
| .await | |
| .unwrap() | |
| .header() | |
| .inner() | |
| .inner() | |
| .number; | |
| // SOURCE = ETHEREUM_CHAIN_ID, DEST = Linea (passed per-call), no L1 inclusion | |
| let (env_eth_opt, env_op_opt) = get_proof_data_call_input( | |
| ETHEREUM_CHAIN_ID, | |
| get_rpc_url("ETHEREUM", false, false), | |
| latest_block, | |
| vec![USER], | |
| vec![WETH_MARKET_SEPOLIA], | |
| vec![LINEA_CHAIN_ID], | |
| false, | |
| false, | |
| ) | |
| .await; | |
| // Non-OpStack branch → OpEvmInput should be None | |
| assert!(env_op_opt.is_none(), "unexpected OpEvmInput returned for ETH non-OpStack path"); | |
| // Materialize the returned input under ETH spec (validator expectation for SOURCE=ETH) | |
| let env_input = env_eth_opt.expect("env input missing for ETH path"); | |
| let _env_expected = env_input.clone().into_env(Ð_MAINNET_CHAIN_SPEC); | |
| // Also materialize under LINEA spec to illustrate the ambiguity introduced by the builder's else-branch | |
| // (the else-branch in viewcalls.rs uses LINEA_MAINNET_CHAIN_SPEC for non-OpStack/no-inclusion) | |
| let _env_built_linea = env_input.into_env(&LINEA_MAINNET_CHAIN_SPEC); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment