Skip to content

Conversation

@ayushboss
Copy link
Contributor

Summary

refactored some of the byte conversions to avoid conversion issues.

Rationale

Merkle hashes are 20 hex digits long, and old versions of Sway could autoconvert those to b256s during the merkle parsing and confirmation. The update to fuel get rid of that, so I initially replaced that conversion with a simple from_be_bytes, but that method needs an input with 32 bytes. To remedy that, I padded those merkle proofs before conversion.

Additionally, the beta 5 fuel test net endpoint is not up anymore, so I replaced it with the testnet.fuel.network endpoint in the deployment script.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

Confirmed deployment on Fuel testnet. Additional diagnostic updates and get_price passes as well

@vercel
Copy link

vercel bot commented Jul 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am
developer-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am
entropy-debugger ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am
entropy-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 6:09am

Comment on lines 23 to 40
let a: b256 = b256::from_be_bytes(child_a.clone());
let b: b256 = b256::from_be_bytes(child_b.clone());
let mut full_address_child_a = Bytes::with_capacity(32);
let mut full_address_child_b = Bytes::with_capacity(32);

// Pad with 12 zeros (32 - 20 = 12)
let mut i = 0;
while i < 12 {
full_address_child_a.push(0u8);
full_address_child_b.push(0u8);
i += 1;
}

// Append the 20-byte data
full_address_child_a.append(child_a);
full_address_child_b.append(child_b);

// Convert to b256
let a: b256 = b256::from_be_bytes(full_address_child_a);
let b: b256 = b256::from_be_bytes(full_address_child_b);
Copy link
Contributor

Choose a reason for hiding this comment

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

How did the b256::from_be_bytes behavior change? Previously it was happy with fewer than 32 bytes as input and it would left-pad zeroes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so before we updated fuel it used .into(), but i think they removed that conversion trait in the update. afterwards, i switched it to from_be_bytes, and it seemingly passed all the build tests but when it actually did result in errors when i deployed

devin-ai-integration bot and others added 2 commits July 31, 2025 21:10
- Remove incorrect right shift operation (key.rsh(96)) that was removing guardian data
- Guardian keys now correctly have 12 zero bytes + 20 data bytes instead of 24 zero bytes + 8 data bytes
- Fixes functions::wormhole_guardians::guardian_set::success::upgrade_guardian_set test failure
- The split_at(20) crash was caused by incorrect key processing, not insufficient slice bytes

Co-Authored-By: [email protected] <[email protected]>
…rdian-set-split-at-crash

Fix guardian set parsing crash in Fuel contracts
new_guardian_set.keys.push(key.rsh(96));
let mut full_address_key = Bytes::with_capacity(32);

// Sway's from_be_bytes expects a 32-byte array, so we pad with zeros
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like this is repeated in several places, maybe a helper function would be good?

@ayushboss ayushboss merged commit 1b84cca into main Aug 1, 2025
12 checks passed
@ayushboss ayushboss deleted the fuel-deployment-fixes branch August 1, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants