Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl PriceFeed {
let (_, slice) = encoded_proof.split_at(current_offset);
let (encoded_message, _) = slice.split_at(message_size);
current_offset += message_size;
let end_offset = validate_proof(encoded_proof, encoded_message, current_offset, digest);
let end_offset = validate_proof(encoded_proof, current_offset, digest, encoded_message);
// Message type of 0 is a Price Feed
require(
encoded_message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ fn node_hash(child_a: Bytes, child_b: Bytes) -> Bytes {

pub fn validate_proof(
encoded_proof: Bytes,
leaf_data: Bytes,
ref mut proof_offset: u64,
root: Bytes,
leaf_data: Bytes,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by: standardizing it to be the same order as the solidity counterpart

) -> u64 {
let mut current_digest = leaf_hash(leaf_data);

Expand All @@ -51,14 +51,14 @@ pub fn validate_proof(
let (_, slice) = encoded_proof.split_at(proof_offset);
let (sibling_digest, _) = slice.split_at(20);
proof_offset += 20;

current_digest = node_hash(current_digest, sibling_digest);

i += 1;
}

// TODO: investigate failing require statement on the accumulator update path.
// require(current_digest == root, PythError::InvalidProof);
let current_digest_b256: b256 = current_digest.into();
let root_b256: b256 = root.into();

require(current_digest_b256 == root_b256, PythError::InvalidProof);

proof_offset
}