mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 09:57:56 +00:00
Weights to u64 + Balances Weights (#5446)
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ use sp_core::{
|
||||
NeverNativeValue, map, traits::Externalities, storage::{well_known_keys, Storage},
|
||||
};
|
||||
use sp_runtime::{
|
||||
ApplyExtrinsicResult, Fixed64,
|
||||
ApplyExtrinsicResult, Fixed128,
|
||||
traits::{Hash as HashT, Convert, BlakeTwo256},
|
||||
transaction_validity::InvalidTransaction,
|
||||
};
|
||||
@@ -51,7 +51,7 @@ use self::common::{*, sign};
|
||||
pub const BLOATY_CODE: &[u8] = node_runtime::WASM_BINARY_BLOATY;
|
||||
|
||||
/// Default transfer fee
|
||||
fn transfer_fee<E: Encode>(extrinsic: &E, fee_multiplier: Fixed64) -> Balance {
|
||||
fn transfer_fee<E: Encode>(extrinsic: &E, fee_multiplier: Fixed128) -> Balance {
|
||||
let length_fee = TransactionByteFee::get() * (extrinsic.encode().len() as Balance);
|
||||
|
||||
let weight = default_transfer_call().get_dispatch_info().weight;
|
||||
@@ -338,7 +338,7 @@ fn full_native_block_import_works() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 10000, class: DispatchClass::Mandatory, pays_fee: true }
|
||||
DispatchInfo { weight: 10_000_000, class: DispatchClass::Mandatory, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -359,7 +359,7 @@ fn full_native_block_import_works() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
|
||||
DispatchInfo { weight: 200_000_000, class: DispatchClass::Normal, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -391,7 +391,7 @@ fn full_native_block_import_works() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 10000, class: DispatchClass::Mandatory, pays_fee: true }
|
||||
DispatchInfo { weight: 10_000_000, class: DispatchClass::Mandatory, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -414,7 +414,7 @@ fn full_native_block_import_works() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(1),
|
||||
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
|
||||
DispatchInfo { weight: 200_000_000, class: DispatchClass::Normal, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -437,7 +437,7 @@ fn full_native_block_import_works() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(2),
|
||||
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
|
||||
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
|
||||
DispatchInfo { weight: 200_000_000, class: DispatchClass::Normal, pays_fee: true }
|
||||
)),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -817,5 +817,3 @@ fn should_import_block_with_test_client() {
|
||||
|
||||
client.import(BlockOrigin::Own, block).unwrap();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use frame_support::{
|
||||
weights::GetDispatchInfo,
|
||||
};
|
||||
use sp_core::{NeverNativeValue, map, storage::Storage};
|
||||
use sp_runtime::{Fixed64, Perbill, traits::{Convert, BlakeTwo256}};
|
||||
use sp_runtime::{Fixed128, Perbill, traits::{Convert, BlakeTwo256}};
|
||||
use node_runtime::{
|
||||
CheckedExtrinsic, Call, Runtime, Balances, TransactionPayment, TransactionBaseFee,
|
||||
TransactionByteFee, WeightFeeCoefficient,
|
||||
@@ -39,7 +39,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
|
||||
let mut t = new_test_ext(COMPACT_CODE, false);
|
||||
|
||||
// initial fee multiplier must be zero
|
||||
let mut prev_multiplier = Fixed64::from_parts(0);
|
||||
let mut prev_multiplier = Fixed128::from_parts(0);
|
||||
|
||||
t.execute_with(|| {
|
||||
assert_eq!(TransactionPayment::next_fee_multiplier(), prev_multiplier);
|
||||
@@ -188,7 +188,9 @@ fn transaction_fee_is_correct_ultimate() {
|
||||
let weight_fee = LinearWeightToFee::<WeightFeeCoefficient>::convert(weight);
|
||||
|
||||
// we know that weight to fee multiplier is effect-less in block 1.
|
||||
assert_eq!(weight_fee as Balance, MILLICENTS);
|
||||
// current weight of transfer = 200_000_000
|
||||
// Linear weight to fee is 1:1 right now (1 weight = 1 unit of balance)
|
||||
assert_eq!(weight_fee, weight as Balance);
|
||||
balance_alice -= weight_fee;
|
||||
balance_alice -= tip;
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ fn submitted_transaction_should_be_valid() {
|
||||
let res = Executive::validate_transaction(source, extrinsic);
|
||||
|
||||
assert_eq!(res.unwrap(), ValidTransaction {
|
||||
priority: 2_411_002_000_000,
|
||||
priority: 2_410_600_000_000,
|
||||
requires: vec![],
|
||||
provides: vec![(address, 0).encode()],
|
||||
longevity: 128,
|
||||
|
||||
Reference in New Issue
Block a user