Skip to content

Commit 6695289

Browse files
authored
fix(target_chains/fuel): fuel merkle verification (#1620)
* fix(target_chains/fuel): fuel merkle verification * fix pre-commit
1 parent c0a4ab0 commit 6695289

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

target_chains/fuel/contracts/pyth-contract/src/data_structures/price.sw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl PriceFeed {
297297
let (_, slice) = encoded_proof.split_at(current_offset);
298298
let (encoded_message, _) = slice.split_at(message_size);
299299
current_offset += message_size;
300-
let end_offset = validate_proof(encoded_proof, encoded_message, current_offset, digest);
300+
let end_offset = validate_proof(encoded_proof, current_offset, digest, encoded_message);
301301
// Message type of 0 is a Price Feed
302302
require(
303303
encoded_message

target_chains/fuel/contracts/pyth-contract/src/pyth_merkle_proof.sw

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ fn node_hash(child_a: Bytes, child_b: Bytes) -> Bytes {
3737

3838
pub fn validate_proof(
3939
encoded_proof: Bytes,
40-
leaf_data: Bytes,
4140
ref mut proof_offset: u64,
4241
root: Bytes,
42+
leaf_data: Bytes,
4343
) -> u64 {
4444
let mut current_digest = leaf_hash(leaf_data);
4545

@@ -51,14 +51,14 @@ pub fn validate_proof(
5151
let (_, slice) = encoded_proof.split_at(proof_offset);
5252
let (sibling_digest, _) = slice.split_at(20);
5353
proof_offset += 20;
54-
5554
current_digest = node_hash(current_digest, sibling_digest);
56-
5755
i += 1;
5856
}
5957

60-
// TODO: investigate failing require statement on the accumulator update path.
61-
// require(current_digest == root, PythError::InvalidProof);
58+
let current_digest_b256: b256 = current_digest.into();
59+
let root_b256: b256 = root.into();
60+
61+
require(current_digest_b256 == root_b256, PythError::InvalidProof);
6262

6363
proof_offset
6464
}

0 commit comments

Comments
 (0)