Refactor weight constants, Update to remove redundant overhead (#5884)

* Move weight values to `frame_support`

* more accurate comment

* update balances

* vesting

* update util

* Add weight to time constants

* use weight constants in weights

* update tests
This commit is contained in:
Shawn Tabrizi
2020-05-04 19:52:53 +02:00
committed by GitHub
parent a00a4ca551
commit 8df33e50af
9 changed files with 87 additions and 66 deletions
+8 -8
View File
@@ -18,7 +18,7 @@ use codec::{Encode, Decode, Joiner};
use frame_support::{
StorageValue, StorageMap,
traits::Currency,
weights::{GetDispatchInfo, DispatchInfo, DispatchClass},
weights::{GetDispatchInfo, DispatchInfo, DispatchClass, constants::ExtrinsicBaseWeight},
};
use sp_core::{
NeverNativeValue, map, traits::Externalities, storage::{well_known_keys, Storage},
@@ -33,7 +33,7 @@ use frame_system::{self, EventRecord, Phase};
use node_runtime::{
Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances,
System, TransactionPayment, Event, TransactionByteFee, ExtrinsicBaseWeight,
System, TransactionPayment, Event, TransactionByteFee,
constants::currency::*,
};
use node_primitives::{Balance, Hash};
@@ -359,9 +359,9 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
// Balance Transfer 80_000_000 + 1 Read + 1 Write
// Balance Transfer 70_000_000 + 1 Read + 1 Write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 80_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
DispatchInfo { weight: 70_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
)),
topics: vec![],
},
@@ -416,9 +416,9 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
// Balance Transfer 80_000_000 + 1 Read + 1 Write
// Balance Transfer 70_000_000 + 1 Read + 1 Write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 80_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
DispatchInfo { weight: 70_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
)),
topics: vec![],
},
@@ -440,9 +440,9 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
// Balance Transfer 80_000_000 + 1 Read + 1 Write
// Balance Transfer 70_000_000 + 1 Read + 1 Write
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 80_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
DispatchInfo { weight: 70_000_000 + 25_000_000 + 100_000_000, ..Default::default() }
)),
topics: vec![],
},
+2 -2
View File
@@ -18,14 +18,14 @@ use codec::{Encode, Joiner};
use frame_support::{
StorageValue, StorageMap,
traits::Currency,
weights::GetDispatchInfo,
weights::{GetDispatchInfo, constants::ExtrinsicBaseWeight},
};
use sp_core::{NeverNativeValue, map, storage::Storage};
use sp_runtime::{Fixed128, Perbill, traits::{Convert, BlakeTwo256}};
use node_runtime::{
CheckedExtrinsic, Call, Runtime, Balances, TransactionPayment,
TransactionByteFee, WeightFeeCoefficient,
constants::currency::*, ExtrinsicBaseWeight,
constants::currency::*,
};
use node_runtime::impls::LinearWeightToFee;
use node_primitives::Balance;
@@ -230,7 +230,7 @@ fn submitted_transaction_should_be_valid() {
let res = Executive::validate_transaction(source, extrinsic);
assert_eq!(res.unwrap(), ValidTransaction {
priority: 1_410_740_000_000,
priority: 1_410_710_000_000,
requires: vec![],
provides: vec![(address, 0).encode()],
longevity: 128,