Skip to content

refactor(fuel): configuring forc and fuel-core upgrades to the Pyth fuel contract #2858

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

Merged
merged 5 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
99 changes: 89 additions & 10 deletions target_chains/fuel/contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 14 additions & 24 deletions target_chains/fuel/contracts/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
[[package]]
name = "core"
source = "path+from-root-8357A6DDC5F39D14"
name = "ownership"
version = "0.26.0"
source = "registry+ownership?0.26.0#QmbVoNUrvCTyQTdE8ZP83XxTQQVzhrevfMqk1rAJAkMFVo!"
dependencies = [
"src5",
"std",
]

[[package]]
name = "pyth-contract"
source = "member"
dependencies = [
"ownership",
"pyth_interface",
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae",
"src5",
"std",
"sway_libs",
]

[[package]]
name = "pyth_interface"
source = "path+from-root-555D3D27A908977B"
dependencies = [
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae",
"std",
]

[[package]]
name = "standards"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2"
dependencies = ["std"]

[[package]]
name = "standards"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae"
name = "src5"
version = "0.8.0"
source = "registry+src5?0.8.0#QmNRPZrPHFBiEAyWPU8gesdPsD2zb3cMKwEgxJwV1ZEjyD!"
dependencies = ["std"]

[[package]]
name = "std"
source = "git+https://github.com/fuellabs/sway?tag=v0.65.2#66bb430395daf5b8f7205f7b9d8d008e2e812d54"
dependencies = ["core"]

[[package]]
name = "sway_libs"
source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.21.0#6a227ed34c86fe1ebd334dbdfeccf66c43e3915b"
dependencies = [
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2",
"std",
]
version = "0.68.9"
source = "registry+std?0.68.9#QmUaBxMs2JvY1bXgRCdeCsG3o6TN82ftRgv4Tq7ytqUGUT!"
6 changes: 3 additions & 3 deletions target_chains/fuel/contracts/fuel-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[toolchain]
channel = "latest-aarch64-apple-darwin"
channel = "mainnet"

[components]
forc = "0.65.2"
fuel-core = "0.37.1"
forc = "0.68.9"
fuel-core = "0.43.2"
4 changes: 2 additions & 2 deletions target_chains/fuel/contracts/pyth-contract/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ license = "Apache-2.0"
name = "pyth-contract"

[dependencies]
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.21.0" }
pyth_interface = { path = "../pyth-interface" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" }
ownership = "0.26.0"
src5 = "0.8.0"
10 changes: 5 additions & 5 deletions target_chains/fuel/contracts/pyth-contract/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ use pyth_interface::{
WormholeGuardians,
};

use sway_libs::ownership::*;
use standards::src5::{SRC5, State};
use ownership::*;
use src5::{SRC5, State};

const GUARDIAN_SET_EXPIRATION_TIME_SECONDS: u64 = 86400; // 24 hours in seconds
configurable {
Expand Down Expand Up @@ -209,7 +209,7 @@ impl PythCore for Contract {
while i_2 < number_of_attestations {
let (_, slice) = vm.payload.split_at(attestation_index + 32);
let (price_feed_id, _) = slice.split_at(32);
let price_feed_id: PriceFeedId = price_feed_id.into();
let price_feed_id: PriceFeedId = b256::from_le_bytes(price_feed_id.clone());

if price_feed_id.is_target(target_price_feed_ids) == false {
attestation_index += attestation_size_u16;
Expand Down Expand Up @@ -374,7 +374,7 @@ fn update_fee(update_data: Vec<Bytes>) -> u64 {
total_fee(total_number_of_updates, storage.single_update_fee)
}

#[storage(read, write), payable]
#[storage(read, write)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing I wanted a second opinion on: one of the new issues that was introduced was that helper functions cannot be listed as "payable" anymore (only functions within the abi are allowed to have that tag). Leaving the tag in there stops the forc build. Removing the tag allows it to build, and all integration tests still pass. I still wanted to make sure that this is a valid removal (i.e. does the payable trait pass down from its calling function).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah i believe it is ok, i think Fuel has borrowed some semantics from EVM (just as it is a layer 2) and in EVM entrypoint functions that are not payable always check that msg.value == 0

fn update_price_feeds(update_data: Vec<Bytes>) {
require(
msg_asset_id() == AssetId::base(),
Expand Down Expand Up @@ -934,4 +934,4 @@ fn verify_governance_vm(encoded_vm: Bytes) -> WormholeVM {

set_last_executed_governance_sequence(vm.sequence);
vm
}
}
3 changes: 0 additions & 3 deletions target_chains/fuel/contracts/pyth-interface/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ authors = ["Fuel Labs <[email protected]>"]
entry = "interface.sw"
license = "Apache-2.0"
name = "pyth_interface"

[dependencies]
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" }
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl GovernanceInstruction {
index += 2;
let (_, slice) = encoded_payload.split_at(index);
let (slice, _) = slice.split_at(32);
let emitter_address: b256 = slice.into();
let emitter_address: b256 = b256::from_le_bytes(slice.clone());
index += 32;

data_sources.push(DataSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library;

use std::{bytes::Bytes, block::timestamp};
use std::{bytes::Bytes, block::timestamp, bytes_conversions::b256::*};

use ::errors::PythError;
use ::utils::absolute_of_exponent;
Expand Down Expand Up @@ -99,7 +99,7 @@ impl PriceFeed {
let mut offset = 1u64;
let (_, slice) = encoded_price_feed.split_at(offset);
let (price_feed_id, _) = slice.split_at(32);
let price_feed_id: PriceFeedId = price_feed_id.into();
let price_feed_id: PriceFeedId = b256::from_le_bytes(price_feed_id.clone());
offset += 32;
let price = u64::from_be_bytes([
encoded_price_feed.get(offset).unwrap(),
Expand Down Expand Up @@ -186,7 +186,7 @@ impl PriceFeed {
let mut attestation_index = index + 32;
let (_, slice) = encoded_payload.split_at(attestation_index);
let (price_feed_id, _) = slice.split_at(32);
let price_feed_id: PriceFeedId = price_feed_id.into();
let price_feed_id: PriceFeedId = b256::from_le_bytes(price_feed_id.clone());
attestation_index += 32;
let mut price = u64::from_be_bytes([
encoded_payload.get(attestation_index).unwrap(),
Expand Down Expand Up @@ -321,7 +321,7 @@ impl PriceFeed {
}

impl PriceFeed {
pub fn extract_from_merkle_proof(digest: Bytes, encoded_proof: Bytes, offset: u64) -> (u64, self) {
pub fn extract_from_merkle_proof(digest: Bytes, encoded_proof: Bytes, offset: u64) -> (u64, Self) {
// In order to avoid `ref mut` param related MemoryWriteOverlap error
let mut current_offset = offset;

Expand Down
Loading
Loading