difftreelog
fix lookahead leftovers
in: master
6 files changed
primitives/common/src/constants.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;18use frame_support::{19 parameter_types,20 weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},21};22use sp_runtime::Perbill;2324use crate::types::{Balance, BlockNumber};2526#[cfg(not(feature = "lookahead"))]27pub const MILLISECS_PER_BLOCK: u64 = 12000;28#[cfg(feature = "lookahead")]29pub const MILLISECS_PER_BLOCK: u64 = 3000;30pub const MILLISECS_PER_RELAY_BLOCK: u64 = 6000;3132pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;3334// These time units are defined in number of blocks.35pub const MINUTES: u32 = 60_000 / (MILLISECS_PER_BLOCK as u32);36pub const HOURS: u32 = MINUTES * 60;37pub const DAYS: u32 = HOURS * 24;3839// These time units are defined in number of relay blocks.40pub const RELAY_MINUTES: u32 = 60_000 / (MILLISECS_PER_RELAY_BLOCK as u32);41pub const RELAY_HOURS: u32 = RELAY_MINUTES * 60;42pub const RELAY_DAYS: u32 = RELAY_HOURS * 24;4344pub const MICROUNIQUE: Balance = 1_000_000_000_000;45pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;46pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;47pub const UNIQUE: Balance = 100 * CENTIUNIQUE;4849/// Minimum balance required to create or keep an account open.50pub const EXISTENTIAL_DEPOSIT: u128 = 0;5152/// Amount of Balance reserved for candidate registration.53pub const GENESIS_LICENSE_BOND: u128 = 1_000_000_000_000 * UNIQUE;54/// Amount of maximum collators for Collator Selection.55pub const MAX_COLLATORS: u32 = 10;56/// How long a periodic session lasts in blocks.57pub const SESSION_LENGTH: BlockNumber = HOURS;5859// Targeting 0.1 UNQ per transfer60pub const WEIGHT_TO_FEE_COEFF: u64 = /*<weight2fee>*/74_401_761_267_585_092/*</weight2fee>*/;6162// Targeting 0.15 UNQ per transfer via ETH63pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_873_477_799_288/*</mingasprice>*/;6465/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.66/// This is used to limit the maximal weight of a single extrinsic.67pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);68/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used69/// by Operational extrinsics.70pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);71/// We allow for 2 seconds of compute with a 6 second average block time.72pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(73 WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),74 MAX_POV_SIZE as u64,75);7677parameter_types! {78 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE / 2;79}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use cumulus_primitives_core::relay_chain::MAX_POV_SIZE;18use frame_support::{19 parameter_types,20 weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},21};22use sp_runtime::Perbill;2324use crate::types::{Balance, BlockNumber};2526#[cfg(not(feature = "lookahead"))]27pub const MILLISECS_PER_BLOCK: u64 = 12000;28#[cfg(feature = "lookahead")]29pub const MILLISECS_PER_BLOCK: u64 = 6000;30pub const MILLISECS_PER_RELAY_BLOCK: u64 = 6000;3132pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;3334// These time units are defined in number of blocks.35pub const MINUTES: u32 = 60_000 / (MILLISECS_PER_BLOCK as u32);36pub const HOURS: u32 = MINUTES * 60;37pub const DAYS: u32 = HOURS * 24;3839// These time units are defined in number of relay blocks.40pub const RELAY_MINUTES: u32 = 60_000 / (MILLISECS_PER_RELAY_BLOCK as u32);41pub const RELAY_HOURS: u32 = RELAY_MINUTES * 60;42pub const RELAY_DAYS: u32 = RELAY_HOURS * 24;4344pub const MICROUNIQUE: Balance = 1_000_000_000_000;45pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;46pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;47pub const UNIQUE: Balance = 100 * CENTIUNIQUE;4849/// Minimum balance required to create or keep an account open.50pub const EXISTENTIAL_DEPOSIT: u128 = 0;5152/// Amount of Balance reserved for candidate registration.53pub const GENESIS_LICENSE_BOND: u128 = 1_000_000_000_000 * UNIQUE;54/// Amount of maximum collators for Collator Selection.55pub const MAX_COLLATORS: u32 = 10;56/// How long a periodic session lasts in blocks.57pub const SESSION_LENGTH: BlockNumber = HOURS;5859// Targeting 0.1 UNQ per transfer60pub const WEIGHT_TO_FEE_COEFF: u64 = /*<weight2fee>*/74_401_761_267_585_092/*</weight2fee>*/;6162// Targeting 0.15 UNQ per transfer via ETH63pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_873_477_799_288/*</mingasprice>*/;6465/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.66/// This is used to limit the maximal weight of a single extrinsic.67pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);68/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used69/// by Operational extrinsics.70pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);71/// We allow for 2 seconds of compute with a 6 second average block time.72pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(73 WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),74 MAX_POV_SIZE as u64,75);7677parameter_types! {78 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE / 2;79}runtime/common/config/parachain.rsdiffbeforeafterboth--- a/runtime/common/config/parachain.rs
+++ b/runtime/common/config/parachain.rs
@@ -43,6 +43,8 @@
#[cfg(feature = "lookahead")]
type CheckAssociatedRelayNumber =
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
+ #[cfg(feature = "lookahead")]
+ type ConsensusHook = ConsensusHook;
}
impl parachain_info::Config for Runtime {}
runtime/common/config/substrate.rsdiffbeforeafterboth--- a/runtime/common/config/substrate.rs
+++ b/runtime/common/config/substrate.rs
@@ -17,7 +17,7 @@
use frame_support::{
dispatch::DispatchClass,
ord_parameter_types, parameter_types,
- traits::{ConstBool, ConstU32, Everything, NeverEnsureOrigin},
+ traits::{ConstBool, ConstU32, ConstU64, Everything, NeverEnsureOrigin},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight},
ConstantMultiplier,
@@ -134,15 +134,14 @@
type MaxKeyLen = MigrationMaxKeyLen;
}
-parameter_types! {
- pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
-}
-
impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = ();
- type MinimumPeriod = MinimumPeriod;
+ #[cfg(not(feature = "lookahead"))]
+ type MinimumPeriod = ConstU64<{SLOT_DURATION / 2}>;
+ #[cfg(feature = "lookahead")]
+ type MinimumPeriod = ConstU64<0>;
type WeightInfo = ();
}
@@ -247,6 +246,8 @@
type DisabledValidators = ();
type MaxAuthorities = MaxAuthorities;
type AllowMultipleBlocksPerSlot = ConstBool<true>;
+ #[cfg(feature = "lookahead")]
+ type SlotDuration = ConstU64<SLOT_DURATION>;
}
impl pallet_utility::Config for Runtime {
runtime/common/mod.rsdiffbeforeafterboth--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -44,7 +44,7 @@
use up_common::types::{AccountId, BlockNumber};
use crate::{
- AllPalletsWithSystem, Aura, Balances, InherentDataExt, Runtime, RuntimeCall, Signature,
+ AllPalletsWithSystem, Aura, Balances, Runtime, RuntimeCall, Signature,
Treasury,
};
@@ -146,13 +146,17 @@
}
}
+#[cfg(not(feature = "lookahead"))]
pub(crate) struct CheckInherents;
+#[cfg(not(feature = "lookahead"))]
impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
fn check_inherents(
block: &Block,
relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,
) -> sp_inherents::CheckInherentsResult {
+ use crate::InherentDataExt;
+
let relay_chain_slot = relay_state_proof
.read_slot()
.expect("Could not read the relay chain slot from the proof");
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -485,7 +485,14 @@
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
- sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
+ #[cfg(not(feature = "lookahead"))]
+ {
+ sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
+ }
+ #[cfg(feature = "lookahead")]
+ {
+ sp_consensus_aura::SlotDuration::from_millis(up_common::constants::SLOT_DURATION)
+ }
}
fn authorities() -> Vec<AuraId> {
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -67,8 +67,15 @@
impl_common_runtime_apis!();
+// CheckInherents is included in consensus hook
+#[cfg(not(feature = "lookahead"))]
cumulus_pallet_parachain_system::register_validate_block!(
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
CheckInherents = CheckInherents,
);
+#[cfg(feature = "lookahead")]
+cumulus_pallet_parachain_system::register_validate_block!(
+ Runtime = Runtime,
+ BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
+);