mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
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:
@@ -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![],
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -23,7 +23,10 @@
|
||||
use sp_std::prelude::*;
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types, debug,
|
||||
weights::{Weight, RuntimeDbWeight},
|
||||
weights::{
|
||||
Weight,
|
||||
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
|
||||
},
|
||||
traits::{Currency, Randomness, OnUnbalanced, Imbalance, LockIdentifier},
|
||||
};
|
||||
use sp_core::u32_trait::{_1, _2, _3, _4};
|
||||
@@ -119,18 +122,10 @@ impl OnUnbalanced<NegativeImbalance> for DealWithFees {
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: BlockNumber = 250;
|
||||
/// We allow for 2 seconds of compute with a 6 second average block time.
|
||||
pub const MaximumBlockWeight: Weight = 2_000_000_000_000;
|
||||
/// Executing 10,000 System remarks (no-op) txs takes ~1.26 seconds -> ~125 µs per tx
|
||||
pub const ExtrinsicBaseWeight: Weight = 125_000_000;
|
||||
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
|
||||
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 25_000_000, // ~25 µs @ 200,000 items
|
||||
write: 100_000_000, // ~100 µs @ 200,000 items
|
||||
};
|
||||
/// Importing a block with 0 txs takes ~5 ms
|
||||
pub const BlockExecutionWeight: Weight = 5_000_000_000;
|
||||
}
|
||||
|
||||
impl frame_system::Trait for Runtime {
|
||||
@@ -146,7 +141,7 @@ impl frame_system::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = DbWeight;
|
||||
type DbWeight = RocksDbWeight;
|
||||
type BlockExecutionWeight = BlockExecutionWeight;
|
||||
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
|
||||
Reference in New Issue
Block a user