Skip to content

Commit b4cf10e

Browse files
authored
Merge pull request #2858 from pyth-network/fuel-fixes
refactor(fuel): configuring forc and fuel-core upgrades to the Pyth fuel contract
2 parents dc4fd5c + 10e5345 commit b4cf10e

File tree

10 files changed

+132
-64
lines changed

10 files changed

+132
-64
lines changed

target_chains/fuel/contracts/Cargo.lock

Lines changed: 89 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,34 @@
11
[[package]]
2-
name = "core"
3-
source = "path+from-root-8357A6DDC5F39D14"
2+
name = "ownership"
3+
version = "0.26.0"
4+
source = "registry+ownership?0.26.0#QmbVoNUrvCTyQTdE8ZP83XxTQQVzhrevfMqk1rAJAkMFVo!"
5+
dependencies = [
6+
"src5",
7+
"std",
8+
]
49

510
[[package]]
611
name = "pyth-contract"
712
source = "member"
813
dependencies = [
14+
"ownership",
915
"pyth_interface",
10-
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae",
16+
"src5",
1117
"std",
12-
"sway_libs",
1318
]
1419

1520
[[package]]
1621
name = "pyth_interface"
1722
source = "path+from-root-555D3D27A908977B"
18-
dependencies = [
19-
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae",
20-
"std",
21-
]
22-
23-
[[package]]
24-
name = "standards"
25-
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2"
2623
dependencies = ["std"]
2724

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

3331
[[package]]
3432
name = "std"
35-
source = "git+https://github.com/fuellabs/sway?tag=v0.65.2#66bb430395daf5b8f7205f7b9d8d008e2e812d54"
36-
dependencies = ["core"]
37-
38-
[[package]]
39-
name = "sway_libs"
40-
source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.21.0#6a227ed34c86fe1ebd334dbdfeccf66c43e3915b"
41-
dependencies = [
42-
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2",
43-
"std",
44-
]
33+
version = "0.68.9"
34+
source = "registry+std?0.68.9#QmUaBxMs2JvY1bXgRCdeCsG3o6TN82ftRgv4Tq7ytqUGUT!"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[toolchain]
2-
channel = "latest-aarch64-apple-darwin"
2+
channel = "mainnet"
33

44
[components]
5-
forc = "0.65.2"
6-
fuel-core = "0.37.1"
5+
forc = "0.68.9"
6+
fuel-core = "0.43.2"

target_chains/fuel/contracts/pyth-contract/Forc.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ license = "Apache-2.0"
55
name = "pyth-contract"
66

77
[dependencies]
8-
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.21.0" }
98
pyth_interface = { path = "../pyth-interface" }
10-
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" }
9+
ownership = "0.26.0"
10+
src5 = "0.8.0"

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ use pyth_interface::{
5353
WormholeGuardians,
5454
};
5555

56-
use sway_libs::ownership::*;
57-
use standards::src5::{SRC5, State};
56+
use ownership::*;
57+
use src5::{SRC5, State};
5858

5959
const GUARDIAN_SET_EXPIRATION_TIME_SECONDS: u64 = 86400; // 24 hours in seconds
6060
configurable {
61-
DEPLOYER: Identity = Identity::Address(Address::from(ZERO_B256)),
61+
DEPLOYER: Identity = Identity::Address(Address::from(b256::zero())),
6262
}
6363

6464
storage {
@@ -209,7 +209,7 @@ impl PythCore for Contract {
209209
while i_2 < number_of_attestations {
210210
let (_, slice) = vm.payload.split_at(attestation_index + 32);
211211
let (price_feed_id, _) = slice.split_at(32);
212-
let price_feed_id: PriceFeedId = price_feed_id.into();
212+
let price_feed_id: PriceFeedId = b256::from_be_bytes(price_feed_id.clone());
213213

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

377-
#[storage(read, write), payable]
377+
#[storage(read, write)]
378378
fn update_price_feeds(update_data: Vec<Bytes>) {
379379
require(
380380
msg_asset_id() == AssetId::base(),
@@ -934,4 +934,4 @@ fn verify_governance_vm(encoded_vm: Bytes) -> WormholeVM {
934934

935935
set_last_executed_governance_sequence(vm.sequence);
936936
vm
937-
}
937+
}

target_chains/fuel/contracts/pyth-interface/Forc.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ authors = ["Fuel Labs <contact@fuel.sh>"]
33
entry = "interface.sw"
44
license = "Apache-2.0"
55
name = "pyth_interface"
6-
7-
[dependencies]
8-
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" }

target_chains/fuel/contracts/pyth-interface/src/data_structures/governance_instruction.sw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl GovernanceInstruction {
139139
index += 2;
140140
let (_, slice) = encoded_payload.split_at(index);
141141
let (slice, _) = slice.split_at(32);
142-
let emitter_address: b256 = slice.into();
142+
let emitter_address: b256 = b256::from_be_bytes(slice.clone());
143143
index += 32;
144144

145145
data_sources.push(DataSource {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
library;
22

3-
use std::{bytes::Bytes, block::timestamp};
3+
use std::{bytes::Bytes, block::timestamp, bytes_conversions::b256::*};
44

55
use ::errors::PythError;
66
use ::utils::absolute_of_exponent;
@@ -99,7 +99,7 @@ impl PriceFeed {
9999
let mut offset = 1u64;
100100
let (_, slice) = encoded_price_feed.split_at(offset);
101101
let (price_feed_id, _) = slice.split_at(32);
102-
let price_feed_id: PriceFeedId = price_feed_id.into();
102+
let price_feed_id: PriceFeedId = b256::from_be_bytes(price_feed_id.clone());
103103
offset += 32;
104104
let price = u64::from_be_bytes([
105105
encoded_price_feed.get(offset).unwrap(),
@@ -186,7 +186,7 @@ impl PriceFeed {
186186
let mut attestation_index = index + 32;
187187
let (_, slice) = encoded_payload.split_at(attestation_index);
188188
let (price_feed_id, _) = slice.split_at(32);
189-
let price_feed_id: PriceFeedId = price_feed_id.into();
189+
let price_feed_id: PriceFeedId = b256::from_be_bytes(price_feed_id.clone());
190190
attestation_index += 32;
191191
let mut price = u64::from_be_bytes([
192192
encoded_payload.get(attestation_index).unwrap(),
@@ -321,7 +321,7 @@ impl PriceFeed {
321321
}
322322

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

0 commit comments

Comments
 (0)