Skip to content

Commit 250250c

Browse files
feat!: update fuel-core to 0.23.0 (#1292)
This PR updates `fuel-core` to `0.23.0` and `fuel-vm` to `0.47.1`. Added `dry_run_multiple` and `dry_run_no_validation_multiple`. Both accept a new type called `Transactions`. Example usage: `Transactions::new().insert(tx).insert(tx2)` BREAKING CHANGE: - `TxPolicies` `gas_price` is replaced with `tip` - `dry_run` now returns `TxStatus` the receipts can be taken with `tx_status.take_receipts()` - `checked_dry_run` is deleted - `TransactionResponse`'s `block_id` is replaced with `block_height` - `estimate_transaction_cost` has a new argument `block_horizon` used to estimate the gas price. Co-authored-by: Ahmed Sagdati <[email protected]>
1 parent 91c3ae6 commit 250250c

File tree

27 files changed

+351
-260
lines changed

27 files changed

+351
-260
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
CARGO_TERM_COLOR: always
1717
DASEL_VERSION: https://github.com/TomWright/dasel/releases/download/v2.3.6/dasel_linux_amd64
1818
RUSTFLAGS: "-D warnings"
19-
FUEL_CORE_VERSION: 0.22.1
19+
FUEL_CORE_VERSION: 0.23.0
2020
FUEL_CORE_PATCH_BRANCH:
2121
RUST_VERSION: 1.74.0
2222
FORC_VERSION: 0.51.1

Cargo.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,25 @@ tokio = { version = "1.34.0", default-features = false }
6868
tracing = "0.1.40"
6969
trybuild = "1.0.85"
7070
uint = { version = "0.9.5", default-features = false }
71-
which = { version = "5.0.0", default-features = false }
71+
which = { version = "6.0.0", default-features = false }
7272
zeroize = "1.7.0"
7373

7474
# Dependencies from the `fuel-core` repository:
75-
fuel-core = { version = "0.22.1", default-features = false }
76-
fuel-core-chain-config = { version = "0.22.1", default-features = false }
77-
fuel-core-client = { version = "0.22.1", default-features = false }
78-
fuel-core-poa = { version = "0.22.1", default-features = false }
79-
fuel-core-services = { version = "0.22.1", default-features = false }
80-
fuel-core-types = { version = "0.22.1", default-features = false }
75+
fuel-core = { version = "0.23.0", default-features = false }
76+
fuel-core-chain-config = { version = "0.23.0", default-features = false }
77+
fuel-core-client = { version = "0.23.0", default-features = false }
78+
fuel-core-poa = { version = "0.23.0", default-features = false }
79+
fuel-core-services = { version = "0.23.0", default-features = false }
80+
fuel-core-types = { version = "0.23.0", default-features = false }
8181

8282
# Dependencies from the `fuel-vm` repository:
83-
fuel-asm = { version = "0.43.2" }
84-
fuel-crypto = { version = "0.43.2" }
85-
fuel-merkle = { version = "0.43.2" }
86-
fuel-storage = { version = "0.43.2" }
87-
fuel-tx = { version = "0.43.2" }
88-
fuel-types = { version = "0.43.2" }
89-
fuel-vm = { version = "0.43.2" }
83+
fuel-asm = { version = "0.47.1" }
84+
fuel-crypto = { version = "0.47.1" }
85+
fuel-merkle = { version = "0.47.1" }
86+
fuel-storage = { version = "0.47.1" }
87+
fuel-tx = { version = "0.47.1" }
88+
fuel-types = { version = "0.47.1" }
89+
fuel-vm = { version = "0.47.1" }
9090

9191
# Workspace projects
9292
fuels = { version = "0.55.0", path = "./packages/fuels" }
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
# Estimating contract call cost
22

3-
With the function `estimate_transaction_cost(tolerance: Option<f64>)` provided by `ContractCallHandler` and `ContractMultiCallHandler`, you can get a cost estimation for a specific call. The return type, `TransactionCost`, is a struct that contains relevant information for the estimation:
3+
With the function `estimate_transaction_cost(tolerance: Option<f64>, block_horizon: Option<u32>)` provided by `ContractCallHandler` and `ContractMultiCallHandler`, you can get a cost estimation for a specific call. The return type, `TransactionCost`, is a struct that contains relevant information for the estimation:
44

55
```rust,ignore
6-
TransactionCost {
7-
min_gas_price: u64,
8-
min_byte_price: u64,
9-
gas_price: u64,
10-
gas_used: u64,
11-
metered_bytes_size: u64,
12-
total_fee: f64, // where total_fee is the sum of the gas and byte fees
13-
}
6+
{{#include ../../../packages/fuels-accounts/src/provider.rs:transaction_cost}}
147
```
158

169
Below are examples that show how to get the estimated transaction cost from single and multi call transactions.
@@ -24,3 +17,5 @@ Below are examples that show how to get the estimated transaction cost from sing
2417
```
2518

2619
The transaction cost estimation can be used to set the gas limit for an actual call, or to show the user the estimated cost.
20+
21+
> **Note** The same estimation interface is available for scripts.

docs/src/calling-contracts/tx-policies.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Transaction policies are defined as follows:
1010

1111
Where:
1212

13-
1. **Gas Price** - Maximum gas price for transaction.
13+
1. **Tip** - amount to pay the block producer to prioritize the transaction.
1414
2. **Witness Limit** - The maximum amount of witness data allowed for the transaction.
1515
3. **Maturity** - Block until which the transaction cannot be included.
1616
4. **Max Fee** - The maximum fee payable by this transaction.
1717
5. **Script Gas Limit** - The maximum amount of gas the transaction may consume for executing its script code.
1818

19-
When the **Script Gas Limit** is not set, the Rust SDK will estimate the consumed gas in the background and set it as the limit. Similarly, if no **Gas Price** is defined, the Rust SDK defaults to the network's minimum gas price.
19+
When the **Script Gas Limit** is not set, the Rust SDK will estimate the consumed gas in the background and set it as the limit.
2020

2121
If the **Witness Limit** is not set, the SDK will set it to the size of all witnesses and signatures defined in the transaction builder.
2222

examples/contracts/src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,12 @@ mod tests {
9898
// ANCHOR: contract_call_cost_estimation
9999
let contract_instance = MyContract::new(contract_id, wallet);
100100

101-
let tolerance = 0.0;
101+
let tolerance = Some(0.0);
102+
let block_horizon = Some(1);
102103
let transaction_cost = contract_instance
103104
.methods()
104105
.initialize_counter(42) // Build the ABI call
105-
.estimate_transaction_cost(Some(tolerance)) // Get estimated transaction cost
106+
.estimate_transaction_cost(tolerance, block_horizon) // Get estimated transaction cost
106107
.await?;
107108
// ANCHOR_END: contract_call_cost_estimation
108109

@@ -144,7 +145,7 @@ mod tests {
144145

145146
// Optional: Configure deployment parameters
146147
let tx_policies = TxPolicies::default()
147-
.with_gas_price(0)
148+
.with_tip(1)
148149
.with_script_gas_limit(1_000_000)
149150
.with_maturity(0);
150151

@@ -281,7 +282,7 @@ mod tests {
281282
let contract_methods = MyContract::new(contract_id.clone(), wallet.clone()).methods();
282283

283284
let tx_policies = TxPolicies::default()
284-
.with_gas_price(1)
285+
.with_tip(1)
285286
.with_script_gas_limit(1_000_000)
286287
.with_maturity(0);
287288

@@ -594,9 +595,10 @@ mod tests {
594595
.add_call(call_handler_1)
595596
.add_call(call_handler_2);
596597

597-
let tolerance = 0.0;
598+
let tolerance = Some(0.0);
599+
let block_horizon = Some(1);
598600
let transaction_cost = multi_call_handler
599-
.estimate_transaction_cost(Some(tolerance)) // Get estimated transaction cost
601+
.estimate_transaction_cost(tolerance, block_horizon) // Get estimated transaction cost
600602
.await?;
601603
// ANCHOR_END: multi_call_cost_estimation
602604

examples/cookbook/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ mod tests {
302302
// ANCHOR_END: custom_tx_adjust
303303

304304
// ANCHOR: custom_tx_policies
305-
let tx_policies = TxPolicies::default().with_gas_price(1);
305+
let tx_policies = TxPolicies::default().with_tip(1);
306306
let tb = tb.with_tx_policies(tx_policies);
307307
// ANCHOR_END: custom_tx_policies
308308

packages/fuels-accounts/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ chrono = { workspace = true }
1515
elliptic-curve = { workspace = true, default-features = false }
1616
eth-keystore = { workspace = true, optional = true }
1717
fuel-core-client = { workspace = true, optional = true }
18+
fuel-core-types = { workspace = true }
1819
fuel-crypto = { workspace = true, features = ["random"] }
1920
fuel-tx = { workspace = true }
2021
fuel-types = { workspace = true, features = ["random"] }

packages/fuels-accounts/src/account.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,12 @@ mod tests {
331331
async fn dry_run_and_get_used_gas(&self, _: FuelTransaction, _: f32) -> Result<u64> {
332332
Ok(0)
333333
}
334+
334335
fn consensus_parameters(&self) -> &ConsensusParameters {
335336
&self.c_param
336337
}
337-
async fn min_gas_price(&self) -> Result<u64> {
338+
339+
async fn estimate_gas_price(&self, _block_header: u32) -> Result<u64> {
338340
Ok(0)
339341
}
340342
}
@@ -390,7 +392,7 @@ mod tests {
390392
assert_eq!(signature, tx_signature);
391393

392394
// Check if the signature is what we expect it to be
393-
assert_eq!(signature, Signature::from_str("a7446cb9703d3bc9e68677715fc7ef6ed72ff4eeac0c67bdb0d9b9c8ba38048e078e38fdd85bf988cefd3737005f1be97ed8b9662f002b0480d4404ebb397fed")?);
395+
assert_eq!(signature, Signature::from_str("37cf6bdefc9e673f99a7fdbbeff454cb5c1bdf632c072f19cf8ac68fa1ede2749c568c56f87d73fc5c97f73b76dfe637422b77c1fdc6010fb4f488444ff5df1a")?);
394396

395397
// Recover the address that signed the transaction
396398
let recovered_address = signature.recover(&message)?;

0 commit comments

Comments
 (0)