{"record":{"id":"4e7414a2dce2a30f","repo":"FuelLabs/fuel-core","slug":"the-genesis-block-height-is-not-found-in-the-datab","errorCode":null,"errorMessage":"The genesis block height is not found in the database during overriding the chain config hash.","messagePattern":"The genesis block height is not found in the database during overriding the chain config hash\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fuel-core/src/service.rs","lineNumber":365,"sourceCode":"        Ok(())\n    }\n\n    fn override_chain_config_if_needed(&self) -> anyhow::Result<()> {\n        let chain_config = self.shared.config.snapshot_reader.chain_config();\n        let on_chain_view = self.shared.database.on_chain().latest_view()?;\n        let chain_config_hash = chain_config.root()?.into();\n        let mut initialized_genesis = on_chain_view.get_genesis()?;\n        let genesis_chain_config_hash = initialized_genesis.chain_config_hash;\n\n        if genesis_chain_config_hash != chain_config_hash {\n            tracing::warn!(\n                \"The genesis chain config hash({genesis_chain_config_hash}) \\\n                is different from the current one({chain_config_hash}). \\\n                Updating the genesis consensus parameters.\"\n            );\n\n            let genesis_block_height =\n                on_chain_view.genesis_height()?.ok_or(anyhow::anyhow!(\n                    \"The genesis block height is not found in the database \\\n                    during overriding the chain config hash.\"\n                ))?;\n            let mut database_tx = on_chain_view.read_transaction();\n\n            initialized_genesis.chain_config_hash = chain_config_hash;\n            database_tx\n                .storage_as_mut::<SealedBlockConsensus>()\n                .insert(\n                    &genesis_block_height,\n                    &Consensus::Genesis(initialized_genesis),\n                )?;\n\n            self.shared.database.on_chain().data.commit_changes(\n                Some(genesis_block_height),\n                StorageChanges::Changes(database_tx.into_changes()),\n            )?;\n        }","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/FuelLabs/fuel-core/blob/b9d4d170da3a31c9ace5f963d633b326348e0d42/crates/fuel-core/src/service.rs#L347-L383","documentation":"Thrown by override_chain_config_if_needed (crates/fuel-core/src/service.rs:365). When the chain config root hash differs from the chain_config_hash stored in the genesis consensus, the node rewrites the SealedBlockConsensus genesis entry at the stored genesis height. on_chain_view.genesis_height() returned None: the database yields a genesis object but no recorded genesis block height, so the update target is missing and startup fails.","triggerScenarios":"Starting with a changed chain config (edited chain_config.json or different --chain-config) against an on-chain database whose genesis state is half-written: get_genesis() succeeds but genesis_height() is None.","commonSituations":"Process crash/kill during first-time genesis initialization; a pruned, partially copied, or restored-from-inconsistent-snapshot database; mixing DB directories between chains or node versions.","solutions":["Wipe the on-chain database directory and let the node re-execute genesis with the new chain config","Restore the database from a consistent snapshot taken after genesis was fully committed","If the config change was accidental, revert to the chain config whose hash matches the DB (the mismatching hashes are printed in the preceding warn log)"],"exampleFix":"# before: fuel run --chain-config new-config.json  (old DB present, fails)\n# after:  stop node, remove the DB dir (default ~/.fuel/db and cohort dirs), then:\n#         fuel run --chain-config new-config.json  (genesis re-executed)","handlingStrategy":"validation","validationCode":"let view = db.on_chain().latest_view()?;\nif view.get_genesis().is_ok() {\n    let has_height = view.genesis_height()?.is_some();\n    anyhow::ensure!(has_height,\n        \"inconsistent DB: genesis present but genesis_height missing; re-init before changing chain config\");\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = node.check_and_override_chain_config() {\n    if e.to_string().contains(\"genesis block height is not found\") {\n        // half-initialized DB: only real fix is wipe + re-execute genesis\n    }\n}","preventionTips":["Take DB snapshots only after a fully committed genesis (node fully started once)","When switching chain configs, verify the DB was initialized and stopped cleanly first","Watch the 'different from the current one' warn log: it precedes every rewrite and tells you a config/DB mismatch exists"],"tags":["fuel-core","genesis","database","chain-config","startup"],"backgroundTag":null,"analyzedSha":"b9d4d170da3a31c9ace5f963d633b326348e0d42","analyzedAt":"2026-08-16T08:56:42.692Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}