-
Notifications
You must be signed in to change notification settings - Fork 307
fix(fuel): further fixes, contract deployment #2914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
- 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 |
There was a problem hiding this comment.
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?
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?
Confirmed deployment on Fuel testnet. Additional diagnostic updates and get_price passes as well