Fix guardian set parsing crash in Fuel contracts #2916
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a guardian set parsing issue in Fuel contracts that was causing the
upgrade_guardian_set
test to fail. The issue was in the key processing logic where a right shift operation was incorrectly removing guardian data, resulting in malformed guardian keys.Key change: Removed
key.rsh(96)
operation in the guardian parsing loop inwormhole_light.sw
.Rationale
The
functions::wormhole_guardians::guardian_set::success::upgrade_guardian_set
test was failing due to guardian key format mismatch:Root cause analysis:
key.rsh(96)
was then applied, which shifted out the actual guardian data (96 bits = 12 bytes)The right shift operation was removing the very data it was supposed to preserve, causing the assertion failure in the test.
How has this been tested?
Testing performed:
test functions::wormhole_guardians::guardian_set::success::upgrade_guardian_set ... ok
forc build --release
cargo clean
and full rebuild to ensure changes are properly compiledHuman Review Checklist
key.rsh(96)
was originally implemented - there may have been a specific reason for the bit manipulation that I missedFiles changed:
target_chains/fuel/contracts/pyth-interface/src/data_structures/wormhole_light.sw
(1 line changed)Link to Devin run: https://app.devin.ai/sessions/138bbf1fd9de463989700f2478fae68e
Requested by: @ayushboss