Skip to content

Commit 3513eed

Browse files
authored
fix(target_chains/fuel): upgrade to fuel testnet from beta-5 (#1625)
* upgrade libs and deps to latest * fix more errors * fix test * fix test
1 parent c76d205 commit 3513eed

File tree

20 files changed

+2197
-325
lines changed

20 files changed

+2197
-325
lines changed

target_chains/fuel/contracts/Cargo.lock

Lines changed: 2071 additions & 189 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

target_chains/fuel/contracts/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ license = "Apache-2.0"
99
[dependencies]
1010
rand = "0.8.5"
1111
base64 = "0.22"
12-
fuels = { version = "0.55", features = ["fuel-core-lib"] }
12+
fuels = { version = "0.62.0", features = ["fuel-core-lib"] }
1313
tokio = { version = "1.12", features = ["rt", "macros"] }
1414
hex = "0.4.3"
1515
reqwest = "0.11.27"
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
[[package]]
22
name = "core"
3-
source = "path+from-root-566CA1D5F8BEAFBF"
4-
5-
[[package]]
6-
name = "ownership"
7-
source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.18.0#8d196e9379463d4596ac582a20a84ed52ff58c69"
8-
dependencies = [
9-
"src_5",
10-
"std",
11-
]
3+
source = "path+from-root-E19CE48B3E858B72"
124

135
[[package]]
146
name = "pyth-contract"
157
source = "member"
168
dependencies = [
17-
"ownership",
189
"pyth_interface",
19-
"src5",
10+
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae",
2011
"std",
12+
"sway_libs",
2113
]
2214

2315
[[package]]
2416
name = "pyth_interface"
2517
source = "path+from-root-555D3D27A908977B"
2618
dependencies = [
27-
"src5",
19+
"standards git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae",
2820
"std",
2921
]
3022

3123
[[package]]
32-
name = "src5"
33-
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.3.3#4198b4b07449ad16104cc8a0501f3013670fdcfd"
24+
name = "standards"
25+
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.3#6f63eb7dff2458a7d976184e565b5cbf26f61da2"
3426
dependencies = ["std"]
3527

3628
[[package]]
37-
name = "src_5"
38-
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.2.2#6989cf8224b0d8aabea62f3d3c648fc754948705"
29+
name = "standards"
30+
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.4.4#a001d3c248595112aae67e5633a06ef9bc0536ae"
3931
dependencies = ["std"]
4032

4133
[[package]]
4234
name = "std"
43-
source = "git+https://github.com/fuellabs/sway?tag=v0.49.3#0dc6570377ee9c4a6359ade597fa27351e02a728"
35+
source = "git+https://github.com/fuellabs/sway?tag=v0.60.0#2f0392ee35a1e4dd80bd8034962d5b4083dfb8b6"
4436
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+
]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[toolchain]
2-
channel = "beta-5"
2+
channel = "latest-aarch64-apple-darwin"
33

44
[components]
5-
forc = "0.49.3"
6-
fuel-core = "0.22.4"
5+
forc = "0.60.0"
6+
fuel-core = "0.26.0"

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-
ownership = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.18.0" }
8+
sway_libs = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.21.0" }
99
pyth_interface = { path = "../pyth-interface" }
10-
src5 = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.3.3" }
10+
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.4.4" }

