Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

Commit d37e88a

Browse files
Alex Sedathei
andauthored
"Implement FixedPoint trait" and "Enable fixed point u128" (#144)
* Enable fixed point u128 Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Commit: c5280a6 [c5280a6] Parents: d047cb3 Author: Marcio Diaz <marcio.diaz@gmail.com> Date: 22 May 2020 at 5:32:44 AM NZST Committer: AlexSedNZ <alex.sedighi@centrality.ai> Commit Date: 29 September 2020 at 2:12:51 PM NZDT Labels: origin/fix/141-weight-multiplier GPG Details: [GOOD] Alex Sedighi * Bring Substrate's commit "Enable fixed point u128 (#6214)" * Ignore fragile tests Co-authored-by: Alexander Theißen <alex.theissen@me.com>
1 parent d047cb3 commit d37e88a

File tree

15 files changed

+2325
-666
lines changed

15 files changed

+2325
-666
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/executor/tests/basic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use sp_core::{
2424
NeverNativeValue, map, traits::Externalities, storage::{well_known_keys, Storage},
2525
};
2626
use sp_runtime::{
27-
ApplyExtrinsicResult, Fixed64,
27+
ApplyExtrinsicResult, FixedI128, FixedPointNumber,
2828
traits::{Hash as HashT, Convert, BlakeTwo256},
2929
transaction_validity::InvalidTransaction,
3030
};
@@ -53,15 +53,15 @@ pub const BLOATY_CODE: &[u8] = node_runtime::WASM_BINARY_BLOATY;
5353
/// Default transfer fee
5454
// NOTE: Transfer fee increased by 1 byte * TransactionByteFee as we include Option<Doughnut> in SignedExtra.
5555
// Option always takes up one byte in extrinsic payload
56-
fn transfer_fee<E: Encode>(extrinsic: &E, fee_multiplier: Fixed64) -> Balance {
56+
fn transfer_fee<E: Encode>(extrinsic: &E, fee_multiplier: FixedI128) -> Balance {
5757
let length_fee = TransactionByteFee::get() * (extrinsic.encode().len() as Balance);
5858

5959
let weight = default_transfer_call().get_dispatch_info().weight;
6060
let weight_fee = <Runtime as pallet_transaction_payment::Trait>
6161
::WeightToFee::convert(weight);
62-
62+
6363
let base_fee = TransactionBaseFee::get();
64-
base_fee + fee_multiplier.saturated_multiply_accumulate(length_fee + weight_fee)
64+
base_fee + fee_multiplier.saturating_mul_acc_int(length_fee + weight_fee)
6565
}
6666

6767
fn xt() -> UncheckedExtrinsic {

bin/node/executor/tests/fees.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use frame_support::{
2121
weights::GetDispatchInfo,
2222
};
2323
use sp_core::{NeverNativeValue, map, storage::Storage};
24-
use sp_runtime::{Fixed64, Perbill, traits::{Convert, BlakeTwo256}};
24+
use sp_runtime::{FixedPointNumber, FixedI128, Perbill, traits::{Convert, BlakeTwo256}};
2525
use node_runtime::{
2626
CheckedExtrinsic, Call, Runtime, Balances, TransactionPayment, TransactionBaseFee,
2727
TransactionByteFee, WeightFeeCoefficient,
@@ -39,7 +39,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
3939
let mut t = new_test_ext(COMPACT_CODE, false);
4040

4141
// initial fee multiplier must be zero
42-
let mut prev_multiplier = Fixed64::from_parts(0);
42+
let mut prev_multiplier = FixedI128::from_inner(0);
4343

4444
t.execute_with(|| {
4545
assert_eq!(TransactionPayment::next_fee_multiplier(), prev_multiplier);
@@ -202,7 +202,7 @@ fn transaction_fee_is_correct_ultimate() {
202202
fn block_weight_capacity_report() {
203203
// Just report how many transfer calls you could fit into a block. The number should at least
204204
// be a few hundred (250 at the time of writing but can change over time). Runs until panic.
205-
use node_primitives::Index;
205+
use node_primitives::{Index, Hash};
206206

207207
// execution ext.
208208
let mut t = new_test_ext(COMPACT_CODE, false);
@@ -269,7 +269,7 @@ fn block_length_capacity_report() {
269269
// Just report how big a block can get. Executes until panic. Should be ignored unless if
270270
// manually inspected. The number should at least be a few megabytes (5 at the time of
271271
// writing but can change over time).
272-
use node_primitives::Index;
272+
use node_primitives::{Index, Hash};
273273

274274
// execution ext.
275275
let mut t = new_test_ext(COMPACT_CODE, false);

0 commit comments

Comments
 (0)