Companion for substrate/pull/7215 (#1768)

* Companion for substrate/pull/7215

* More fixes

* Fix build

* fix

* Fix again with normal

* Fix build

* Latest changes

* "Update Substrate"

Co-authored-by: parity-processbot <>
This commit is contained in:
Kian Paimani
2020-10-04 14:12:34 +02:00
committed by GitHub
parent 8d36e9b0f0
commit 4d5b7a6245
8 changed files with 163 additions and 141 deletions
+136 -136
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -51,7 +51,7 @@ pub type NegativeImbalance<T> = <pallet_balances::Module<T> as Currency<<T as fr
/// We assume that an on-initialize consumes 10% of the weight on average, hence a single extrinsic /// We assume that an on-initialize consumes 10% of the weight on average, hence a single extrinsic
/// will not be allowed to consume more than `AvailableBlockRatio - 10%`. /// will not be allowed to consume more than `AvailableBlockRatio - 10%`.
const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10); pub const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
// Common constants used in all runtimes. // Common constants used in all runtimes.
parameter_types! { parameter_types! {
@@ -61,8 +61,9 @@ parameter_types! {
/// Portion of the block available to normal class of dispatches. /// Portion of the block available to normal class of dispatches.
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
/// Maximum weight that a _single_ extrinsic can take. /// Maximum weight that a _single_ extrinsic can take.
pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get() pub MaximumExtrinsicWeight: Weight =
.saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT) * MaximumBlockWeight::get(); AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
* MaximumBlockWeight::get();
/// Maximum length of block. 5MB. /// Maximum length of block. 5MB.
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
/// The portion of the `AvailableBlockRatio` that we adjust the fees with. Blocks filled less /// The portion of the `AvailableBlockRatio` that we adjust the fees with. Blocks filled less
@@ -411,6 +411,7 @@ mod tests {
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = (); type MaxIterations = ();
type MinSolutionScoreBump = (); type MinSolutionScoreBump = ();
type OffchainSolutionWeightLimit = MaximumBlockWeight;
type WeightInfo = (); type WeightInfo = ();
} }
+8 -1
View File
@@ -332,6 +332,9 @@ parameter_types! {
pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4; pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
pub const MaxIterations: u32 = 10; pub const MaxIterations: u32 = 10;
pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
pub OffchainSolutionWeightLimit: Weight = MaximumExtrinsicWeight::get()
.saturating_sub(BlockExecutionWeight::get())
.saturating_sub(ExtrinsicBaseWeight::get());
} }
type SlashCancelOrigin = EnsureOneOf< type SlashCancelOrigin = EnsureOneOf<
@@ -362,6 +365,9 @@ impl pallet_staking::Trait for Runtime {
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations; type MaxIterations = MaxIterations;
type MinSolutionScoreBump = MinSolutionScoreBump; type MinSolutionScoreBump = MinSolutionScoreBump;
// The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of
// a single extrinsic.
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>; type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
} }
@@ -574,7 +580,8 @@ parameter_types! {
} }
parameter_types! { parameter_types! {
pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; pub StakingUnsignedPriority: TransactionPriority =
Perbill::from_percent(90) * TransactionPriority::max_value();
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
} }
+8 -1
View File
@@ -339,6 +339,9 @@ parameter_types! {
pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 16; pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 16;
pub const MaxIterations: u32 = 10; pub const MaxIterations: u32 = 10;
pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
pub OffchainSolutionWeightLimit: Weight = MaximumExtrinsicWeight::get()
.saturating_sub(BlockExecutionWeight::get())
.saturating_sub(ExtrinsicBaseWeight::get());
} }
type SlashCancelOrigin = EnsureOneOf< type SlashCancelOrigin = EnsureOneOf<
@@ -369,6 +372,9 @@ impl pallet_staking::Trait for Runtime {
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations; type MaxIterations = MaxIterations;
type MinSolutionScoreBump = MinSolutionScoreBump; type MinSolutionScoreBump = MinSolutionScoreBump;
// The unsigned solution weight targeted by the OCW. We set it to the maximum possible value of
// a single extrinsic.
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>; type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
} }
@@ -620,7 +626,8 @@ parameter_types! {
} }
parameter_types! { parameter_types! {
pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2; pub StakingUnsignedPriority: TransactionPriority =
Perbill::from_percent(90) * TransactionPriority::max_value();
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
} }
+1
View File
@@ -561,6 +561,7 @@ impl pallet_staking::Trait for Runtime {
type Call = Call; type Call = Call;
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations; type MaxIterations = MaxIterations;
type OffchainSolutionWeightLimit = MaximumBlockWeight;
type MinSolutionScoreBump = MinSolutionScoreBump; type MinSolutionScoreBump = MinSolutionScoreBump;
type WeightInfo = (); type WeightInfo = ();
} }
+1
View File
@@ -305,6 +305,7 @@ impl pallet_staking::Trait for Runtime {
type Call = Call; type Call = Call;
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations; type MaxIterations = MaxIterations;
type OffchainSolutionWeightLimit = MaximumBlockWeight;
type MinSolutionScoreBump = MinSolutionScoreBump; type MinSolutionScoreBump = MinSolutionScoreBump;
type WeightInfo = (); type WeightInfo = ();
+4
View File
@@ -310,6 +310,9 @@ parameter_types! {
pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4; pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
pub const MaxIterations: u32 = 10; pub const MaxIterations: u32 = 10;
pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000); pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
pub OffchainSolutionWeightLimit: Weight = MaximumExtrinsicWeight::get()
.saturating_sub(BlockExecutionWeight::get())
.saturating_sub(ExtrinsicBaseWeight::get());
} }
impl pallet_staking::Trait for Runtime { impl pallet_staking::Trait for Runtime {
@@ -334,6 +337,7 @@ impl pallet_staking::Trait for Runtime {
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations; type MaxIterations = MaxIterations;
type MinSolutionScoreBump = MinSolutionScoreBump; type MinSolutionScoreBump = MinSolutionScoreBump;
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>; type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
} }