mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 15:55:49 +00:00
backing: move the min votes threshold to the runtime (#1200)
* move min backing votes const to runtime also cache it per-session in the backing subsystem Signed-off-by: alindima <alin@parity.io> * add runtime migration * introduce api versioning for min_backing votes also enable it for rococo/versi for testing * also add min_backing_votes runtime calls to statement-distribution this dependency has been recently introduced by async backing * remove explicit version runtime API call this is not needed, as the RuntimeAPISubsystem already takes care of versioning and will return NotSupported if the version is not right. * address review comments - parametrise backing votes runtime API with session index - remove RuntimeInfo usage in backing subsystem, as runtime API caches the min backing votes by session index anyway. - move the logic for adjusting the configured needed backing votes with the size of the backing group to a primitives helper. - move the legacy min backing votes value to a primitives helper. - mark JoinMultiple error as fatal, since the Canceled (non-multiple) counterpart is also fatal. - make backing subsystem handle fatal errors for new leaves update. - add HostConfiguration consistency check for zeroed backing votes threshold - add cumulus accompanying change * fix cumulus test compilation * fix tests * more small fixes * fix merge * bump runtime api version for westend and rollback version for rococo --------- Signed-off-by: alindima <alin@parity.io> Co-authored-by: Javier Viola <javier@parity.io>
This commit is contained in:
@@ -34,19 +34,19 @@ pub mod runtime_api;
|
||||
// Current primitives not requiring versioning are exported here.
|
||||
// Primitives requiring versioning must not be exported and must be referred by an exact version.
|
||||
pub use v5::{
|
||||
byzantine_threshold, check_candidate_backing, collator_signature_payload, metric_definitions,
|
||||
slashing, supermajority_threshold, well_known_keys, AbridgedHostConfiguration,
|
||||
AbridgedHrmpChannel, AccountId, AccountIndex, AccountPublic, ApprovalVote, AssignmentId,
|
||||
AuthorityDiscoveryId, AvailabilityBitfield, BackedCandidate, Balance, BlakeTwo256, Block,
|
||||
BlockId, BlockNumber, CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash,
|
||||
CandidateIndex, CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet,
|
||||
CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog,
|
||||
CoreIndex, CoreOccupied, CoreState, DisputeState, DisputeStatement, DisputeStatementSet,
|
||||
DownwardMessage, EncodeAs, ExecutorParam, ExecutorParams, ExecutorParamsHash,
|
||||
ExplicitDisputeStatement, GroupIndex, GroupRotationInfo, Hash, HashT, HeadData, Header,
|
||||
HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage, IndexedVec, InherentData,
|
||||
InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce, OccupiedCore,
|
||||
OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry,
|
||||
byzantine_threshold, check_candidate_backing, collator_signature_payload,
|
||||
effective_minimum_backing_votes, metric_definitions, slashing, supermajority_threshold,
|
||||
well_known_keys, AbridgedHostConfiguration, AbridgedHrmpChannel, AccountId, AccountIndex,
|
||||
AccountPublic, ApprovalVote, AssignmentId, AuthorityDiscoveryId, AvailabilityBitfield,
|
||||
BackedCandidate, Balance, BlakeTwo256, Block, BlockId, BlockNumber, CandidateCommitments,
|
||||
CandidateDescriptor, CandidateEvent, CandidateHash, CandidateIndex, CandidateReceipt,
|
||||
CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CollatorId, CollatorSignature,
|
||||
CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex, CoreOccupied, CoreState,
|
||||
DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage, EncodeAs, ExecutorParam,
|
||||
ExecutorParams, ExecutorParamsHash, ExplicitDisputeStatement, GroupIndex, GroupRotationInfo,
|
||||
Hash, HashT, HeadData, Header, HrmpChannelId, Id, InboundDownwardMessage, InboundHrmpMessage,
|
||||
IndexedVec, InherentData, InvalidDisputeStatementKind, Moment, MultiDisputeStatementSet, Nonce,
|
||||
OccupiedCore, OccupiedCoreAssumption, OutboundHrmpMessage, ParathreadClaim, ParathreadEntry,
|
||||
PersistedValidationData, PvfCheckStatement, PvfExecTimeoutKind, PvfPrepTimeoutKind,
|
||||
RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues, RuntimeMetricLabels,
|
||||
RuntimeMetricOp, RuntimeMetricUpdate, ScheduledCore, ScrapedOnChainVotes, SessionIndex,
|
||||
@@ -55,9 +55,9 @@ pub use v5::{
|
||||
UncheckedSignedAvailabilityBitfields, UncheckedSignedStatement, UpgradeGoAhead,
|
||||
UpgradeRestriction, UpwardMessage, ValidDisputeStatementKind, ValidationCode,
|
||||
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation,
|
||||
ValidityError, ASSIGNMENT_KEY_TYPE_ID, LOWEST_PUBLIC_ID, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE,
|
||||
MAX_POV_SIZE, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, PARACHAINS_INHERENT_IDENTIFIER,
|
||||
PARACHAIN_KEY_TYPE_ID,
|
||||
ValidityError, ASSIGNMENT_KEY_TYPE_ID, LEGACY_MIN_BACKING_VOTES, LOWEST_PUBLIC_ID,
|
||||
MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
|
||||
PARACHAINS_INHERENT_IDENTIFIER, PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -240,6 +240,13 @@ sp_api::decl_runtime_apis! {
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()>;
|
||||
|
||||
/***** Staging *****/
|
||||
|
||||
/// Get the minimum number of backing votes for a parachain candidate.
|
||||
/// This is a staging method! Do not use on production runtimes!
|
||||
#[api_version(6)]
|
||||
fn minimum_backing_votes() -> u32;
|
||||
|
||||
/***** Asynchronous backing *****/
|
||||
|
||||
/// Returns the state of parachain backing for a given para.
|
||||
|
||||
@@ -390,6 +390,10 @@ pub const MAX_POV_SIZE: u32 = 5 * 1024 * 1024;
|
||||
/// Can be adjusted in configuration.
|
||||
pub const ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE: u32 = 10_000;
|
||||
|
||||
/// Backing votes threshold used from the host prior to runtime API version 6 and from the runtime
|
||||
/// prior to v9 configuration migration.
|
||||
pub const LEGACY_MIN_BACKING_VOTES: u32 = 2;
|
||||
|
||||
// The public key of a keypair used by a validator for determining assignments
|
||||
/// to approve included parachain candidates.
|
||||
mod assignment_app {
|
||||
@@ -1695,6 +1699,14 @@ pub const fn supermajority_threshold(n: usize) -> usize {
|
||||
n - byzantine_threshold(n)
|
||||
}
|
||||
|
||||
/// Adjust the configured needed backing votes with the size of the backing group.
|
||||
pub fn effective_minimum_backing_votes(
|
||||
group_len: usize,
|
||||
configured_minimum_backing_votes: u32,
|
||||
) -> usize {
|
||||
sp_std::cmp::min(group_len, configured_minimum_backing_votes as usize)
|
||||
}
|
||||
|
||||
/// Information about validator sets of a session.
|
||||
///
|
||||
/// NOTE: `SessionInfo` is frozen. Do not include new fields, consider creating a separate runtime
|
||||
|
||||
Reference in New Issue
Block a user