Skip to content

Commit

Permalink
chore: upgrade fuels-rs sdk to 0.70 (#6851)
Browse files Browse the repository at this point in the history
## Description
Updated the `fuels-rs` SDK to `0.77`.
This required updating transitive dependencies to the relevant versions
specified in fuels-rs sdk.

## Dependency tree

```mermaid
graph TD
    sway[sway]
    fuelsrs[fuels-rs]
    fuelabi[fuel-abi-types]
    fuelvm[fuel-vm]
    forcwallet[forc-wallet]
    fcoreclient[fuels-core]
    fvmprivate[fuel-vm-private]

    %% Main dependency relationships
    sway --> fuelsrs
    fuelsrs --> fuelabi
    fuelsrs --> fuelvm
    fuelsrs --> forcwallet
    fuelsrs --> fcoreclient
    
    %% Secondary dependencies
    fcoreclient --> fvmprivate
    fvmprivate --> fuelvm
    
    %% forc-wallet dependencies
    forcwallet --> fuelvm
    forcwallet --> fuelsrs

    %% Styling
    classDef primary fill:#d0e1f9,stroke:#4a90e2,stroke-width:2px
    classDef secondary fill:#e8f4ea,stroke:#66b366,stroke-width:2px
    
    class sway,fuelsrs primary
    class fuelabi,fuelvm,forcwallet,fcoreclient,fvmprivate secondary

    %% Add notes
    subgraph Note
        note[Update forc-wallet first due to circular dependency]
        style note fill:#fff4e6,stroke:#ffab40,stroke-width:1px
    end
```

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: z <[email protected]>
Co-authored-by: Sophie Dankel <[email protected]>
Co-authored-by: hal3e <[email protected]>
  • Loading branch information
4 people authored Feb 1, 2025
1 parent f0ed57a commit 55358da
Show file tree
Hide file tree
Showing 18 changed files with 2,168 additions and 984 deletions.
702 changes: 405 additions & 297 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,31 @@ sway-ir-macros = { path = "sway-ir/sway-ir-macros", version = "0.66.6" }
#

# Dependencies from the `fuel-abi-types` repository:
fuel-abi-types = "0.7"
fuel-abi-types = "0.8"

# Dependencies from the `fuel-core` repository:
#
# Although ALL verions are "X.Y", we need the complete semver for
# fuel-core-client as the GitHub Actions workflow parses this value to pull down
# the correct tarball
fuel-core-client = { version = "0.40.0", default-features = false }
fuel-core-types = { version = "0.40", default-features = false }
fuel-core-client = { version = "0.41.4", default-features = false }
fuel-core-types = { version = "0.41", default-features = false }

# Dependencies from the `fuels-rs` repository:

fuels = "0.66.10"
fuels-core = "0.66.10"
fuels-accounts = "0.66.10"
fuels = "0.70"
fuels-core = "0.70"
fuels-accounts = "0.70"

# Dependencies from the `fuel-vm` repository:
fuel-asm = "0.58"
fuel-crypto = "0.58"
fuel-types = "0.58"
fuel-tx = "0.58"
fuel-vm = "0.58"
fuel-asm = "0.59"
fuel-crypto = "0.59"
fuel-types = "0.59"
fuel-tx = "0.59"
fuel-vm = "0.59"

# Dependencies from the `forc-wallet` repository:
forc-wallet = "0.11"
forc-wallet = "0.12"

#
# External dependencies
Expand All @@ -129,7 +129,6 @@ comrak = "0.28"
crossbeam-channel = "0.5"
dap = "0.4.1-alpha"
dashmap = "6.1"
derivative = "2.2"
devault = "0.2"
dialoguer = "0.11"
dirs = "5.0"
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-client/src/op/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use fuels::{
transaction_builders::{BuildableTransaction, VariableOutputPolicy},
},
};
use fuels_accounts::{provider::Provider, Account};
use fuels_accounts::{provider::Provider, Account, ViewOnlyAccount};
use pkg::BuiltPackage;
use std::time::Duration;
use std::{path::PathBuf, str::FromStr};
Expand Down
41 changes: 21 additions & 20 deletions forc-plugins/forc-client/src/util/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,14 @@ pub enum ForcClientAccount {

#[async_trait]
impl Account for ForcClientAccount {
async fn get_asset_inputs_for_amount(
&self,
asset_id: AssetId,
amount: u64,
excluded_coins: Option<Vec<CoinTypeId>>,
) -> Result<Vec<Input>> {
match self {
ForcClientAccount::Wallet(wallet) => {
wallet
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
ForcClientAccount::KmsSigner(account) => {
account
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
}
}

fn add_witnesses<Tb: TransactionBuilder>(&self, tb: &mut Tb) -> Result<()> {
tb.add_signer(self.clone())?;

Ok(())
}
}

#[async_trait]
impl ViewOnlyAccount for ForcClientAccount {
fn address(&self) -> &Bech32Address {
match self {
Expand All @@ -67,6 +48,26 @@ impl ViewOnlyAccount for ForcClientAccount {
ForcClientAccount::KmsSigner(account) => Ok(account.provider()),
}
}

async fn get_asset_inputs_for_amount(
&self,
asset_id: AssetId,
amount: u64,
excluded_coins: Option<Vec<CoinTypeId>>,
) -> Result<Vec<Input>> {
match self {
ForcClientAccount::Wallet(wallet) => {
wallet
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
ForcClientAccount::KmsSigner(account) => {
account
.get_asset_inputs_for_amount(asset_id, amount, excluded_coins)
.await
}
}
}
}

#[async_trait]
Expand Down
7 changes: 4 additions & 3 deletions forc-plugins/forc-client/src/util/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ impl Signer for AwsSigner {
}
}

#[async_trait]
impl ViewOnlyAccount for AwsSigner {
fn address(&self) -> &Bech32Address {
&self.bech
Expand All @@ -249,10 +250,7 @@ impl ViewOnlyAccount for AwsSigner {
fn try_provider(&self) -> Result<&Provider> {
Ok(&self.provider)
}
}

#[async_trait]
impl Account for AwsSigner {
async fn get_asset_inputs_for_amount(
&self,
asset_id: AssetId,
Expand All @@ -267,3 +265,6 @@ impl Account for AwsSigner {
.collect::<Vec<Input>>())
}
}

#[async_trait]
impl Account for AwsSigner {}
5 changes: 3 additions & 2 deletions forc-plugins/forc-client/src/util/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,13 @@ pub(crate) async fn select_account(
let wallet_path = default_wallet_path();
let accounts = collect_user_accounts(&wallet_path, password)?;
let account_balances = collect_account_balances(&accounts, provider).await?;
let base_asset_id = provider.base_asset_id();
let consensus_parameters = provider.consensus_parameters().await?;
let base_asset_id = consensus_parameters.base_asset_id();

let total_balance = account_balances
.iter()
.flat_map(|account| account.values())
.sum::<u64>();
.sum::<u128>();
if total_balance == 0 {
let first_account = accounts
.get(&0)
Expand Down
20 changes: 11 additions & 9 deletions forc-plugins/forc-client/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,8 @@ async fn test_non_owner_fails_to_set_target() {
SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap();
let owner_wallet =
WalletUnlocked::new_from_private_key(owner_secret_key, Some(provider.clone()));
let base_asset_id = provider.base_asset_id();
let consensus_parameters = provider.consensus_parameters().await.unwrap();
let base_asset_id = consensus_parameters.base_asset_id();

// Fund attacker wallet so that it can try to make a set proxy target call.
owner_wallet
Expand Down Expand Up @@ -1052,7 +1053,8 @@ async fn deployed_predicate_call() {
));

let provider = Provider::connect(&node_url).await.unwrap();
let base_asset_id = *provider.base_asset_id();
let consensus_parameters = provider.consensus_parameters().await.unwrap();
let base_asset_id = consensus_parameters.base_asset_id();
let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap();
let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone()));
let loader_path = tmp_dir.path().join("out/deployed_predicate-loader.bin");
Expand All @@ -1074,32 +1076,32 @@ async fn deployed_predicate_call() {
wallet_unlocked
.transfer(
predicate.address(),
500,
base_asset_id,
2000,
*base_asset_id,
TxPolicies::default(),
)
.await
.unwrap();

// Check predicate balance.
let balance = predicate.get_asset_balance(&base_asset_id).await.unwrap();
assert_eq!(balance, 500);
let balance = predicate.get_asset_balance(base_asset_id).await.unwrap();
assert_eq!(balance, 2000);

// Try to spend it
let amount_to_unlock = 300;
predicate
.transfer(
wallet_unlocked.address(),
amount_to_unlock,
base_asset_id,
*base_asset_id,
TxPolicies::default(),
)
.await
.unwrap();

// Check predicate balance again.
let balance = predicate.get_asset_balance(&base_asset_id).await.unwrap();
assert_eq!(balance, 200);
let balance = predicate.get_asset_balance(base_asset_id).await.unwrap();
assert_eq!(balance, 828);

node.kill().unwrap();
}
Expand Down
1 change: 1 addition & 0 deletions forc-test/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl TestExecutor {
gas_price,
consensus_params.gas_costs(),
consensus_params.fee_params(),
None,
)
.map_err(|e| anyhow::anyhow!("{e:?}"))?;

Expand Down
4 changes: 2 additions & 2 deletions forc-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl PackageWithDeploymentToTest {
.map(|(contract_id, tx)| {
// Transact the deployment transaction constructed for this contract dependency.
let tx = tx
.into_ready(gas_price, params.gas_costs(), params.fee_params())
.into_ready(gas_price, params.gas_costs(), params.fee_params(), None)
.unwrap();
interpreter.transact(tx).map_err(anyhow::Error::msg)?;
Ok(contract_id)
Expand All @@ -247,7 +247,7 @@ impl PackageWithDeploymentToTest {
&params,
);
let root_contract_tx = root_contract_tx
.into_ready(gas_price, params.gas_costs(), params.fee_params())
.into_ready(gas_price, params.gas_costs(), params.fee_params(), None)
.unwrap();
// Deploy the root contract.
interpreter
Expand Down
1 change: 0 additions & 1 deletion sway-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ repository.workspace = true

[dependencies]
clap = { workspace = true, features = ["derive"] }
derivative.workspace = true
dirs.workspace = true
either.workspace = true
ethabi.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions sway-core/src/asm_generation/finalized_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ fn print_instruction(op: &Instruction) {
Instruction::ECAL(x) => f("ECAL", x.unpack()),
Instruction::BSIZ(x) => f("BSIZ", x.unpack()),
Instruction::BLDD(x) => f("BLDD", x.unpack()),
Instruction::ECOP(x) => f("ECOP", x.unpack()),
Instruction::EPAR(x) => f("EPAR", x.unpack()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/e2e_vm_tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub(crate) fn runs_in_vm(

let tx = tb
.finalize_checked(block_height)
.into_ready(gas_price, params.gas_costs(), params.fee_params())
.into_ready(gas_price, params.gas_costs(), params.fee_params(), None)
.map_err(|e| anyhow::anyhow!("{e:?}"))?;

let mem_instance = MemoryInstance::new();
Expand Down
Loading

0 comments on commit 55358da

Please sign in to comment.