target_chains/fuel/contracts/pyth-contract/src/data_structures/accumulator_update.sw

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl AccumulatorUpdate {
3939
require(trailing_header_size.is_some(), PythError::InvalidHeaderSize);
4040
// skip trailing headers and update type
4141
let offset = 8 + trailing_header_size.unwrap().as_u64();
42-
require(self.data.len >= offset, PythError::InvalidUpdateDataLength);
42+
require(self.data.len() >= offset, PythError::InvalidUpdateDataLength);
4343
offset
4444
}
4545
}
@@ -53,7 +53,7 @@ impl AccumulatorUpdate {
5353
) -> (u64, Bytes, u64, Bytes) {
5454
let encoded_offset = self.verify();
5555
let (_, slice) = self.data.split_at(encoded_offset);
56-
let (encoded_slice, _) = slice.split_at(self.data.len - encoded_offset);
56+
let (encoded_slice, _) = slice.split_at(self.data.len() - encoded_offset);
5757
let mut offset = 0;
5858
let wormhole_proof_size = u16::from_be_bytes([encoded_slice.get(offset).unwrap(), encoded_slice.get(offset + 1).unwrap()]).as_u64();
5959
offset += 2;
@@ -80,7 +80,7 @@ impl AccumulatorUpdate {
8080
payload_offset += 20;
8181
require(
8282
payload_offset <= encoded_payload
83-
.len,
83+
.len(),
8484
PythError::InvalidPayloadLength,
8585
);
8686
let number_of_updates = encoded_slice.get(offset);
@@ -125,7 +125,7 @@ impl AccumulatorUpdate {
125125
}
126126
require(
127127
offset == encoded_data
128-
.len,
128+
.len(),
129129
PythError::InvalidUpdateDataLength,
130130
);
131131
(number_of_updates, updated_ids)

target_chains/fuel/contracts/pyth-contract/src/data_structures/batch_attestation_update.sw

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{bytes::Bytes, hash::Hash};
88
const BATCH_MAGIC: u32 = 0x50325748;
99

1010
pub struct BatchAttestationUpdate {
11-
data: Bytes,
11+
pub data: Bytes,
1212
}
1313
impl BatchAttestationUpdate {
1414
pub fn new(data: Bytes) -> Self {
@@ -87,7 +87,7 @@ pub fn parse_and_verify_batch_attestation_header(encoded_payload: Bytes) -> (u64
8787
index += 2;
8888
require(
8989
encoded_payload
90-
.len == index + (attestation_size * number_of_attestations)
90+
.len() == index + (attestation_size * number_of_attestations)
9191
.as_u64(),
9292
PythError::InvalidPayloadLength,
9393
);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Price {
2828
impl PriceFeedId {
2929
pub fn is_target(self, target_price_feed_ids: Vec<PriceFeedId>) -> bool {
3030
let mut i = 0;
31-
while i < target_price_feed_ids.len {
31+
while i < target_price_feed_ids.len() {
3232
if target_price_feed_ids.get(i).unwrap() == self {
3333
return true;
3434
}
@@ -38,7 +38,7 @@ impl PriceFeedId {
3838
}
3939
pub fn is_contained_within(self, output_price_feeds: Vec<PriceFeed>) -> bool {
4040
let mut i = 0;
41-
while i < output_price_feeds.len {
41+
while i < output_price_feeds.len() {
4242
if output_price_feeds.get(i).unwrap().id == self {
4343
return true;
4444
}
@@ -133,7 +133,7 @@ impl PriceFeed {
133133
offset += 8;
134134
require(
135135
offset <= encoded_price_feed
136-
.len,
136+
.len(),
137137
PythError::InvalidPriceFeedDataLength,
138138
);
139139
//convert publish_time from UNIX to TAI64

target_chains/fuel/contracts/pyth-contract/src/data_structures/update_type.sw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub enum UpdateType {
1616
impl UpdateType {
1717
pub fn determine_type(data: Bytes) -> Self {
1818
let (magic, _) = data.split_at(4); //TODO: Convert to u32 for comparison with const ACCUMULATOR_MAGIC. Use raw_ptr.read::<u32>()? Remove accumulator_magic_bytes()
19-
if data.len > 4 && magic == accumulator_magic_bytes() {
19+
if data.len() > 4 && magic == accumulator_magic_bytes() {
2020
UpdateType::Accumulator(AccumulatorUpdate::new(data))
2121
} else {
2222
UpdateType::BatchAttestation((BatchAttestationUpdate::new(data)))

target_chains/fuel/contracts/pyth-contract/src/data_structures/wormhole_light.sw

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ impl GuardianSet {
4040
}
4141

4242
pub struct StorageGuardianSet {
43-
expiration_time: u64,
44-
keys: StorageKey<StorageVec<b256>>,
43+
pub expiration_time: u64,
44+
pub keys: StorageKey<StorageVec<b256>>,
4545
}
4646

4747
impl StorageGuardianSet {
@@ -54,11 +54,11 @@ impl StorageGuardianSet {
5454
}
5555

5656
pub struct GuardianSetUpgrade {
57-
action: u8,
58-
chain: u16,
59-
module: b256,
60-
new_guardian_set: StorageGuardianSet,
61-
new_guardian_set_index: u32,
57+
pub action: u8,
58+
pub chain: u16,
59+
pub module: b256,
60+
pub new_guardian_set: StorageGuardianSet,
61+
pub new_guardian_set_index: u32,
6262
}
6363

6464
impl GuardianSetUpgrade {
@@ -106,13 +106,9 @@ impl GuardianSetUpgrade {
106106
index += 4;
107107
let guardian_length = encoded_upgrade.get(index).unwrap();
108108
index += 1;
109-
let mut new_guardian_set = StorageGuardianSet::new(
109+
let mut new_guardian_set: StorageGuardianSet = StorageGuardianSet::new(
110110
0,
111-
StorageKey {
112-
slot: sha256(("guardian_set_keys", new_guardian_set_index)),
113-
offset: 0,
114-
field_id: ZERO_B256,
115-
},
111+
StorageKey::<StorageVec<b256>>::new(sha256(("guardian_set_keys", new_guardian_set_index)), 0, ZERO_B256),
116112
);
117113
let mut i: u8 = 0;
118114
while i < guardian_length {
@@ -131,7 +127,7 @@ impl GuardianSetUpgrade {
131127
);
132128
require(
133129
encoded_upgrade
134-
.len == index,
130+
.len() == index,
135131
WormholeError::InvalidGuardianSetUpgradeLength,
136132
);
137133
GuardianSetUpgrade::new(
@@ -222,25 +218,24 @@ impl GuardianSignature {
222218
require(
223219
recovered_signer
224220
.is_ok() && recovered_signer
225-
.unwrap()
226-
.value == guardian_set_key,
221+
.unwrap().bits() == guardian_set_key,
227222
WormholeError::SignatureInvalid,
228223
);
229224
}
230225
}
231226

232227
pub struct WormholeVM {
233-
version: u8,
234-
guardian_set_index: u32,
235-
governance_action_hash: b256,
228+
pub version: u8,
229+
pub guardian_set_index: u32,
230+
pub governance_action_hash: b256,
236231
// signatures: Vec<GuardianSignature>, // Shown here to represent data layout of VM, but not needed
237-
timestamp: u32,
238-
nonce: u32,
239-
emitter_chain_id: u16,
240-
emitter_address: b256,
241-
sequence: u64,
242-
consistency_level: u8,
243-
payload: Bytes,
232+
pub timestamp: u32,
233+
pub nonce: u32,
234+
pub emitter_chain_id: u16,
235+
pub emitter_address: b256,
236+
pub sequence: u64,
237+
pub consistency_level: u8,
238+
pub payload: Bytes,
244239
}
245240

246241
impl WormholeVM {
@@ -339,7 +334,7 @@ impl WormholeVM {
339334
let hash_index = index + (signers_length * 66);
340335
require(
341336
hash_index < encoded_vm
342-
.len,
337+
.len(),
343338
WormholeError::InvalidSignatureLength,
344339
);
345340
let (_, slice) = encoded_vm.split_at(hash_index);
@@ -435,7 +430,7 @@ impl WormholeVM {
435430
WormholeError::ConsistencyLevelIrretrievable,
436431
);
437432
index += 1;
438-
require(index <= encoded_vm.len, WormholeError::InvalidPayloadLength);
433+
require(index <= encoded_vm.len(), WormholeError::InvalidPayloadLength);
439434
let (_, payload) = encoded_vm.split_at(index);
440435
WormholeVM::new(
441436
version
@@ -485,7 +480,7 @@ impl WormholeVM {
485480
let hash_index = index + (signers_length * 66);
486481
require(
487482
hash_index < encoded_vm
488-
.len,
483+
.len(),
489484
WormholeError::InvalidSignatureLength,
490485
);
491486
let (_, slice) = encoded_vm.split_at(hash_index);
@@ -538,7 +533,7 @@ impl WormholeVM {
538533
WormholeError::ConsistencyLevelIrretrievable,
539534
);
540535
index += 1;
541-
require(index <= encoded_vm.len, WormholeError::InvalidPayloadLength);
536+
require(index <= encoded_vm.len(), WormholeError::InvalidPayloadLength);
542537
let (_, payload) = encoded_vm.split_at(index);
543538
WormholeVM::new(
544539
version

0 commit comments

Comments
 (0)