Skip to content

Commit

Permalink
Upgrade to Rust 1.73 and fix related todo (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dentosal authored Nov 7, 2023
1 parent f77ef3e commit 09cc333
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.72.0
RUST_VERSION: 1.73.0
NIGHTLY_RUST_VERSION: nightly-2023-08-28

jobs:
Expand Down
13 changes: 6 additions & 7 deletions fuel-tx/src/transaction/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,20 @@ impl TransactionFee {
) -> Option<Self> {
let factor = params.gas_price_factor as u128;

// TODO: use native div_ceil once stabilized out from nightly
let bytes_gas = params.gas_per_byte.checked_mul(metered_bytes)?;
let min_gas = bytes_gas
.checked_add(gas_used_by_signature_checks)?
.checked_add(gas_used_by_metadata)?
.checked_add(gas_used_by_predicates)?;
let max_gas = min_gas.checked_add(gas_limit)?;

let max_gas_to_pay = max_gas.checked_mul(gas_price).and_then(|total| {
num_integer::div_ceil(total as u128, factor).try_into().ok()
});
let max_gas_to_pay = max_gas
.checked_mul(gas_price)
.and_then(|total| (total as u128).div_ceil(factor).try_into().ok());

let min_gas_to_pay = min_gas.checked_mul(gas_price).and_then(|bytes| {
num_integer::div_ceil(bytes as u128, factor).try_into().ok()
});
let min_gas_to_pay = min_gas
.checked_mul(gas_price)
.and_then(|bytes| (bytes as u128).div_ceil(factor).try_into().ok());

min_gas_to_pay
.zip(max_gas_to_pay)
Expand Down
4 changes: 1 addition & 3 deletions fuel-vm/src/interpreter/receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ impl ReceiptsCtx {
/// only be used when the list of receipts has been mutated externally.
fn recalculate_root(&mut self) {
self.receipts_tree = MerkleTree::new();
// TODO: Remove `clone()` when `to_bytes()` no longer requires `&mut self`
let receipts = self.as_ref().clone();
for receipt in receipts {
for receipt in &self.receipts {
self.receipts_tree.push(receipt.to_bytes().as_slice())
}
}
Expand Down

0 comments on commit 09cc333

Please sign in to comment.