Skip to content

Commit

Permalink
Fuel Core v0.16.1 (#813)
Browse files Browse the repository at this point in the history
Update `fuels-rs` to the latest `fuel-core 0.16.1` and latest `sway
0.34.0`.

Due to changes in `fuel-asm` for GTF, this is causing yet another
circular upgrade issue.
- Used `{ workspace = true }` syntax to use one version across the
project and simplify integration with new changes in the future.
- Added `ci_checks.sh` script to compile all tests to simplify
integration of changes like this in the future.
- Update contracts to be compatible with `sway 0.34.0`.
- Updated tests to be compatible with `fuel-core 0.16.1`.

related PR: FuelLabs/sway#3961

---------

Co-authored-by: green <xgreenx9999@gmail.com>
  • Loading branch information
2 people authored and MujkicA committed Feb 10, 2023
1 parent c9577de commit 9512307
Show file tree
Hide file tree
Showing 38 changed files with 140 additions and 109 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ env:
CARGO_TERM_COLOR: always
DASEL_VERSION: https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64
RUSTFLAGS: "-D warnings"
FUEL_CORE_VERSION: 0.15.1
RUST_VERSION: 1.64.0
FORC_VERSION: 0.33.1
FORC_PATCH_BRANCH: ""
FUEL_CORE_VERSION: 0.16.1
RUST_VERSION: 1.65.0
FORC_VERSION: 0.34.0
FORC_PATCH_BRANCH: "Voxelot/update-predicate-metadata-0.33.1"
FORC_PATCH_REVISION: ""

jobs:
Expand All @@ -44,9 +44,9 @@ jobs:
- name: Install forc and forc-fmt
run: |
if [[ -n $FORC_PATCH_BRANCH ]]; then
cargo install forc forc-fmt --git https://github.com/FuelLabs/sway --branch $FORC_PATCH_BRANCH
cargo install --locked forc forc-fmt --git https://github.com/FuelLabs/sway --branch $FORC_PATCH_BRANCH
elif [[ -n $FORC_PATCH_BRANCH ]]; then
cargo install forc forc-fmt --git https://github.com/FuelLabs/sway --rev $FORC_PATCH_REVISION
cargo install --locked forc forc-fmt --git https://github.com/FuelLabs/sway --rev $FORC_PATCH_REVISION
else
curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ env.FORC_VERSION }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz
tar -xvf forc.tar.gz
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} packages/fuels-types/Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} packages/fuels-test-helpers/Cargo.toml
- name: Publish crate
uses: katyo/publish-crates@v1
uses: katyo/publish-crates@v2
with:
publish-delay: 30000
no-verify: true
Expand Down
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ members = [
"scripts/test-projects",
"scripts/check-docs",
]

[workspace.dependencies]
fuel-asm = "0.25"
fuel-crypto = "0.25"
fuel-merkle = "0.25"
fuel-storage = "0.25"
fuel-tx = "0.25"
fuel-types = "0.25"
fuel-core = { version = "0.16", default-features = false }
fuel-core-client = "0.16"
fuel-core-chain-config = "0.16"
fuel-core-types = "0.16"
fuel-vm = "0.25"
18 changes: 18 additions & 0 deletions ci_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Requires installed:
# The latest version of the `forc`,`forc-fmt` and `fuel-core`.
# `cargo install fuel-core-bin --git https://github.com/FuelLabs/fuel-core --tag v0.16.1 --locked`
# `cargo install forc --git https://github.com/FuelLabs/sway --tag v0.34.0 --locked`
# `cargo install forc-fmt --git https://github.com/FuelLabs/sway --tag v0.34.0 --locked`
# Note, if you need a custom branch, you can replace `--tag {RELEASE}` with the `--branch {BRANCH_NAME}`.

