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:
Chris Sosnin
2023-09-27 13:32:02 +03:00
committed by GitHub
parent 5a2833cceb
commit 7cbe0c76ef
107 changed files with 2410 additions and 2792 deletions
+10 -14
View File
@@ -39,12 +39,12 @@ use polkadot_node_primitives::{
ValidationResult,
};
use polkadot_primitives::{
slashing, vstaging as vstaging_primitives, AuthorityDiscoveryId, BackedCandidate, BlockNumber,
CandidateEvent, CandidateHash, CandidateIndex, CandidateReceipt, CollatorId,
CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupIndex,
GroupRotationInfo, Hash, Header as BlockHeader, Id as ParaId, InboundDownwardMessage,
InboundHrmpMessage, MultiDisputeStatementSet, OccupiedCoreAssumption, PersistedValidationData,
PvfCheckStatement, PvfExecTimeoutKind, SessionIndex, SessionInfo, SignedAvailabilityBitfield,
async_backing, slashing, AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent,
CandidateHash, CandidateIndex, CandidateReceipt, CollatorId, CommittedCandidateReceipt,
CoreState, DisputeState, ExecutorParams, GroupIndex, GroupRotationInfo, Hash,
Header as BlockHeader, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
MultiDisputeStatementSet, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement,
PvfExecTimeoutKind, SessionIndex, SessionInfo, SignedAvailabilityBitfield,
SignedAvailabilityBitfields, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
ValidatorSignature,
};
@@ -695,14 +695,12 @@ pub enum RuntimeApiRequest {
),
/// Get the minimum required backing votes.
MinimumBackingVotes(SessionIndex, RuntimeApiSender<u32>),
/// Get the backing state of the given para.
/// This is a staging API that will not be available on production runtimes.
StagingParaBackingState(ParaId, RuntimeApiSender<Option<vstaging_primitives::BackingState>>),
ParaBackingState(ParaId, RuntimeApiSender<Option<async_backing::BackingState>>),
/// Get candidate's acceptance limitations for asynchronous backing for a relay parent.
///
/// If it's not supported by the Runtime, the async backing is said to be disabled.
StagingAsyncBackingParams(RuntimeApiSender<vstaging_primitives::AsyncBackingParams>),
AsyncBackingParams(RuntimeApiSender<async_backing::AsyncBackingParams>),
}
impl RuntimeApiRequest {
@@ -726,10 +724,8 @@ impl RuntimeApiRequest {
/// `MinimumBackingVotes`
pub const MINIMUM_BACKING_VOTES_RUNTIME_REQUIREMENT: u32 = 6;
/// Minimum version for backing state, required for async backing.
///
/// 99 for now, should be adjusted to VSTAGING/actual runtime version once released.
pub const STAGING_BACKING_STATE: u32 = 99;
/// Minimum version to enable asynchronous backing: `AsyncBackingParams` and `ParaBackingState`.
pub const STAGING_BACKING_STATE: u32 = 7;
}
/// A message to the Runtime API subsystem.
@@ -16,9 +16,9 @@
use async_trait::async_trait;
use polkadot_primitives::{
runtime_api::ParachainHost, vstaging, Block, BlockNumber, CandidateCommitments, CandidateEvent,
CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams,
GroupRotationInfo, Hash, Id, InboundDownwardMessage, InboundHrmpMessage,
async_backing, runtime_api::ParachainHost, slashing, Block, BlockNumber, CandidateCommitments,
CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState,
ExecutorParams, GroupRotationInfo, Hash, Id, InboundDownwardMessage, InboundHrmpMessage,
OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes,
SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
ValidatorSignature,
@@ -190,7 +190,7 @@ pub trait RuntimeApiSubsystemClient {
async fn unapplied_slashes(
&self,
at: Hash,
) -> Result<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>, ApiError>;
) -> Result<Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>, ApiError>;
/// Returns a merkle proof of a validator session key in a past session.
///
@@ -199,7 +199,7 @@ pub trait RuntimeApiSubsystemClient {
&self,
at: Hash,
validator_id: ValidatorId,
) -> Result<Option<vstaging::slashing::OpaqueKeyOwnershipProof>, ApiError>;
) -> Result<Option<slashing::OpaqueKeyOwnershipProof>, ApiError>;
/// Submits an unsigned extrinsic to slash validators who lost a dispute about
/// a candidate of a past session.
@@ -208,8 +208,8 @@ pub trait RuntimeApiSubsystemClient {
async fn submit_report_dispute_lost(
&self,
at: Hash,
dispute_proof: vstaging::slashing::DisputeProof,
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
dispute_proof: slashing::DisputeProof,
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
) -> Result<Option<()>, ApiError>;
// === BABE API ===
@@ -232,7 +232,7 @@ pub trait RuntimeApiSubsystemClient {
session_index: SessionIndex,
) -> Result<Option<ExecutorParams>, ApiError>;
// === STAGING v6 ===
// === v6 ===
/// Get the minimum number of backing votes.
async fn minimum_backing_votes(
&self,
@@ -240,21 +240,21 @@ pub trait RuntimeApiSubsystemClient {
session_index: SessionIndex,
) -> Result<u32, ApiError>;
// === Asynchronous backing API ===
// === v7: Asynchronous backing API ===
/// Returns candidate's acceptance limitations for asynchronous backing for a relay parent.
async fn staging_async_backing_params(
async fn async_backing_params(
&self,
at: Hash,
) -> Result<polkadot_primitives::vstaging::AsyncBackingParams, ApiError>;
) -> Result<polkadot_primitives::AsyncBackingParams, ApiError>;
/// Returns the state of parachain backing for a given para.
/// This is a staging method! Do not use on production runtimes!
async fn staging_para_backing_state(
async fn para_backing_state(
&self,
at: Hash,
para_id: Id,
) -> Result<Option<polkadot_primitives::vstaging::BackingState>, ApiError>;
) -> Result<Option<async_backing::BackingState>, ApiError>;
}
/// Default implementation of [`RuntimeApiSubsystemClient`] using the client.
@@ -454,7 +454,7 @@ where
async fn unapplied_slashes(
&self,
at: Hash,
) -> Result<Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>, ApiError> {
) -> Result<Vec<(SessionIndex, CandidateHash, slashing::PendingSlashes)>, ApiError> {
self.client.runtime_api().unapplied_slashes(at)
}
@@ -462,15 +462,15 @@ where
&self,
at: Hash,
validator_id: ValidatorId,
) -> Result<Option<vstaging::slashing::OpaqueKeyOwnershipProof>, ApiError> {
) -> Result<Option<slashing::OpaqueKeyOwnershipProof>, ApiError> {
self.client.runtime_api().key_ownership_proof(at, validator_id)
}
async fn submit_report_dispute_lost(
&self,
at: Hash,
dispute_proof: vstaging::slashing::DisputeProof,
key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof,
dispute_proof: slashing::DisputeProof,
key_ownership_proof: slashing::OpaqueKeyOwnershipProof,
) -> Result<Option<()>, ApiError> {
let mut runtime_api = self.client.runtime_api();
@@ -489,19 +489,19 @@ where
self.client.runtime_api().minimum_backing_votes(at)
}
async fn staging_para_backing_state(
async fn para_backing_state(
&self,
at: Hash,
para_id: Id,
) -> Result<Option<polkadot_primitives::vstaging::BackingState>, ApiError> {
self.client.runtime_api().staging_para_backing_state(at, para_id)
) -> Result<Option<async_backing::BackingState>, ApiError> {
self.client.runtime_api().para_backing_state(at, para_id)
}
/// Returns candidate's acceptance limitations for asynchronous backing for a relay parent.
async fn staging_async_backing_params(
async fn async_backing_params(
&self,
at: Hash,
) -> Result<polkadot_primitives::vstaging::AsyncBackingParams, ApiError> {
self.client.runtime_api().staging_async_backing_params(at)
) -> Result<async_backing::AsyncBackingParams, ApiError> {
self.client.runtime_api().async_backing_params(at)
}
}