|
|
|
@@ -116,11 +116,10 @@
|
|
|
|
|
use crate::{
|
|
|
|
|
async_backing, slashing, vstaging, AsyncBackingParams, BlockNumber, CandidateCommitments,
|
|
|
|
|
CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState,
|
|
|
|
|
ExecutorParams, GroupRotationInfo, OccupiedCoreAssumption, PersistedValidationData,
|
|
|
|
|
ExecutorParams, GroupRotationInfo, Hash, OccupiedCoreAssumption, PersistedValidationData,
|
|
|
|
|
PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidatorId, ValidatorIndex,
|
|
|
|
|
ValidatorSignature,
|
|
|
|
|
};
|
|
|
|
|
use parity_scale_codec::{Decode, Encode};
|
|
|
|
|
use polkadot_core_primitives as pcp;
|
|
|
|
|
use polkadot_parachain_primitives::primitives as ppp;
|
|
|
|
|
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
|
|
|
@@ -128,18 +127,18 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
|
|
|
|
sp_api::decl_runtime_apis! {
|
|
|
|
|
/// The API for querying the state of parachains on-chain.
|
|
|
|
|
#[api_version(5)]
|
|
|
|
|
pub trait ParachainHost<H: Encode + Decode = pcp::v2::Hash, N: Encode + Decode = pcp::v2::BlockNumber> {
|
|
|
|
|
pub trait ParachainHost {
|
|
|
|
|
/// Get the current validators.
|
|
|
|
|
fn validators() -> Vec<ValidatorId>;
|
|
|
|
|
|
|
|
|
|
/// Returns the validator groups and rotation info localized based on the hypothetical child
|
|
|
|
|
/// of a block whose state this is invoked on. Note that `now` in the `GroupRotationInfo`
|
|
|
|
|
/// should be the successor of the number of the block.
|
|
|
|
|
fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<N>);
|
|
|
|
|
fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>);
|
|
|
|
|
|
|
|
|
|
/// Yields information on all availability cores as relevant to the child block.
|
|
|
|
|
/// Cores are either free or occupied. Free cores can have paras assigned to them.
|
|
|
|
|
fn availability_cores() -> Vec<CoreState<H, N>>;
|
|
|
|
|
fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>>;
|
|
|
|
|
|
|
|
|
|
/// Yields the persisted validation data for the given `ParaId` along with an assumption that
|
|
|
|
|
/// should be used if the para currently occupies a core.
|
|
|
|
@@ -147,15 +146,15 @@ sp_api::decl_runtime_apis! {
|
|
|
|
|
/// Returns `None` if either the para is not registered or the assumption is `Freed`
|
|
|
|
|
/// and the para already occupies a core.
|
|
|
|
|
fn persisted_validation_data(para_id: ppp::Id, assumption: OccupiedCoreAssumption)
|
|
|
|
|
-> Option<PersistedValidationData<H, N>>;
|
|
|
|
|
-> Option<PersistedValidationData<Hash, BlockNumber>>;
|
|
|
|
|
|
|
|
|
|
/// Returns the persisted validation data for the given `ParaId` along with the corresponding
|
|
|
|
|
/// validation code hash. Instead of accepting assumption about the para, matches the validation
|
|
|
|
|
/// data hash against an expected one and yields `None` if they're not equal.
|
|
|
|
|
fn assumed_validation_data(
|
|
|
|
|
para_id: ppp::Id,
|
|
|
|
|
expected_persisted_validation_data_hash: pcp::v2::Hash,
|
|
|
|
|
) -> Option<(PersistedValidationData<H, N>, ppp::ValidationCodeHash)>;
|
|
|
|
|
expected_persisted_validation_data_hash: Hash,
|
|
|
|
|
) -> Option<(PersistedValidationData<Hash, BlockNumber>, ppp::ValidationCodeHash)>;
|
|
|
|
|
|
|
|
|
|
/// Checks if the given validation outputs pass the acceptance criteria.
|
|
|
|
|
fn check_validation_outputs(para_id: ppp::Id, outputs: CandidateCommitments) -> bool;
|
|
|
|
@@ -169,30 +168,34 @@ sp_api::decl_runtime_apis! {
|
|
|
|
|
///
|
|
|
|
|
/// Returns `None` if either the para is not registered or the assumption is `Freed`
|
|
|
|
|
/// and the para already occupies a core.
|
|
|
|
|
fn validation_code(para_id: ppp::Id, assumption: OccupiedCoreAssumption)
|
|
|
|
|
-> Option<ppp::ValidationCode>;
|
|
|
|
|
fn validation_code(
|
|
|
|
|
para_id: ppp::Id,
|
|
|
|
|
assumption: OccupiedCoreAssumption,
|
|
|
|
|
) -> Option<ppp::ValidationCode>;
|
|
|
|
|
|
|
|
|
|
/// Get the receipt of a candidate pending availability. This returns `Some` for any paras
|
|
|
|
|
/// assigned to occupied cores in `availability_cores` and `None` otherwise.
|
|
|
|
|
fn candidate_pending_availability(para_id: ppp::Id) -> Option<CommittedCandidateReceipt<H>>;
|
|
|
|
|
fn candidate_pending_availability(para_id: ppp::Id) -> Option<CommittedCandidateReceipt<Hash>>;
|
|
|
|
|
|
|
|
|
|
/// Get a vector of events concerning candidates that occurred within a block.
|
|
|
|
|
fn candidate_events() -> Vec<CandidateEvent<H>>;
|
|
|
|
|
fn candidate_events() -> Vec<CandidateEvent<Hash>>;
|
|
|
|
|
|
|
|
|
|
/// Get all the pending inbound messages in the downward message queue for a para.
|
|
|
|
|
fn dmq_contents(
|
|
|
|
|
recipient: ppp::Id,
|
|
|
|
|
) -> Vec<pcp::v2::InboundDownwardMessage<N>>;
|
|
|
|
|
) -> Vec<pcp::v2::InboundDownwardMessage<BlockNumber>>;
|
|
|
|
|
|
|
|
|
|
/// Get the contents of all channels addressed to the given recipient. Channels that have no
|
|
|
|
|
/// messages in them are also included.
|
|
|
|
|
fn inbound_hrmp_channels_contents(recipient: ppp::Id) -> BTreeMap<ppp::Id, Vec<pcp::v2::InboundHrmpMessage<N>>>;
|
|
|
|
|
fn inbound_hrmp_channels_contents(
|
|
|
|
|
recipient: ppp::Id,
|
|
|
|
|
) -> BTreeMap<ppp::Id, Vec<pcp::v2::InboundHrmpMessage<BlockNumber>>>;
|
|
|
|
|
|
|
|
|
|
/// Get the validation code from its hash.
|
|
|
|
|
fn validation_code_by_hash(hash: ppp::ValidationCodeHash) -> Option<ppp::ValidationCode>;
|
|
|
|
|
|
|
|
|
|
/// Scrape dispute relevant from on-chain, backing votes and resolved disputes.
|
|
|
|
|
fn on_chain_votes() -> Option<ScrapedOnChainVotes<H>>;
|
|
|
|
|
fn on_chain_votes() -> Option<ScrapedOnChainVotes<Hash>>;
|
|
|
|
|
|
|
|
|
|
/***** Added in v2 *****/
|
|
|
|
|
|
|
|
|
@@ -253,7 +256,7 @@ sp_api::decl_runtime_apis! {
|
|
|
|
|
|
|
|
|
|
/// Returns the state of parachain backing for a given para.
|
|
|
|
|
#[api_version(7)]
|
|
|
|
|
fn para_backing_state(_: ppp::Id) -> Option<async_backing::BackingState<H, N>>;
|
|
|
|
|
fn para_backing_state(_: ppp::Id) -> Option<async_backing::BackingState<Hash, BlockNumber>>;
|
|
|
|
|
|
|
|
|
|
/// Returns candidate's acceptance limitations for asynchronous backing for a relay parent.
|
|
|
|
|
#[api_version(7)]
|
|
|
|
|