Skip to content

Commit 0bbe849

Browse files
authored
Runtime requires <= 1/2 second block execution (paritytech#165)
1 parent 7a655e3 commit 0bbe849

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

runtime/src/lib.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use sp_api::impl_runtime_apis;
4949
use sp_core::{OpaqueMetadata, H160, H256, U256};
5050
use sp_runtime::{
5151
create_runtime_str, generic, impl_opaque_keys,
52-
traits::{BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, Saturating, Verify},
52+
traits::{BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, Verify},
5353
transaction_validity::{TransactionSource, TransactionValidity},
5454
ApplyExtrinsicResult,
5555
};
@@ -100,7 +100,7 @@ pub type Hash = sp_core::H256;
100100
/// Digest item type.
101101
pub type DigestItem = generic::DigestItem<Hash>;
102102

103-
/// Minimum time between blocks.
103+
/// Minimum time between blocks. Slot duration is double this.
104104
pub const MINIMUM_PERIOD: u64 = 3000;
105105

106106
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
@@ -140,17 +140,12 @@ const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
140140

141141
parameter_types! {
142142
pub const BlockHashCount: BlockNumber = 250;
143-
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
144-
/// Assume 10% of weight for average on_initialize calls.
145-
pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()
146-
.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();
147-
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
148143
pub const Version: RuntimeVersion = VERSION;
149-
pub const ExtrinsicBaseWeight: Weight = 10_000_000;
150-
151-
144+
/// We allow for one half second of compute with a 6 second average block time.
145+
/// These values are dictated by Polkadot for the parachain.
152146
pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
153-
::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO);
147+
::with_sensible_defaults(WEIGHT_PER_SECOND / 2, NORMAL_DISPATCH_RATIO);
148+
/// We allow for 5 MB blocks.
154149
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
155150
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
156151
}
@@ -195,8 +190,10 @@ impl frame_system::Config for Runtime {
195190

196191
parameter_types! {
197192
// When running in standalone mode, this controls the block time.
198-
// Block time is double the minimum period.
193+
// Slot duration is double the minimum period.
199194
// https://github.com/paritytech/substrate/blob/e4803bd/frame/aura/src/lib.rs#L197-L199
195+
// We maintain a six second block time in standalone to imitate parachain-like performance
196+
// This value is stored in a seperate constant because it is used in our mock timestamp provider
200197
pub const MinimumPeriod: u64 = MINIMUM_PERIOD;
201198
}
202199

0 commit comments

Comments
 (0)