mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
Migrate polkadot-primitives to v6 (#1543)
- Async-backing related primitives are stable `primitives::v6` - Async-backing API is now part of `api_version(7)` - It's enabled on Rococo and Westend runtimes --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
// `v5` is currently the latest stable version of the runtime API.
|
||||
pub mod v5;
|
||||
// `v6` is currently the latest stable version of the runtime API.
|
||||
pub mod v6;
|
||||
|
||||
// The 'staging' version is special - it contains primitives which are
|
||||
// still in development. Once they are considered stable, they will be
|
||||
@@ -33,20 +33,21 @@ 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,
|
||||
pub use v6::{
|
||||
async_backing, 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, 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,
|
||||
AccountPublic, ApprovalVote, AssignmentId, AsyncBackingParams, AuthorityDiscoveryId,
|
||||
AvailabilityBitfield, BackedCandidate, Balance, BlakeTwo256, Block, BlockId, BlockNumber,
|
||||
CandidateCommitments, CandidateDescriptor, CandidateEvent, CandidateHash, CandidateIndex,
|
||||
CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CollatorId,
|
||||
CollatorSignature, CommittedCandidateReceipt, CompactStatement, ConsensusLog, CoreIndex,
|
||||
CoreState, DisputeState, DisputeStatement, DisputeStatementSet, DownwardMessage, EncodeAs,
|
||||
ExecutorParam, ExecutorParams, ExecutorParamsHash, ExplicitDisputeStatement, GroupIndex,
|
||||
GroupRotationInfo, Hash, HashT, HeadData, Header, HorizontalMessages, 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,
|
||||
@@ -61,4 +62,4 @@ pub use v5::{
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use v5::{AssignmentPair, CollatorPair, ValidatorPair};
|
||||
pub use v6::{AssignmentPair, CollatorPair, ValidatorPair};
|
||||
|
||||
@@ -114,10 +114,11 @@
|
||||
//! separated from the stable primitives.
|
||||
|
||||
use crate::{
|
||||
vstaging, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash,
|
||||
CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo,
|
||||
OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes,
|
||||
SessionIndex, SessionInfo, ValidatorId, ValidatorIndex, ValidatorSignature,
|
||||
async_backing, slashing, AsyncBackingParams, BlockNumber, CandidateCommitments, CandidateEvent,
|
||||
CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams,
|
||||
GroupRotationInfo, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement,
|
||||
ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
|
||||
ValidatorSignature,
|
||||
};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_core_primitives as pcp;
|
||||
@@ -224,38 +225,37 @@ sp_api::decl_runtime_apis! {
|
||||
|
||||
/// Returns a list of validators that lost a past session dispute and need to be slashed.
|
||||
/// NOTE: This function is only available since parachain host version 5.
|
||||
fn unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>;
|
||||
fn unapplied_slashes() -> Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>;
|
||||
|
||||
/// Returns a merkle proof of a validator session key.
|
||||
/// NOTE: This function is only available since parachain host version 5.
|
||||
fn key_ownership_proof(
|
||||
validator_id: ValidatorId,
|
||||
) -> Option<vstaging::slashing::OpaqueKeyOwnershipProof>;
|
||||
) -> Option<slashing::OpaqueKeyOwnershipProof>;
|
||||
|
||||
/// Submit an unsigned extrinsic to slash validators who lost a dispute about
|
||||
/// a candidate of a past session.
|
||||
/// NOTE: This function is only available since parachain host version 5.
|
||||
fn submit_report_dispute_lost(
|
||||
dispute_proof: vstaging::slashing::DisputeProof,
|
||||
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
|
||||
dispute_proof: slashing::DisputeProof,
|
||||
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
|
||||
) -> Option<()>;
|
||||
|
||||
/***** Staging *****/
|
||||
/***** Added in v6 *****/
|
||||
|
||||
/// 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 *****/
|
||||
/***** Added in v7: Asynchronous backing *****/
|
||||
|
||||
/// Returns the state of parachain backing for a given para.
|
||||
/// This is a staging method! Do not use on production runtimes!
|
||||
#[api_version(99)]
|
||||
fn staging_para_backing_state(_: ppp::Id) -> Option<vstaging::BackingState<H, N>>;
|
||||
#[api_version(7)]
|
||||
fn para_backing_state(_: ppp::Id) -> Option<async_backing::BackingState<H, N>>;
|
||||
|
||||
/// Returns candidate's acceptance limitations for asynchronous backing for a relay parent.
|
||||
#[api_version(99)]
|
||||
fn staging_async_backing_params() -> vstaging::AsyncBackingParams;
|
||||
#[api_version(7)]
|
||||
fn async_backing_params() -> AsyncBackingParams;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Asynchronous backing primitives.
|
||||
|
||||
use super::*;
|
||||
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::RuntimeDebug;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Candidate's acceptance limitations for asynchronous backing per relay parent.
|
||||
#[derive(
|
||||
RuntimeDebug,
|
||||
Copy,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Encode,
|
||||
Decode,
|
||||
TypeInfo,
|
||||
serde::Serialize,
|
||||
serde::Deserialize,
|
||||
)]
|
||||
|
||||
pub struct AsyncBackingParams {
|
||||
/// The maximum number of para blocks between the para head in a relay parent
|
||||
/// and a new candidate. Restricts nodes from building arbitrary long chains
|
||||
/// and spamming other validators.
|
||||
///
|
||||
/// When async backing is disabled, the only valid value is 0.
|
||||
pub max_candidate_depth: u32,
|
||||
/// How many ancestors of a relay parent are allowed to build candidates on top
|
||||
/// of.
|
||||
///
|
||||
/// When async backing is disabled, the only valid value is 0.
|
||||
pub allowed_ancestry_len: u32,
|
||||
}
|
||||
|
||||
/// Constraints on inbound HRMP channels.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct InboundHrmpLimitations<N = BlockNumber> {
|
||||
/// An exhaustive set of all valid watermarks, sorted ascending.
|
||||
///
|
||||
/// It's only expected to contain block numbers at which messages were
|
||||
/// previously sent to a para, excluding most recent head.
|
||||
pub valid_watermarks: Vec<N>,
|
||||
}
|
||||
|
||||
/// Constraints on outbound HRMP channels.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct OutboundHrmpChannelLimitations {
|
||||
/// The maximum bytes that can be written to the channel.
|
||||
pub bytes_remaining: u32,
|
||||
/// The maximum messages that can be written to the channel.
|
||||
pub messages_remaining: u32,
|
||||
}
|
||||
|
||||
/// Constraints on the actions that can be taken by a new parachain
|
||||
/// block. These limitations are implicitly associated with some particular
|
||||
/// parachain, which should be apparent from usage.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct Constraints<N = BlockNumber> {
|
||||
/// The minimum relay-parent number accepted under these constraints.
|
||||
pub min_relay_parent_number: N,
|
||||
/// The maximum Proof-of-Validity size allowed, in bytes.
|
||||
pub max_pov_size: u32,
|
||||
/// The maximum new validation code size allowed, in bytes.
|
||||
pub max_code_size: u32,
|
||||
/// The amount of UMP messages remaining.
|
||||
pub ump_remaining: u32,
|
||||
/// The amount of UMP bytes remaining.
|
||||
pub ump_remaining_bytes: u32,
|
||||
/// The maximum number of UMP messages allowed per candidate.
|
||||
pub max_ump_num_per_candidate: u32,
|
||||
/// Remaining DMP queue. Only includes sent-at block numbers.
|
||||
pub dmp_remaining_messages: Vec<N>,
|
||||
/// The limitations of all registered inbound HRMP channels.
|
||||
pub hrmp_inbound: InboundHrmpLimitations<N>,
|
||||
/// The limitations of all registered outbound HRMP channels.
|
||||
pub hrmp_channels_out: Vec<(Id, OutboundHrmpChannelLimitations)>,
|
||||
/// The maximum number of HRMP messages allowed per candidate.
|
||||
pub max_hrmp_num_per_candidate: u32,
|
||||
/// The required parent head-data of the parachain.
|
||||
pub required_parent: HeadData,
|
||||
/// The expected validation-code-hash of this parachain.
|
||||
pub validation_code_hash: ValidationCodeHash,
|
||||
/// The code upgrade restriction signal as-of this parachain.
|
||||
pub upgrade_restriction: Option<UpgradeRestriction>,
|
||||
/// The future validation code hash, if any, and at what relay-parent
|
||||
/// number the upgrade would be minimally applied.
|
||||
pub future_validation_code: Option<(N, ValidationCodeHash)>,
|
||||
}
|
||||
|
||||
/// A candidate pending availability.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct CandidatePendingAvailability<H = Hash, N = BlockNumber> {
|
||||
/// The hash of the candidate.
|
||||
pub candidate_hash: CandidateHash,
|
||||
/// The candidate's descriptor.
|
||||
pub descriptor: CandidateDescriptor<H>,
|
||||
/// The commitments of the candidate.
|
||||
pub commitments: CandidateCommitments,
|
||||
/// The candidate's relay parent's number.
|
||||
pub relay_parent_number: N,
|
||||
/// The maximum Proof-of-Validity size allowed, in bytes.
|
||||
pub max_pov_size: u32,
|
||||
}
|
||||
|
||||
/// The per-parachain state of the backing system, including
|
||||
/// state-machine constraints and candidates pending availability.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct BackingState<H = Hash, N = BlockNumber> {
|
||||
/// The state-machine constraints of the parachain.
|
||||
pub constraints: Constraints<N>,
|
||||
/// The candidates pending availability. These should be ordered, i.e. they should form
|
||||
/// a sub-chain, where the first candidate builds on top of the required parent of the
|
||||
/// constraints and each subsequent builds on top of the previous head-data.
|
||||
pub pending_availability: Vec<CandidatePendingAvailability<H, N>>,
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! `V2` Primitives.
|
||||
//! `V6` Primitives.
|
||||
|
||||
use bitvec::vec::BitVec;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
@@ -57,8 +57,13 @@ pub use sp_staking::SessionIndex;
|
||||
mod signed;
|
||||
pub use signed::{EncodeAs, Signed, UncheckedSigned};
|
||||
|
||||
pub mod async_backing;
|
||||
pub mod executor_params;
|
||||
pub mod slashing;
|
||||
|
||||
pub use async_backing::AsyncBackingParams;
|
||||
pub use executor_params::{ExecutorParam, ExecutorParams, ExecutorParamsHash};
|
||||
|
||||
mod metrics;
|
||||
pub use metrics::{
|
||||
metric_definitions, RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues,
|
||||
@@ -1116,7 +1121,7 @@ pub struct AbridgedHostConfiguration {
|
||||
/// The delay, in blocks, before a validation upgrade is applied.
|
||||
pub validation_upgrade_delay: BlockNumber,
|
||||
/// Asynchronous backing parameters.
|
||||
pub async_backing_params: super::vstaging::AsyncBackingParams,
|
||||
pub async_backing_params: AsyncBackingParams,
|
||||
}
|
||||
|
||||
/// Abridged version of `HrmpChannel` (from the `Hrmp` parachains host runtime module) meant to be
|
||||
@@ -1803,9 +1808,6 @@ pub enum PvfExecTimeoutKind {
|
||||
Approval,
|
||||
}
|
||||
|
||||
pub mod executor_params;
|
||||
pub use executor_params::{ExecutorParam, ExecutorParams, ExecutorParamsHash};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -17,121 +17,3 @@
|
||||
//! Staging Primitives.
|
||||
|
||||
// Put any primitives used by staging APIs functions here
|
||||
pub use crate::v5::*;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::RuntimeDebug;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Useful type alias for Para IDs.
|
||||
pub type ParaId = Id;
|
||||
|
||||
/// Candidate's acceptance limitations for asynchronous backing per relay parent.
|
||||
#[derive(
|
||||
RuntimeDebug,
|
||||
Copy,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Encode,
|
||||
Decode,
|
||||
TypeInfo,
|
||||
serde::Serialize,
|
||||
serde::Deserialize,
|
||||
)]
|
||||
|
||||
pub struct AsyncBackingParams {
|
||||
/// The maximum number of para blocks between the para head in a relay parent
|
||||
/// and a new candidate. Restricts nodes from building arbitrary long chains
|
||||
/// and spamming other validators.
|
||||
///
|
||||
/// When async backing is disabled, the only valid value is 0.
|
||||
pub max_candidate_depth: u32,
|
||||
/// How many ancestors of a relay parent are allowed to build candidates on top
|
||||
/// of.
|
||||
///
|
||||
/// When async backing is disabled, the only valid value is 0.
|
||||
pub allowed_ancestry_len: u32,
|
||||
}
|
||||
|
||||
/// Constraints on inbound HRMP channels.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct InboundHrmpLimitations<N = BlockNumber> {
|
||||
/// An exhaustive set of all valid watermarks, sorted ascending.
|
||||
///
|
||||
/// It's only expected to contain block numbers at which messages were
|
||||
/// previously sent to a para, excluding most recent head.
|
||||
pub valid_watermarks: Vec<N>,
|
||||
}
|
||||
|
||||
/// Constraints on outbound HRMP channels.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct OutboundHrmpChannelLimitations {
|
||||
/// The maximum bytes that can be written to the channel.
|
||||
pub bytes_remaining: u32,
|
||||
/// The maximum messages that can be written to the channel.
|
||||
pub messages_remaining: u32,
|
||||
}
|
||||
|
||||
/// Constraints on the actions that can be taken by a new parachain
|
||||
/// block. These limitations are implicitly associated with some particular
|
||||
/// parachain, which should be apparent from usage.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct Constraints<N = BlockNumber> {
|
||||
/// The minimum relay-parent number accepted under these constraints.
|
||||
pub min_relay_parent_number: N,
|
||||
/// The maximum Proof-of-Validity size allowed, in bytes.
|
||||
pub max_pov_size: u32,
|
||||
/// The maximum new validation code size allowed, in bytes.
|
||||
pub max_code_size: u32,
|
||||
/// The amount of UMP messages remaining.
|
||||
pub ump_remaining: u32,
|
||||
/// The amount of UMP bytes remaining.
|
||||
pub ump_remaining_bytes: u32,
|
||||
/// The maximum number of UMP messages allowed per candidate.
|
||||
pub max_ump_num_per_candidate: u32,
|
||||
/// Remaining DMP queue. Only includes sent-at block numbers.
|
||||
pub dmp_remaining_messages: Vec<N>,
|
||||
/// The limitations of all registered inbound HRMP channels.
|
||||
pub hrmp_inbound: InboundHrmpLimitations<N>,
|
||||
/// The limitations of all registered outbound HRMP channels.
|
||||
pub hrmp_channels_out: Vec<(ParaId, OutboundHrmpChannelLimitations)>,
|
||||
/// The maximum number of HRMP messages allowed per candidate.
|
||||
pub max_hrmp_num_per_candidate: u32,
|
||||
/// The required parent head-data of the parachain.
|
||||
pub required_parent: HeadData,
|
||||
/// The expected validation-code-hash of this parachain.
|
||||
pub validation_code_hash: ValidationCodeHash,
|
||||
/// The code upgrade restriction signal as-of this parachain.
|
||||
pub upgrade_restriction: Option<UpgradeRestriction>,
|
||||
/// The future validation code hash, if any, and at what relay-parent
|
||||
/// number the upgrade would be minimally applied.
|
||||
pub future_validation_code: Option<(N, ValidationCodeHash)>,
|
||||
}
|
||||
|
||||
/// A candidate pending availability.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct CandidatePendingAvailability<H = Hash, N = BlockNumber> {
|
||||
/// The hash of the candidate.
|
||||
pub candidate_hash: CandidateHash,
|
||||
/// The candidate's descriptor.
|
||||
pub descriptor: CandidateDescriptor<H>,
|
||||
/// The commitments of the candidate.
|
||||
pub commitments: CandidateCommitments,
|
||||
/// The candidate's relay parent's number.
|
||||
pub relay_parent_number: N,
|
||||
/// The maximum Proof-of-Validity size allowed, in bytes.
|
||||
pub max_pov_size: u32,
|
||||
}
|
||||
|
||||
/// The per-parachain state of the backing system, including
|
||||
/// state-machine constraints and candidates pending availability.
|
||||
#[derive(RuntimeDebug, Clone, PartialEq, Encode, Decode, TypeInfo)]
|
||||
pub struct BackingState<H = Hash, N = BlockNumber> {
|
||||
/// The state-machine constraints of the parachain.
|
||||
pub constraints: Constraints<N>,
|
||||
/// The candidates pending availability. These should be ordered, i.e. they should form
|
||||
/// a sub-chain, where the first candidate builds on top of the required parent of the
|
||||
/// constraints and each subsequent builds on top of the previous head-data.
|
||||
pub pending_availability: Vec<CandidatePendingAvailability<H, N>>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user