Skip to content

Commit

Permalink
fix: handle new empty account formatting (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncitron committed Oct 25, 2024
1 parent 953bdb6 commit 016af05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<N: NetworkSpec, R: ExecutionRpc<N>> ExecutionClient<N, R> {
slot_map.insert(key, storage_proof.value);
}

let code = if proof.code_hash == KECCAK_EMPTY {
let code = if proof.code_hash == KECCAK_EMPTY || proof.code_hash == B256::ZERO {
Vec::new()
} else {
let code = self.rpc.get_code(address, block.number.to()).await?;
Expand Down
12 changes: 10 additions & 2 deletions core/src/execution/proof.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy::consensus::Account;
use alloy::primitives::{b256, keccak256, Bytes, U256};
use alloy::primitives::{b256, keccak256, Bytes, B256, U256};
use alloy::rlp::{encode, Decodable};
use alloy::rpc::types::EIP1186AccountProofResponse;

Expand Down Expand Up @@ -105,10 +105,18 @@ fn is_empty_value(value: &[u8]) -> bool {
code_hash: b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"),
};

let new_empty_account = Account {
nonce: 0,
balance: U256::ZERO,
storage_root: B256::ZERO,
code_hash: B256::ZERO,
};

let empty_account = encode(empty_account);
let new_empty_account = encode(new_empty_account);

let is_empty_slot = value.len() == 1 && value[0] == 0x80;
let is_empty_account = value == empty_account;
let is_empty_account = value == empty_account || value == new_empty_account;
is_empty_slot || is_empty_account
}

Expand Down
2 changes: 1 addition & 1 deletion ethereum/consensus-core/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tree_hash::TreeHash;

use crate::{
consensus_spec::ConsensusSpec,
types::{ExecutionPayloadHeader, BeaconBlockHeader, SyncCommittee},
types::{BeaconBlockHeader, ExecutionPayloadHeader, SyncCommittee},
};

pub fn is_finality_proof_valid(
Expand Down

0 comments on commit 016af05

Please sign in to comment.