Skip to content

Commit

Permalink
Fix unresolvable key endianness
Browse files Browse the repository at this point in the history
  • Loading branch information
Wollac committed Jan 29, 2025
1 parent 3f3c673 commit cb443ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/core/src/mpt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::map::B256Set;
use alloy_primitives::{B256, U256};
use alloy_primitives::B256;
use alloy_rlp::{Decodable, Encodable};
use risc0_ethereum_trie::{orphan, CachedTrie};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -55,7 +55,7 @@ impl<T: Decodable + Encodable> MptNode<T> {
&mut self,
key: K,
post_state_proof: impl IntoIterator<Item = N>,
unresolvable: &mut B256Set,
unresolvable_keys: &mut B256Set,
) -> alloy_rlp::Result<()>
where
K: AsRef<[u8]>,
Expand All @@ -65,8 +65,8 @@ impl<T: Decodable + Encodable> MptNode<T> {
Ok(_) => {}
Err(orphan::Error::Unresolvable(nibbles)) => {
// convert the unresolvable nibbles into B256 with zero padding
let key = B256::from(U256::from_le_slice(&nibbles.pack()));
unresolvable.insert(key);
let unresolvable = B256::right_padding_from(&nibbles.pack());
unresolvable_keys.insert(unresolvable);
}
Err(orphan::Error::RlpError(err)) => return Err(err),
};
Expand Down
7 changes: 6 additions & 1 deletion crates/preflight/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use alloy::primitives::map::HashMap;
use alloy::primitives::{Address, B256, U256};
use alloy::rpc::types::EIP1186AccountProofResponse;
use anyhow::Context;
use log::error;
use log::{debug, error};
use reth_primitives::revm_primitives::{Account, AccountInfo, Bytecode};
use reth_revm::db::states::StateChangeset;
use reth_revm::db::CacheDB;
Expand Down Expand Up @@ -267,6 +267,7 @@ impl<N: Network, R: CoreDriver, P: PreflightDriver<R, N>> PreflightDB<N, R, P> {
let mut provider = provider_db.provider.borrow_mut();
let block_no = initial_db.db.borrow_db().block_no + block_count - 1;

debug!("getting next account: start={}", start);
let address = provider
.get_next_account(&AccountRangeQuery::new(block_no, start))
.context("debug_accountRange call failed")?;
Expand Down Expand Up @@ -299,6 +300,10 @@ impl<N: Network, R: CoreDriver, P: PreflightDriver<R, N>> PreflightDB<N, R, P> {

let mut indices = BTreeSet::new();
for start in starts {
debug!(
"getting next storage key: address={},start={}",
address, start
);
let slot = provider
.get_next_slot(&StorageRangeQuery::new(block_no, address, start))
.context("debug_storageRangeAt call failed")?;
Expand Down

0 comments on commit cb443ba

Please sign in to comment.