Companion for Trim compact solution for length during preparation (#2649)

* Companion for Trim compact solution for length during preparation

https://github.com/paritytech/substrate/pull/8317

* eliminate potential for overflow in OffchainSolutionLengthLimit

* Apply suggestions from code review

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* update substrate: cargo update -p sp-io

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Peter Goodspeed-Niklaus
2021-04-13 15:53:51 +02:00
committed by GitHub
parent f1f9192a38
commit f822381c4c
5 changed files with 169 additions and 155 deletions
+149 -149
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -118,6 +118,14 @@ parameter_types! {
.max_extrinsic .max_extrinsic
.expect("Normal extrinsics have weight limit configured by default; qed") .expect("Normal extrinsics have weight limit configured by default; qed")
.saturating_sub(BlockExecutionWeight::get()); .saturating_sub(BlockExecutionWeight::get());
/// A limit for off-chain phragmen unsigned solution length.
///
/// We allow up to 90% of the block's size to be consumed by the solution.
pub OffchainSolutionLengthLimit: u32 = Perbill::from_rational(90_u32, 100) *
*BlockLength::get()
.max
.get(DispatchClass::Normal);
} }
/// Parameterized slow adjusting fee updated based on /// Parameterized slow adjusting fee updated based on
+4 -2
View File
@@ -34,7 +34,8 @@ use primitives::v1::{
use runtime_common::{ use runtime_common::{
claims, SlowAdjustingFeeUpdate, CurrencyToVote, claims, SlowAdjustingFeeUpdate, CurrencyToVote,
impls::DealWithFees, impls::DealWithFees,
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength, OffchainSolutionWeightLimit, BlockHashCount, RocksDbWeight, BlockWeights, BlockLength,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder, ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
}; };
use sp_runtime::{ use sp_runtime::{
@@ -338,7 +339,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type UnsignedPhase = UnsignedPhase; type UnsignedPhase = UnsignedPhase;
type SolutionImprovementThreshold = SolutionImprovementThreshold; type SolutionImprovementThreshold = SolutionImprovementThreshold;
type MinerMaxIterations = MinerMaxIterations; type MinerMaxIterations = MinerMaxIterations;
type MinerMaxWeight = OffchainSolutionWeightLimit; // For now use the one from staking. type MinerMaxWeight = OffchainSolutionWeightLimit;
type MinerMaxLength = OffchainSolutionLengthLimit;
type MinerTxPriority = NposSolutionPriority; type MinerTxPriority = NposSolutionPriority;
type DataProvider = Staking; type DataProvider = Staking;
type OnChainAccuracy = Perbill; type OnChainAccuracy = Perbill;
+4 -2
View File
@@ -24,7 +24,8 @@ use pallet_transaction_payment::CurrencyAdapter;
use runtime_common::{ use runtime_common::{
claims, SlowAdjustingFeeUpdate, CurrencyToVote, claims, SlowAdjustingFeeUpdate, CurrencyToVote,
impls::DealWithFees, impls::DealWithFees,
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength, OffchainSolutionWeightLimit, BlockHashCount, RocksDbWeight, BlockWeights, BlockLength,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder, ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
}; };
@@ -348,7 +349,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type UnsignedPhase = UnsignedPhase; type UnsignedPhase = UnsignedPhase;
type SolutionImprovementThreshold = SolutionImprovementThreshold; type SolutionImprovementThreshold = SolutionImprovementThreshold;
type MinerMaxIterations = MinerMaxIterations; type MinerMaxIterations = MinerMaxIterations;
type MinerMaxWeight = OffchainSolutionWeightLimit; // For now use the one from staking. type MinerMaxWeight = OffchainSolutionWeightLimit;
type MinerMaxLength = OffchainSolutionLengthLimit;
type MinerTxPriority = NposSolutionPriority; type MinerTxPriority = NposSolutionPriority;
type DataProvider = Staking; type DataProvider = Staking;
type OnChainAccuracy = Perbill; type OnChainAccuracy = Perbill;
+4 -2
View File
@@ -34,7 +34,8 @@ use runtime_common::{
mmr as mmr_common, mmr as mmr_common,
SlowAdjustingFeeUpdate, CurrencyToVote, SlowAdjustingFeeUpdate, CurrencyToVote,
impls::ToAuthor, impls::ToAuthor,
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, OffchainSolutionWeightLimit, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder, ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
}; };
use sp_runtime::{ use sp_runtime::{
@@ -365,7 +366,8 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type UnsignedPhase = UnsignedPhase; type UnsignedPhase = UnsignedPhase;
type SolutionImprovementThreshold = SolutionImprovementThreshold; type SolutionImprovementThreshold = SolutionImprovementThreshold;
type MinerMaxIterations = MinerMaxIterations; type MinerMaxIterations = MinerMaxIterations;
type MinerMaxWeight = OffchainSolutionWeightLimit; // For now use the one from staking. type MinerMaxWeight = OffchainSolutionWeightLimit;
type MinerMaxLength = OffchainSolutionLengthLimit;
type MinerTxPriority = NposSolutionPriority; type MinerTxPriority = NposSolutionPriority;
type DataProvider = Staking; type DataProvider = Staking;
type OnChainAccuracy = Perbill; type OnChainAccuracy = Perbill;