{"record":{"id":"c7727958a0be354d","repo":"linera-io/linera-protocol","slug":"returned-accountinfo-should-have-code-some-a-c77279","errorCode":null,"errorMessage":"Returned AccountInfo should have code: Some(...) and so code_by_hash should never be called","messagePattern":"Returned AccountInfo should have code: Some\\(\\.\\.\\.\\) and so code_by_hash should never be called","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"linera-execution/src/evm/database.rs","lineNumber":846,"sourceCode":"    }\n\n    fn block_hash_ref(&self, number: u64) -> Result<B256, ExecutionError> {\n        Ok(keccak256(number.to_string().as_bytes()))\n    }\n}\n\nimpl<Runtime> Database for ContractDatabase<Runtime>\nwhere\n    Runtime: ContractRuntime,\n{\n    type Error = ExecutionError;\n\n    fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, ExecutionError> {\n        self.basic_ref(address)\n    }\n\n    fn code_by_hash(&mut self, _code_hash: B256) -> Result<Bytecode, ExecutionError> {\n        panic!(\"Returned AccountInfo should have code: Some(...) and so code_by_hash should never be called\");\n    }\n\n    fn storage(&mut self, address: Address, index: U256) -> Result<U256, ExecutionError> {\n        self.storage_ref(address, index)\n    }\n\n    fn block_hash(&mut self, number: u64) -> Result<B256, ExecutionError> {\n        <Self as DatabaseRef>::block_hash_ref(self, number)\n    }\n}\n\nimpl<Runtime> DatabaseCommit for ContractDatabase<Runtime>\nwhere\n    Runtime: ContractRuntime,\n{\n    fn commit(&mut self, changes: EvmState) {\n        self.inner.changes = changes;\n    }","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-execution/src/evm/database.rs#L828-L864","documentation":"The mutable (&mut self) twin of the ref variant: this Revm Database impl guarantees every AccountInfo carries its bytecode inline (code: Some), so code_by_hash is never supposed to be called and panics to say so. Reaching it indicates the engine took the by-hash code path, which the inline-code design explicitly rules out.","triggerScenarios":"A revm version whose Database/DatabaseCommit flow calls code_by_hash during execution or state loading; account-loading code that returns code: None; a custom journaled/override path that stores code by hash. Trigger is engine-internal — normal Linera EVM transactions never reach it.","commonSituations":"Bumping revm/alloy patch versions that change when the interpreter resolves code; local modifications to the EVM database glue; introducing caching layers that strip bytecode from AccountInfo.","solutions":["Revert/pin the revm and alloy versions to the ones validated for this codebase.","Audit any change to basic/basic_ref so they keep returning code: Some(bytecode).","If the upgrade is required, implement code_by_hash by reading bytecode from contract storage rather than leaving the panic."],"exampleFix":"# Cargo.toml — before (bump triggered the path)\nrevm = \"newer\"\n# after — pin to the version the database design assumes\nrevm = \"=<previously-validated-version>\"","handlingStrategy":"validation","validationCode":"# Cargo.lock discipline: pin revm & alloy to the versions the Database design assumes\ncargo update -p revm --precise <validated-version>","typeGuard":"// Test invariant: accounts loaded for revm always include their bytecode\nlet info = db.basic(addr)?.expect(\"account\");\nassert!(info.code.is_some(), \"code must be inline; code_by_hash must stay unreachable\");","tryCatchPattern":null,"preventionTips":["Treat any revm/alloy version bump as a breaking change for the EVM DB glue; run full EVM test suites.","Never strip bytecode from AccountInfo in caching/refactor layers.","Add a regression test that executes a contract after a state override if such features are enabled."],"tags":["rust","revm","evm","database","panic","dependency-upgrade"],"backgroundTag":"unimplemented-trait-method","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}