Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Wollac committed Jan 29, 2025
1 parent cb443ba commit 7a0bb55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions crates/core/src/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ impl<T: Decodable + Encodable> MptNode<T> {
&mut self,
key: K,
post_state_proof: impl IntoIterator<Item = N>,
unresolvable_keys: &mut B256Set,
unresolvable: &mut B256Set,
) -> alloy_rlp::Result<()>
where
K: AsRef<[u8]>,
N: AsRef<[u8]>,
{
match self.inner.resolve_orphan(key, post_state_proof) {
Ok(_) => {}
Err(orphan::Error::Unresolvable(nibbles)) => {
// convert the unresolvable nibbles into B256 with zero padding
let unresolvable = B256::right_padding_from(&nibbles.pack());
unresolvable_keys.insert(unresolvable);
Err(orphan::Error::Unresolvable(prefix)) => {
// convert the unresolvable prefix nibbles into a B256 key with zero padding
let key = B256::right_padding_from(&prefix.pack());
unresolvable.insert(key);
}
Err(orphan::Error::RlpError(err)) => return Err(err),
};
Expand Down
9 changes: 6 additions & 3 deletions crates/preflight/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,18 @@ where
.get_next_slot_proofs(block_count, address, unresolvable_storage_keys)
.with_context(|| format!("failed to get next slot for {}", address))?;
storage_trie
.hydrate_from_rlp(proof.storage_proof.iter().flat_map(|p| &p.proof))?;
.hydrate_from_rlp(proof.storage_proof.iter().flat_map(|p| &p.proof))
.with_context(|| format!("invalid storage proof for {}", address))?;
}
}

for state_key in unresolvable_state_keys {
let proof = preflight_db.get_next_account_proof(block_count, state_key)?;
let proof = preflight_db
.get_next_account_proof(block_count, state_key)
.context("failed to get next account")?;
state_trie
.hydrate_from_rlp(proof.account_proof)
.context("failed to get next account")?
.with_context(|| format!("invalid account proof for {}", proof.address))?;
}

info!("Saving provider cache ...");
Expand Down

0 comments on commit 7a0bb55

Please sign in to comment.