{"record":{"id":"040678cd138f3752","repo":"nautechsystems/nautilus_trader","slug":"chain-anchor-id-must-be-nonzero","errorCode":null,"errorMessage":"Chain anchor ID must be nonzero","messagePattern":"Chain anchor ID must be nonzero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/rpc/verification.rs","lineNumber":1213,"sourceCode":"            anyhow::ensure!(\n                identities[right]\n                    .failure_domain_ids\n                    .iter()\n                    .all(|domain| !left_domains.contains(domain)),\n                \"Provider failure domains must be pairwise disjoint\"\n            );\n        }\n    }\n\n    let endpoints = [\n        normalize_endpoint(authoritative_url)?,\n        normalize_endpoint(config.verifiers[0].http_rpc_url.expose_secret())?,\n        normalize_endpoint(config.verifiers[1].http_rpc_url.expose_secret())?,\n    ];\n    ensure_distinct(endpoints.iter().map(String::as_str), \"provider endpoints\")?;\n\n    let anchor = &config.chain_anchor;\n    anyhow::ensure!(anchor.chain_id != 0, \"Chain anchor ID must be nonzero\");\n    anyhow::ensure!(\n        !anchor.chain_name.trim().is_empty(),\n        \"Chain anchor name is required\"\n    );\n    let checkpoint_hash = B256::from_str(&anchor.checkpoint_hash)\n        .map_err(|_| anyhow::anyhow!(\"Chain checkpoint hash must contain 32 hexadecimal bytes\"))?;\n    anyhow::ensure!(\n        checkpoint_hash != B256::ZERO,\n        \"Chain checkpoint hash must be nonzero\"\n    );\n    anyhow::ensure!(\n        anchor.max_head_skew_blocks != 0\n            && anchor.max_head_age_secs != 0\n            && anchor.max_future_drift_secs != 0,\n        \"Chain head skew, age, and future-drift limits must be nonzero\"\n    );\n    anyhow::ensure!(\n        !config.manifest_version.trim().is_empty(),","sourceCodeStart":1195,"sourceCodeEnd":1231,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/rpc/verification.rs#L1195-L1231","documentation":"`validate_config` requires `config.chain_anchor.chain_id` to be nonzero. A zero chain ID is never a valid EVM chain identifier and would make anchor verification meaningless, so it is rejected up front. The error is thrown by `anyhow::ensure!` when `anchor.chain_id == 0`.","triggerScenarios":"Loading a verification config where `verification.chain_anchor.chain_id` is 0, omitted and defaulted to 0, or left as a placeholder value.","commonSituations":"Copy-pasting a config template without filling in the chain ID; deserializing a JSON/TOML block where the field is absent and defaults to 0; targeting a dev/test chain and mistyping the ID; using 0 as a 'not set yet' sentinel.","solutions":["Set `chain_anchor.chain_id` to the actual EIP-155 chain ID of the target network (e.g. 1 for Ethereum mainnet).","Query the target RPC (`eth_chainId`) to confirm the correct value before configuring.","Ensure the config deserializer surfaces missing/absent fields instead of silently defaulting chain_id to 0.","Replace any 0 placeholder with the real value before deploying."],"exampleFix":"// before\n[verification.chain_anchor]\nchain_id = 0\n\n// after\n[verification.chain_anchor]\nchain_id = 1","handlingStrategy":"validation","validationCode":"fn check_chain_id(anchor: &ChainAnchor) -> Result<(), String> {\n    if anchor.chain_id == 0 {\n        return Err(\"chain_anchor.chain_id must be a nonzero EIP-155 chain ID\".into());\n    }\n    Ok(())\n}","typeGuard":"fn has_valid_chain_id(anchor: &ChainAnchor) -> bool {\n    anchor.chain_id != 0\n}","tryCatchPattern":"match validate_config(&cfg) {\n    Err(e) if e.to_string().contains(\"Chain anchor ID must be nonzero\") => {\n        eprintln!(\"Set verification.chain_anchor.chain_id to the real chain ID: {e}\");\n        std::process::exit(1);\n    }\n    other => other,\n}","preventionTips":["Fill chain_id from the output of `eth_chainId` against the configured RPC endpoints.","Reject zero-valued required numeric fields in your config linter before deployment.","Never use 0 as a placeholder or 'unset' sentinel for chain IDs in templates."],"tags":["config","validation","blockchain"],"backgroundTag":"invalid-config-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}