cargo run --bin test-projects -- build &&
cargo run --bin test-projects -- format --check &&
cargo fmt --all --verbose -- --check &&
cargo clippy --all-targets --all-features &&
cargo test --all-targets --all-features &&
cargo test --all-targets &&
cargo test --all-targets &&
# May fail after `cargo doc`
cargo run --bin check-docs
12 changes: 8 additions & 4 deletions examples/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ mod tests {
.await?;
// ANCHOR_END: contract_call_cost_estimation

assert_eq!(transaction_cost.gas_used, 9826);
assert_eq!(transaction_cost.gas_used, 430);

Ok(())
}
Expand Down Expand Up @@ -206,11 +206,13 @@ mod tests {
let wallets =
launch_custom_provider_and_get_wallets(WalletsConfig::default(), None, None).await;

let contract_id_1 = Contract::deploy(
let salt = [0; 32].into();
let contract_id_1 = Contract::deploy_with_parameters(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
&wallets[0],
TxParameters::default(),
StorageConfiguration::default(),
salt,
)
.await?;

Expand All @@ -226,11 +228,13 @@ mod tests {

assert_eq!(42, response.value);

let contract_id_2 = Contract::deploy(
let salt = [1; 32].into();
let contract_id_2 = Contract::deploy_with_parameters(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
&wallets[1],
TxParameters::default(),
StorageConfiguration::default(),
salt,
)
.await?;

Expand Down Expand Up @@ -676,7 +680,7 @@ mod tests {
.await?;
// ANCHOR_END: multi_call_cost_estimation

assert_eq!(transaction_cost.gas_used, 16181);
assert_eq!(transaction_cost.gas_used, 700);

Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions packages/fuels-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ repository = "https://github.com/FuelLabs/fuels-rs"
description = "Fuel Rust SDK core."

[dependencies]
fuel-tx = "0.23"
fuel-vm = "0.22"
fuel-types = "0.5"
fuel-tx = { workspace = true }
fuel-vm = { workspace = true }
fuel-types = { workspace = true }
fuels-types = { version = "0.34.0", path = "../fuels-types" }
hex = { version = "0.4.3", features = ["std"] }
itertools = "0.10"
Expand Down
6 changes: 3 additions & 3 deletions packages/fuels-programs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ description = "Fuel Rust SDK contracts."

[dependencies]
bytes = { version = "1.0.1", features = ["serde"] }
fuel-vm = "0.22"
fuel-types = "0.5"
fuel-tx = "0.23"
fuel-vm = { workspace = true }
fuel-types = { workspace = true }
fuel-tx = { workspace = true }
fuels-core = { version = "0.34.0", path = "../fuels-core" }
fuels-signers = { version = "0.34.0", path = "../fuels-signers" }
fuels-types = { version = "0.34.0", path = "../fuels-types" }
Expand Down
4 changes: 2 additions & 2 deletions packages/fuels-programs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{
};

use fuel_tx::{
Address, AssetId, Bytes32, Checkable, Contract as FuelContract, ContractId, Create, Output,
Receipt, Salt, StorageSlot, Transaction,
Address, AssetId, Bytes32, Contract as FuelContract, ContractId, Create, FormatValidityChecks,
Output, Receipt, Salt, StorageSlot, Transaction,
};
use fuel_vm::fuel_asm::PanicReason;
use fuels_core::{
Expand Down
2 changes: 1 addition & 1 deletion packages/fuels-programs/src/execution_script.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fmt::Debug, vec};

use fuel_tx::{AssetId, Checkable, Receipt, Script, ScriptExecutionResult, Transaction};
use fuel_tx::{AssetId, FormatValidityChecks, Receipt, Script, ScriptExecutionResult, Transaction};
use fuels_core::{offsets::call_script_data_offset, parameters::TxParameters};
use fuels_signers::{provider::Provider, Signer, WalletUnlocked};
use fuels_types::errors::{Error, Result};
Expand Down
12 changes: 6 additions & 6 deletions packages/fuels-signers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ bytes = { version = "1.1.0", features = ["serde"] }
chrono = "0.4.2"
elliptic-curve = { version = "0.11.6", default-features = false }
eth-keystore = { version = "0.3.0" }
fuel-core = { version = "0.15", default-features = false, optional = true }
fuel-tx = "0.23"
fuel-vm = "0.22"
fuel-crypto = { version = "0.6", features = ["random"] }
fuel-gql-client = { version = "0.15", default-features = false }
fuel-types = { version = "0.5", default-features = false, features = ["random"] }
fuel-core = { workspace = true, default-features = false, optional = true }
fuel-tx = { workspace = true }
fuel-vm = { workspace = true }
fuel-crypto = { workspace = true, features = ["random"] }
fuel-core-client = { workspace = true, default-features = false }
fuel-types = { workspace = true, default-features = false, features = ["random"] }
fuels-core = { version = "0.34.0", path = "../fuels-core" }
fuels-types = { version = "0.34.0", path = "../fuels-types" }
hex = { version = "0.4.3", default-features = false, features = ["std"] }
Expand Down
25 changes: 15 additions & 10 deletions packages/fuels-signers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ mod tests {
let mut wallet_1 = WalletUnlocked::new_random(None);
let mut wallet_2 = WalletUnlocked::new_random(None).lock();

let mut coins_1 = setup_single_asset_coins(wallet_1.address(), BASE_ASSET_ID, 1, 1000000);
let coins_2 = setup_single_asset_coins(wallet_2.address(), BASE_ASSET_ID, 1, 1000000);
let amount = 1000000;
let mut coins_1 = setup_single_asset_coins(wallet_1.address(), BASE_ASSET_ID, 1, amount);
let coins_2 = setup_single_asset_coins(wallet_2.address(), BASE_ASSET_ID, 1, amount);

coins_1.extend(coins_2);

Expand Down Expand Up @@ -180,7 +181,7 @@ mod tests {

// Transfer 1 from wallet 1 to wallet 2.
let (tx_id, _receipts) = wallet_1
.transfer(wallet_2.address(), 1, Default::default(), tx_params)
.transfer(wallet_2.address(), 1, BASE_ASSET_ID, tx_params)
.await?;

// Assert that the transaction was properly configured.
Expand All @@ -196,13 +197,17 @@ mod tests {
assert_eq!(*script.maturity(), maturity);

let wallet_1_spendable_resources =
wallet_1.get_spendable_resources(BASE_ASSET_ID, 0).await?;
wallet_1.get_spendable_resources(BASE_ASSET_ID, 1).await?;
let wallet_2_spendable_resources = wallet_2
.get_spendable_resources(BASE_ASSET_ID, amount + 1)
.await?;
let wallet_1_all_coins = wallet_1.get_coins(BASE_ASSET_ID).await?;
let wallet_2_all_coins = wallet_2.get_coins(BASE_ASSET_ID).await?;

// wallet_1 has now only 1 spent coin (so 0 spendable)
assert_eq!(wallet_1_spendable_resources.len(), 0);
assert_eq!(wallet_1_all_coins.len(), 1);
// wallet_1 has now only one spent coin and one not spent(the remaining not sent coins)
assert_eq!(wallet_1_spendable_resources.len(), 1);
assert_eq!(wallet_1_all_coins.len(), 2);
assert_eq!(wallet_2_spendable_resources.len(), 2);
// Check that wallet two now has two coins.
assert_eq!(wallet_2_all_coins.len(), 2);

Expand Down Expand Up @@ -250,16 +255,16 @@ mod tests {
.transfer(
wallet_2.address(),
2,
Default::default(),
BASE_ASSET_ID,
TxParameters::default(),
)
.await?;

let wallet_1_final_coins = wallet_1.get_coins(BASE_ASSET_ID).await?;
let wallet_1_final_coins = wallet_1.get_spendable_resources(BASE_ASSET_ID, 1).await?;

// Assert that we've sent 2 from wallet 1, resulting in an amount of 3 in wallet 1.
let resulting_amount = wallet_1_final_coins.first().unwrap();
assert_eq!(resulting_amount.amount, 3);
assert_eq!(resulting_amount.amount(), 3);

let wallet_2_final_coins = wallet_2.get_coins(BASE_ASSET_ID).await?;
assert_eq!(wallet_2_final_coins.len(), 2);
Expand Down
15 changes: 6 additions & 9 deletions packages/fuels-signers/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ use std::{collections::HashMap, io};
use chrono::{DateTime, Duration, Utc};
#[cfg(feature = "fuel-core")]
use fuel_core::service::{Config, FuelService};
use fuel_gql_client::{
client::{
schema::{
balance::Balance, block::TimeParameters as FuelTimeParameters,
contract::ContractBalance,
},
types::TransactionStatus,
FuelClient, PageDirection, PaginatedResult, PaginationRequest,
use fuel_core_client::client::{
schema::{
balance::Balance, block::TimeParameters as FuelTimeParameters, contract::ContractBalance,
},
interpreter::ExecutableTransaction,
types::TransactionStatus,
FuelClient, PageDirection, PaginatedResult, PaginationRequest,
};
use fuel_tx::{
field, AssetId, ConsensusParameters, Receipt, Transaction, TransactionFee, UniqueIdentifier,
UtxoId,
};
use fuel_vm::prelude::ExecutableTransaction;
use fuel_types::MessageId;
use fuels_core::constants::{DEFAULT_GAS_ESTIMATION_TOLERANCE, MAX_GAS_PER_TX};
use fuels_types::{
Expand Down
4 changes: 2 additions & 2 deletions packages/fuels-signers/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::{collections::HashMap, fmt, ops, path::Path};
use async_trait::async_trait;
use elliptic_curve::rand_core;
use eth_keystore::KeystoreError;
use fuel_core_client::client::{PaginatedResult, PaginationRequest};
use fuel_crypto::{Message, PublicKey, SecretKey, Signature};
use fuel_gql_client::client::{PaginatedResult, PaginationRequest};
use fuel_tx::{
field, AssetId, Bytes32, Cacheable, Chargeable, ContractId, Input, Output, Receipt, Script,
Transaction, TransactionFee, TxPointer, UniqueIdentifier, UtxoId, Witness,
Expand Down Expand Up @@ -927,7 +927,7 @@ mod tests {
use std::iter::repeat;

use fuel_core::service::{Config, FuelService};
use fuel_gql_client::client::FuelClient;
use fuel_core_client::client::FuelClient;
use fuel_tx::{
field::{Inputs, Outputs},
Address,
Expand Down
14 changes: 7 additions & 7 deletions packages/fuels-test-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ repository = "https://github.com/FuelLabs/fuels-rs"
description = "Fuel Rust SDK test helpers."

[dependencies]
fuel-vm = "0.22"
fuel-tx = "0.23"
fuel-core = { version = "0.15", default-features = false, optional = true }
fuel-chain-config = { version = "0.15", default-features = false }
fuel-core-interfaces = { version = "0.15", default-features = false }
fuel-gql-client = { version = "0.15", default-features = false }
fuel-types = { version = "0.5", default-features = false, features = ["random"] }
fuel-vm = { workspace = true }
fuel-tx = { workspace = true }
fuel-core = { workspace = true, default-features = false, optional = true }
fuel-core-chain-config = { workspace = true, default-features = false }
fuel-core-types = { workspace = true, default-features = false }
fuel-core-client = { workspace = true, default-features = false }
fuel-types = { workspace = true, default-features = false, features = ["random"] }
fuels-programs = { version = "0.34.0", path = "../fuels-programs" }
fuels-core = { version = "0.34.0", path = "../fuels-core" }
fuels-signers = { version = "0.34.0", path = "../fuels-signers", optional = true }
Expand Down
8 changes: 4 additions & 4 deletions packages/fuels-test-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use std::{
net::SocketAddr,
};

use fuel_chain_config::ChainConfig;
#[cfg(feature = "fuel-core-lib")]
use fuel_chain_config::StateConfig;
#[cfg(feature = "fuel-core-lib")]
pub use fuel_core::service::Config;
#[cfg(feature = "fuel-core-lib")]
use fuel_core::service::FuelService;
use fuel_gql_client::client::FuelClient;
use fuel_core_chain_config::ChainConfig;
#[cfg(feature = "fuel-core-lib")]
use fuel_core_chain_config::StateConfig;
use fuel_core_client::client::FuelClient;
use fuel_tx::{Bytes32, ConsensusParameters, UtxoId};
use fuels_core::constants::BASE_ASSET_ID;
use fuels_signers::fuel_crypto::{fuel_types::AssetId, rand};
Expand Down
6 changes: 3 additions & 3 deletions packages/fuels-test-helpers/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::{
time::Duration,
};

use fuel_chain_config::{ChainConfig, StateConfig};
use fuel_core_interfaces::model::BlockHeight;
use fuel_gql_client::client::FuelClient;
use fuel_core_chain_config::{ChainConfig, StateConfig};
use fuel_core_client::client::FuelClient;
use fuel_core_types::blockchain::primitives::BlockHeight;
use fuel_tx::ConsensusParameters;
use fuel_types::Word;
use fuel_vm::consts::WORD_SIZE;
Expand Down
4 changes: 2 additions & 2 deletions packages/fuels-test-helpers/src/signers.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{mem::size_of, net::SocketAddr};

use fuel_chain_config::ChainConfig;
#[cfg(feature = "fuel-core-lib")]
use fuel_core::service::Config;
use fuel_core_chain_config::ChainConfig;
use fuels_signers::{fuel_crypto::SecretKey, provider::Provider, WalletUnlocked};
use fuels_types::{coin::Coin, message::Message};

Expand Down Expand Up @@ -213,7 +213,7 @@ mod tests {

#[tokio::test]
async fn generated_wallets_with_custom_chain_config() -> Result<()> {
use fuel_chain_config::ChainConfig;
use fuel_core_chain_config::ChainConfig;
use fuel_tx::ConsensusParameters;

let chain_config = ChainConfig {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuels-test-helpers/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use fuel_chain_config::{CoinConfig, MessageConfig};
use fuel_core_chain_config::{CoinConfig, MessageConfig};
use fuels_types::{coin::Coin, message::Message};

pub fn into_coin_configs(coins: Vec<Coin>) -> Vec<CoinConfig> {
Expand Down
10 changes: 5 additions & 5 deletions packages/fuels-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ regex = "1.6.0"
lazy_static = "1.4.0"
bech32 = "0.9.0"
chrono = "0.4.2"
fuel-tx = "0.23"
fuel-types = "0.5"
fuel-tx = { workspace = true }
fuel-types = { workspace = true }
fuel-abi-types = "0.2.0"
fuel-core = { version = "0.15", default-features = false, optional = true }
fuel-chain-config = { version = "0.15", default-features = false }
fuel-gql-client = { version = "0.15", default-features = false }
fuel-core = { workspace = true, default-features = false, optional = true }
fuel-core-chain-config = { workspace = true, default-features = false }
fuel-core-client = { workspace = true, default-features = false }
hex = { version = "0.4.3", features = ["std"] }
proc-macro2 = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion packages/fuels-types/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chrono::{DateTime, NaiveDateTime, Utc};
use fuel_gql_client::client::schema::block::{Block as ClientBlock, Header as ClientHeader};
use fuel_core_client::client::schema::block::{Block as ClientBlock, Header as ClientHeader};
use fuel_tx::Bytes32;

#[derive(Debug)]
Expand Down
Loading

0 comments on commit 9512307

Please sign in to comment.