Skip to content

Commit 80bcbed

Browse files
fix: process nullish code hash from proof
1 parent c6340a4 commit 80bcbed

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

revm-utils/src/proof_db.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use alloy::{
66
};
77
use eyre::Result;
88
use revm::{
9-
primitives::{address, Address, B256, U256},
9+
primitives::{address, Address, B256, KECCAK_EMPTY, U256},
1010
state::{AccountInfo, Bytecode},
1111
Database,
1212
};
@@ -112,10 +112,19 @@ impl<N: NetworkSpec, E: ExecutionProvider<N>> EvmState<N, E> {
112112

113113
pub fn get_basic(&mut self, address: Address) -> Result<AccountInfo, DatabaseError> {
114114
if let Some(account) = self.accounts.get(&address) {
115+
// Normalize code_hash for REVM compatibility:
116+
// RPC response for getProof method for non-existing (unused) EOAs
117+
// may contain B256::ZERO for code_hash, but REVM expects KECCAK_EMPTY
118+
let code_hash = if account.account.code_hash == B256::ZERO {
119+
KECCAK_EMPTY
120+
} else {
121+
account.account.code_hash
122+
};
123+
115124
Ok(AccountInfo::new(
116125
account.account.balance,
117126
account.account.nonce,
118-
account.account.code_hash,
127+
code_hash,
119128
Bytecode::new_raw(account.code.as_ref().unwrap().clone()),
120129
))
121130
} else {

0 commit comments

Comments
 (0)