Skip to content
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

Upgrade to forc 0.38 & fuels-rs 0.41, including new storage API & some quality of life changes #88

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
32 changes: 16 additions & 16 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ authors = ["Abacus Works"]

[workspace.dependencies]
ethers = { git = "https://github.com/hyperlane-xyz/ethers-rs", tag = "2023-02-10-01" }
fuels = { git = "https://github.com/FuelLabs/fuels-rs", rev = "f5d08d6" }
fuels = { git = "https://github.com/FuelLabs/fuels-rs", tag = "v0.41.0" }
hyperlane-core = { git = "https://github.com/hyperlane-xyz/hyperlane-monorepo", rev = "930cded" }
hyperlane-ethereum = { git = "https://github.com/hyperlane-xyz/hyperlane-monorepo", rev = "930cded" }
tokio = { version = "1.12" }
32 changes: 10 additions & 22 deletions Forc.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[package]]
name = 'core'
source = 'path+from-root-91563E0DA237BDEC'
source = 'path+from-root-1AA1C8235B783A81'

[[package]]
name = 'hyperlane-ism-test'
Expand All @@ -18,7 +18,7 @@ dependencies = [
'hyperlane_interfaces',
'hyperlane_message',
'merkle',
'ownership git+https://github.com/fuellabs/sway-libs?tag=v0.8.0#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a',
'ownership',
'pause',
'reentrancy',
'std',
Expand Down Expand Up @@ -48,7 +48,7 @@ name = 'hyperlane_interfaces'
source = 'member'
dependencies = [
'hyperlane_message',
'ownership git+https://github.com/fuellabs/sway-libs?rev#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a',
'ownership',
'std',
]

Expand All @@ -65,7 +65,7 @@ name = 'interchain-gas-paymaster'
source = 'member'
dependencies = [
'hyperlane_interfaces',
'ownership git+https://github.com/fuellabs/sway-libs?tag=v0.8.0#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a',
'ownership',
'std',
'std_lib_extended',
]
Expand Down Expand Up @@ -107,10 +107,9 @@ dependencies = [
'hyperlane_message',
'merkle',
'multisig_ism_metadata',
'ownership git+https://github.com/fuellabs/sway-libs?rev#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a',
'ownership',
'std',
'std_lib_extended',
'storagemapvec',
]

[[package]]
Expand All @@ -126,18 +125,13 @@ name = 'overhead-igp'
source = 'member'
dependencies = [
'hyperlane_interfaces',
'ownership git+https://github.com/fuellabs/sway-libs?tag=v0.8.0#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a',
'ownership',
'std',
]

[[package]]
name = 'ownership'
source = 'git+https://github.com/fuellabs/sway-libs?rev#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a'
dependencies = ['std']

[[package]]
name = 'ownership'
source = 'git+https://github.com/fuellabs/sway-libs?tag=v0.8.0#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a'
source = 'git+https://github.com/fuellabs/sway-libs?tag=v0.9.0#01cb23bfc13be2a95c81dec17933f84991337ac9'
dependencies = ['std']

[[package]]
Expand All @@ -155,12 +149,12 @@ dependencies = [

[[package]]
name = 'reentrancy'
source = 'git+https://github.com/FuelLabs/sway-libs?tag=v0.8.0#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a'
source = 'git+https://github.com/fuellabs/sway-libs?tag=v0.9.0#01cb23bfc13be2a95c81dec17933f84991337ac9'
dependencies = ['std']

[[package]]
name = 'std'
source = 'git+https://github.com/fuellabs/sway?tag=v0.37.1#83e5479462ed2883591669a42552606ac25f0a04'
source = 'git+https://github.com/fuellabs/sway?tag=v0.38.0#2d16d70ab9d5ab0de0255941048f811b6d07c6b1'
dependencies = ['core']

[[package]]
Expand All @@ -173,20 +167,14 @@ name = 'storage-gas-oracle'
source = 'member'
dependencies = [
'hyperlane_interfaces',
'ownership git+https://github.com/fuellabs/sway-libs?tag=v0.8.0#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a',
'ownership',
'std',
]

[[package]]
name = 'storagemapvec'
source = 'git+https://github.com/FuelLabs/sway-libs?tag=v0.8.0#f6bb5c234e020d556e1bc688e0f1f368dc9b0f9a'
dependencies = ['std']

[[package]]
name = 'validator-announce'
source = 'member'
dependencies = [
'std',
'std_lib_extended',
'storagemapvec',
]
2 changes: 1 addition & 1 deletion Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ members = [
]

[dependencies]
ownership = { git = "https://github.com/fuellabs/sway-libs", tag = "v0.8.0" }
ownership = { git = "https://github.com/fuellabs/sway-libs", tag = "v0.9.0" }
2 changes: 1 addition & 1 deletion contracts/hyperlane-interfaces/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ name = "hyperlane_interfaces"

[dependencies]
hyperlane_message = { path = "../hyperlane-message" }
ownership = { git = "https://github.com/fuellabs/sway-libs", rev = "v0.8.0" }
ownership = { git = "https://github.com/fuellabs/sway-libs", tag = "v0.9.0" }
6 changes: 3 additions & 3 deletions contracts/hyperlane-ism-test/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ abi TestISM {
impl TestISM for Contract {
#[storage(write)]
fn set_accept(accept: bool) {
storage.accept = accept;
storage.accept.write(accept);
}
}

impl InterchainSecurityModule for Contract {
#[storage(read, write)]
fn verify(metadata: Bytes, message: Bytes) -> bool {
// To ignore a compiler warning that no storage writes are made.
storage.accept = storage.accept;
storage.accept.write(storage.accept.read());

return storage.accept;
return storage.accept.read();
}

#[storage(read)]
Expand Down
4 changes: 2 additions & 2 deletions contracts/hyperlane-mailbox/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "hyperlane-mailbox"
hyperlane_interfaces = { path = "../hyperlane-interfaces" }
hyperlane_message = { path = "../hyperlane-message" }
merkle = { path = "../merkle" }
ownership = { git = "https://github.com/fuellabs/sway-libs", tag = "v0.8.0" }
ownership = { git = "https://github.com/fuellabs/sway-libs", tag = "v0.9.0" }
pause = { path = "../pause" }
reentrancy = { git = "https://github.com/FuelLabs/sway-libs", tag = "v0.8.0" }
reentrancy = { git = "https://github.com/fuellabs/sway-libs", tag = "v0.9.0" }
std_lib_extended = { path = "../std-lib-extended" }
25 changes: 13 additions & 12 deletions contracts/hyperlane-mailbox/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::{auth::msg_sender, bytes::Bytes, call_frames::contract_id, logging::log

use std_lib_extended::bytes::*;

use merkle::StorageMerkleTree;
use ownership::{data_structures::State, only_owner, owner, set_ownership, transfer_ownership};
use merkle::*;
use ownership::{*, data_structures::State};
use pause::{interface::Pausable, is_paused, pause, require_unpaused, unpause};
use reentrancy::reentrancy_guard;

Expand Down Expand Up @@ -38,6 +38,7 @@ configurable {
}

storage {
ownership: Ownership = Ownership::uninitialized(),
/// A merkle tree that includes outbound message IDs as leaves.
merkle_tree: StorageMerkleTree = StorageMerkleTree {},
delivered: StorageMap<b256, bool> = StorageMap {},
Expand Down Expand Up @@ -80,15 +81,15 @@ impl Mailbox for Contract {

#[storage(read, write)]
fn set_default_ism(module: ContractId) {
only_owner();
storage.default_ism = module;
storage.ownership.only_owner();
storage.default_ism.write(module);

log(DefaultIsmSetEvent { module });
}

#[storage(read)]
fn get_default_ism() -> ContractId {
storage.default_ism
storage.default_ism.read()
}

#[storage(read)]
Expand Down Expand Up @@ -119,7 +120,7 @@ impl Mailbox for Contract {
let msg_recipient = abi(MessageRecipient, recipient);
let mut ism_id = msg_recipient.interchain_security_module();
if (ism_id == ZERO_ID) {
ism_id = storage.default_ism;
ism_id = storage.default_ism.read();
}

let ism = abi(InterchainSecurityModule, ism_id.into());
Expand Down Expand Up @@ -164,21 +165,21 @@ impl Ownable for Contract {
/// Gets the current owner.
#[storage(read)]
fn owner() -> State {
owner()
storage.ownership.owner()
}

/// Transfers ownership to `new_owner`.
/// Reverts if the msg_sender is not the current owner.
#[storage(read, write)]
fn transfer_ownership(new_owner: Identity) {
transfer_ownership(new_owner);
storage.ownership.transfer_ownership(new_owner);
}

/// Initializes ownership to `new_owner`.
/// Reverts if owner already initialized.
#[storage(read, write)]
fn set_ownership(new_owner: Identity) {
set_ownership(new_owner);
storage.ownership.set_ownership(new_owner);
}
}

Expand All @@ -193,15 +194,15 @@ impl Pausable for Contract {
/// Reverts if the msg_sender is not the current owner.
#[storage(read, write)]
fn pause() {
only_owner();
storage.ownership.only_owner();
pause()
}

/// Unpauses the contract if it is paused.
/// Reverts if the msg_sender is not the current owner.
#[storage(read, write)]
fn unpause() {
only_owner();
storage.ownership.only_owner();
unpause()
}
}
Expand All @@ -222,7 +223,7 @@ fn root() -> b256 {

#[storage(read)]
fn delivered(message_id: b256) -> bool {
storage.delivered.get(message_id).unwrap_or(false)
storage.delivered.get(message_id).try_read().unwrap_or(false)
}

/// Gets the b256 representation of the msg_sender.
Expand Down
Loading