diff --git a/substrate/bin/node-template/runtime/src/lib.rs b/substrate/bin/node-template/runtime/src/lib.rs index 863f263077..d3f2f1a94d 100644 --- a/substrate/bin/node-template/runtime/src/lib.rs +++ b/substrate/bin/node-template/runtime/src/lib.rs @@ -34,7 +34,7 @@ pub use sp_runtime::{Permill, Perbill}; pub use frame_support::{ StorageValue, construct_runtime, parameter_types, traits::Randomness, - weights::Weight, + weights::{Weight, RuntimeDbWeight}, }; /// Importing a template pallet @@ -126,6 +126,12 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const Version: RuntimeVersion = VERSION; + /// This probably should not be changed unless you have specific + /// disk i/o conditions for the node. + pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { + read: 60_000_000, // ~0.06 ms = ~60 µs + write: 200_000_000, // ~0.2 ms = 200 µs + }; } impl system::Trait for Runtime { @@ -154,7 +160,7 @@ impl system::Trait for Runtime { /// Maximum weight of each block. type MaximumBlockWeight = MaximumBlockWeight; /// The weight of database operations that the runtime can invoke. - type DbWeight = (); + type DbWeight = DbWeight; /// Maximum size of all encoded transactions (in bytes) that are allowed in one block. type MaximumBlockLength = MaximumBlockLength; /// Portion of the block weight that is available to all normal transactions. diff --git a/substrate/bin/node/executor/tests/basic.rs b/substrate/bin/node/executor/tests/basic.rs index 758ea1a32e..151b7c54f6 100644 --- a/substrate/bin/node/executor/tests/basic.rs +++ b/substrate/bin/node/executor/tests/basic.rs @@ -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: 200_000_000, ..Default::default() } + DispatchInfo { weight: 460_000_000, ..Default::default() } )), 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: 200_000_000, ..Default::default() } + DispatchInfo { weight: 460_000_000, ..Default::default() } )), 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: 200_000_000, ..Default::default() } + DispatchInfo { weight: 460_000_000, ..Default::default() } )), topics: vec![], }, diff --git a/substrate/bin/node/executor/tests/submit_transaction.rs b/substrate/bin/node/executor/tests/submit_transaction.rs index 3a41c3483c..4a66ac4c21 100644 --- a/substrate/bin/node/executor/tests/submit_transaction.rs +++ b/substrate/bin/node/executor/tests/submit_transaction.rs @@ -229,7 +229,7 @@ fn submitted_transaction_should_be_valid() { let res = Executive::validate_transaction(source, extrinsic); assert_eq!(res.unwrap(), ValidTransaction { - priority: 2_410_600_000_000, + priority: 2_411_380_000_000, requires: vec![], provides: vec![(address, 0).encode()], longevity: 128, diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index b1797fffb3..d225d3e478 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -23,7 +23,7 @@ use sp_std::prelude::*; use frame_support::{ construct_runtime, parameter_types, debug, - weights::Weight, + weights::{Weight, RuntimeDbWeight}, traits::{Currency, Randomness, OnUnbalanced, Imbalance}, }; use sp_core::u32_trait::{_1, _2, _3, _4}; @@ -123,6 +123,10 @@ parameter_types! { 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: 60_000_000, // ~0.06 ms = ~60 µs + write: 200_000_000, // ~0.2 ms = 200 µs + }; } impl frame_system::Trait for Runtime { @@ -138,7 +142,7 @@ impl frame_system::Trait for Runtime { type Event = Event; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; - type DbWeight = (); + type DbWeight = DbWeight; type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = Version;