diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 4c5d21e62964..c8526fcf7cb7 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -731,7 +731,7 @@ impl_runtime_apis! { } } - impl polkadot_primitives::v2::ParachainHost for Runtime { + impl polkadot_primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { polkadot_runtime_parachains::runtime_api_impl::v2::validators::() } diff --git a/node/client/src/lib.rs b/node/client/src/lib.rs index 8446950fe4df..4be3acbd6a13 100644 --- a/node/client/src/lib.rs +++ b/node/client/src/lib.rs @@ -19,8 +19,9 @@ //! Provides the [`AbstractClient`] trait that is a super trait that combines all the traits the client implements. //! There is also the [`Client`] enum that combines all the different clients into one common structure. -use polkadot_primitives::v2::{ - AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce, ParachainHost, +use polkadot_primitives::{ + runtime_api::ParachainHost, + v2::{AccountId, Balance, Block, BlockNumber, Hash, Header, Nonce}, }; use sc_client_api::{AuxStore, Backend as BackendT, BlockchainEvents, KeyIterator, UsageProvider}; use sc_executor::NativeElseWasmExecutor; diff --git a/node/core/runtime-api/src/lib.rs b/node/core/runtime-api/src/lib.rs index bd2da3772c84..3665cb57ccbe 100644 --- a/node/core/runtime-api/src/lib.rs +++ b/node/core/runtime-api/src/lib.rs @@ -23,7 +23,10 @@ #![warn(missing_docs)] use polkadot_node_subsystem_util::metrics::{self, prometheus}; -use polkadot_primitives::v2::{Block, BlockId, Hash, ParachainHost}; +use polkadot_primitives::{ + runtime_api::ParachainHost, + v2::{Block, BlockId, Hash}, +}; use polkadot_subsystem::{ errors::RuntimeApiError, messages::{RuntimeApiMessage, RuntimeApiRequest as Request}, diff --git a/node/core/runtime-api/src/tests.rs b/node/core/runtime-api/src/tests.rs index 40027fe91a00..0d732ba20c35 100644 --- a/node/core/runtime-api/src/tests.rs +++ b/node/core/runtime-api/src/tests.rs @@ -21,10 +21,11 @@ use futures::channel::oneshot; use polkadot_node_primitives::{BabeAllowedSlots, BabeEpoch, BabeEpochConfiguration}; use polkadot_node_subsystem_test_helpers::make_subsystem_context; use polkadot_primitives::v2::{ - AuthorityDiscoveryId, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo, - Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, - PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, + AuthorityDiscoveryId, BlockNumber, CandidateEvent, CandidateHash, CommittedCandidateReceipt, + CoreState, DisputeState, GroupRotationInfo, Id as ParaId, InboundDownwardMessage, + InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, + ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, + ValidatorId, ValidatorIndex, ValidatorSignature, }; use sp_core::testing::TaskExecutor; use std::{ @@ -189,6 +190,10 @@ sp_api::mock_impl_runtime_apis! { ) -> Option { self.validation_code_hash.get(¶).map(|c| c.clone()) } + + fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + unimplemented!() + } } impl BabeApi for MockRuntimeApi { diff --git a/node/overseer/src/lib.rs b/node/overseer/src/lib.rs index 89067dbcef22..b5fd1fba9b78 100644 --- a/node/overseer/src/lib.rs +++ b/node/overseer/src/lib.rs @@ -71,7 +71,10 @@ use futures::{channel::oneshot, future::BoxFuture, select, Future, FutureExt, St use lru::LruCache; use client::{BlockImportNotification, BlockchainEvents, FinalityNotification}; -use polkadot_primitives::v2::{Block, BlockId, BlockNumber, Hash, ParachainHost}; +use polkadot_primitives::{ + runtime_api::ParachainHost, + v2::{Block, BlockId, BlockNumber, Hash}, +}; use sp_api::{ApiExt, ProvideRuntimeApi}; use polkadot_node_network_protocol::v1 as protocol_v1; diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index fb27d8509f7e..c0986869a8fc 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -54,7 +54,7 @@ pub use sp_core::traits::SpawnNamed; #[cfg(feature = "full-node")] pub use { polkadot_overseer::{Handle, Overseer, OverseerConnector, OverseerHandle}, - polkadot_primitives::v2::ParachainHost, + polkadot_primitives::runtime_api::ParachainHost, relay_chain_selection::SelectRelayChain, sc_client_api::AuxStore, sp_authority_discovery::AuthorityDiscoveryApi, diff --git a/node/service/src/overseer.rs b/node/service/src/overseer.rs index 4b80e40a5a95..fbdd57586b72 100644 --- a/node/service/src/overseer.rs +++ b/node/service/src/overseer.rs @@ -34,7 +34,7 @@ use polkadot_overseer::{ Overseer, OverseerConnector, OverseerHandle, }; -use polkadot_primitives::v2::ParachainHost; +use polkadot_primitives::runtime_api::ParachainHost; use sc_authority_discovery::Service as AuthorityDiscoveryService; use sc_client_api::AuxStore; use sc_keystore::LocalKeystore; diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index c1cb635b8c8e..121f7cb40d23 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -19,4 +19,14 @@ #![warn(missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +// `v2` is currently the latest stable version of the runtime API. pub mod v2; + +// The 'staging' version is special - while other versions are set in stone, +// the staging version is malleable. Once it's released, it gets the next +// version number. +pub mod vstaging; + +// `runtime_api` contains the actual API implementation. It contains stable and +// unstable functions. +pub mod runtime_api; diff --git a/primitives/src/runtime_api.rs b/primitives/src/runtime_api.rs new file mode 100644 index 000000000000..84d2cf0ec4ca --- /dev/null +++ b/primitives/src/runtime_api.rs @@ -0,0 +1,159 @@ +// Copyright 2017-2022 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 . + +//! Runtime API module declares the `trait ParachainHost` which is part +//! of the Runtime API exposed from the Runtime to the Host. +//! +//! The functions in trait ParachainHost` can be part of the stable API +//! (which is versioned) or they can be staging (aka unstable functions). +//! +//! All stable API functions should use primitives from the latest version. +//! In the time of writing of this document - this is v2. So for example: +//! ```ignore +//! fn validators() -> Vec; +//! ``` +//! indicates a function from the stable v2 API. +//! +//! On the other hand a staging function's name should be prefixed with +//! `staging_` like this: +//! ```ignore +//! fn staging_get_disputes() -> Vec<(vstaging::SessionIndex, vstaging::CandidateHash, vstaging::DisputeState)>; +//! ``` +//! +//! How a staging function becomes stable? +//! +//! Once a staging function is ready to be versioned the `renamed` macro +//! should be used to rename it and version it. For the example above: +//! ```ignore +//! #[renamed("staging_get_session_disputes", 3)] +//! fn get_session_disputes() -> Vec<(v3::SessionIndex, v3::CandidateHash, v3::DisputeState)>; +//! ``` +//! For more details about how the API versioning works refer to `spi_api` +//! documentation [here](https://docs.substrate.io/rustdocs/latest/sp_api/macro.decl_runtime_apis.html). + +use crate::v2; +use parity_scale_codec::{Decode, Encode}; +use polkadot_core_primitives as pcp; +use polkadot_parachain::primitives as ppp; +use sp_staking; +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(2)] + pub trait ParachainHost { + /// Get the current validators. + fn validators() -> Vec; + + /// 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>, v2::GroupRotationInfo); + + /// 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>; + + /// Yields the persisted validation data for the given `ParaId` along with an assumption that + /// should be used if the para currently occupies a core. + /// + /// 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: v2::OccupiedCoreAssumption) + -> Option>; + + /// 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<(v2::PersistedValidationData, ppp::ValidationCodeHash)>; + + /// Checks if the given validation outputs pass the acceptance criteria. + fn check_validation_outputs(para_id: ppp::Id, outputs: v2::CandidateCommitments) -> bool; + + /// Returns the session index expected at a child of the block. + /// + /// This can be used to instantiate a `SigningContext`. + fn session_index_for_child() -> sp_staking::SessionIndex; + + /// Fetch the validation code used by a para, making the given `OccupiedCoreAssumption`. + /// + /// 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: v2::OccupiedCoreAssumption) + -> Option; + + /// 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>; + + /// Get a vector of events concerning candidates that occurred within a block. + fn candidate_events() -> Vec>; + + /// Get all the pending inbound messages in the downward message queue for a para. + fn dmq_contents( + recipient: ppp::Id, + ) -> Vec>; + + /// 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>>; + + /// Get the validation code from its hash. + fn validation_code_by_hash(hash: ppp::ValidationCodeHash) -> Option; + + /// Scrape dispute relevant from on-chain, backing votes and resolved disputes. + fn on_chain_votes() -> Option>; + + /***** Added in v2 *****/ + + /// Get the session info for the given session, if stored. + /// + /// NOTE: This function is only available since parachain host version 2. + fn session_info(index: sp_staking::SessionIndex) -> Option; + + /// Submits a PVF pre-checking statement into the transaction pool. + /// + /// NOTE: This function is only available since parachain host version 2. + fn submit_pvf_check_statement(stmt: v2::PvfCheckStatement, signature: v2::ValidatorSignature); + + /// Returns code hashes of PVFs that require pre-checking by validators in the active set. + /// + /// NOTE: This function is only available since parachain host version 2. + fn pvfs_require_precheck() -> Vec; + + /// Fetch the hash of the validation code used by a para, making the given `OccupiedCoreAssumption`. + /// + /// NOTE: This function is only available since parachain host version 2. + fn validation_code_hash(para_id: ppp::Id, assumption: v2::OccupiedCoreAssumption) + -> Option; + + + /***** Replaced in v2 *****/ + + /// Old method to fetch v1 session info. + #[changed_in(2)] + fn session_info(index: sp_staking::SessionIndex) -> Option; + + /***** STAGING *****/ + + /// Returns all onchain disputes. + /// This is a staging method! Do not use on production runtimes! + fn staging_get_disputes() -> Vec<(v2::SessionIndex, v2::CandidateHash, v2::DisputeState)>; + } +} diff --git a/primitives/src/v2/mod.rs b/primitives/src/v2/mod.rs index 64f8624b28ea..57e19c68693e 100644 --- a/primitives/src/v2/mod.rs +++ b/primitives/src/v2/mod.rs @@ -19,7 +19,7 @@ use bitvec::vec::BitVec; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -use sp_std::{collections::btree_map::BTreeMap, prelude::*}; +use sp_std::prelude::*; use application_crypto::KeyTypeId; use inherents::InherentIdentifier; @@ -1651,107 +1651,6 @@ impl PvfCheckStatement { } } -sp_api::decl_runtime_apis! { - /// The API for querying the state of parachains on-chain. - #[api_version(2)] - pub trait ParachainHost { - /// Get the current validators. - fn validators() -> Vec; - - /// 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>, GroupRotationInfo); - - /// 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>; - - /// Yields the persisted validation data for the given `ParaId` along with an assumption that - /// should be used if the para currently occupies a core. - /// - /// 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: Id, assumption: OccupiedCoreAssumption) - -> Option>; - - /// 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: Id, - expected_persisted_validation_data_hash: Hash, - ) -> Option<(PersistedValidationData, ValidationCodeHash)>; - - /// Checks if the given validation outputs pass the acceptance criteria. - fn check_validation_outputs(para_id: Id, outputs: CandidateCommitments) -> bool; - - /// Returns the session index expected at a child of the block. - /// - /// This can be used to instantiate a `SigningContext`. - fn session_index_for_child() -> SessionIndex; - - /// Fetch the validation code used by a para, making the given `OccupiedCoreAssumption`. - /// - /// 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: Id, assumption: OccupiedCoreAssumption) - -> Option; - - /// 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: Id) -> Option>; - - /// Get a vector of events concerning candidates that occurred within a block. - fn candidate_events() -> Vec>; - - /// Get all the pending inbound messages in the downward message queue for a para. - fn dmq_contents( - recipient: Id, - ) -> Vec>; - - /// 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: Id) -> BTreeMap>>; - - /// Get the validation code from its hash. - fn validation_code_by_hash(hash: ValidationCodeHash) -> Option; - - /// Scrape dispute relevant from on-chain, backing votes and resolved disputes. - fn on_chain_votes() -> Option>; - - /***** Added in v2 *****/ - - /// Get the session info for the given session, if stored. - /// - /// NOTE: This function is only available since parachain host version 2. - fn session_info(index: SessionIndex) -> Option; - - /// Submits a PVF pre-checking statement into the transaction pool. - /// - /// NOTE: This function is only available since parachain host version 2. - fn submit_pvf_check_statement(stmt: PvfCheckStatement, signature: ValidatorSignature); - - /// Returns code hashes of PVFs that require pre-checking by validators in the active set. - /// - /// NOTE: This function is only available since parachain host version 2. - fn pvfs_require_precheck() -> Vec; - - /// Fetch the hash of the validation code used by a para, making the given `OccupiedCoreAssumption`. - /// - /// NOTE: This function is only available since parachain host version 2. - fn validation_code_hash(para_id: Id, assumption: OccupiedCoreAssumption) - -> Option; - - - /***** Replaced in v2 *****/ - - /// Old method to fetch v1 session info. - #[changed_in(2)] - fn session_info(index: SessionIndex) -> Option; - } -} - /// Old, v1-style info about session info. Only needed for limited /// backwards-compatibility. #[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)] diff --git a/primitives/src/vstaging/mod.rs b/primitives/src/vstaging/mod.rs new file mode 100644 index 000000000000..2f29ffbe60b7 --- /dev/null +++ b/primitives/src/vstaging/mod.rs @@ -0,0 +1,19 @@ +// Copyright 2017-2021 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 . + +//! Staging Primitives. + +// Put any primitives used by staging API functions here diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 7cd9005a48cb..b99992adfb30 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -23,10 +23,11 @@ use pallet_transaction_payment::CurrencyAdapter; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, - SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, }; use runtime_common::{ auctions, claims, crowdloan, elections::OnChainSeqPhragmen, impl_runtime_weights, @@ -1661,7 +1662,7 @@ sp_api::impl_runtime_apis! { } } - impl primitives::v2::ParachainHost for Runtime { + impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() } @@ -1758,6 +1759,10 @@ sp_api::impl_runtime_apis! { { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } + + fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + unimplemented!() + } } impl beefy_primitives::BeefyApi for Runtime { diff --git a/runtime/parachains/Cargo.toml b/runtime/parachains/Cargo.toml index 45d938539410..b0827ba6500a 100644 --- a/runtime/parachains/Cargo.toml +++ b/runtime/parachains/Cargo.toml @@ -109,3 +109,4 @@ try-runtime = [ "pallet-vesting/try-runtime", ] runtime-metrics = ["sp-tracing/with-tracing", "polkadot-runtime-metrics/runtime-metrics"] +vstaging = [] \ No newline at end of file diff --git a/runtime/parachains/src/runtime_api_impl/mod.rs b/runtime/parachains/src/runtime_api_impl/mod.rs index edcf4d8ef937..603b6c4cb385 100644 --- a/runtime/parachains/src/runtime_api_impl/mod.rs +++ b/runtime/parachains/src/runtime_api_impl/mod.rs @@ -21,3 +21,5 @@ //! to a v2 would be done. pub mod v2; +#[cfg(feature = "vstaging")] +pub mod vstaging; diff --git a/runtime/parachains/src/runtime_api_impl/vstaging.rs b/runtime/parachains/src/runtime_api_impl/vstaging.rs new file mode 100644 index 000000000000..8715cdc53121 --- /dev/null +++ b/runtime/parachains/src/runtime_api_impl/vstaging.rs @@ -0,0 +1,27 @@ +// Copyright 2017-2022 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 . + +// Put implementations of functions from staging API here. + +use crate::disputes; +use primitives::v2::{CandidateHash, DisputeState, SessionIndex}; +use sp_std::prelude::*; + +/// Implementation for `get_session_disputes` function from the runtime API +pub fn get_session_disputes( +) -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + >::disputes() +} diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index f798c7e013af..ea72ba6db1bd 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -58,10 +58,11 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, - SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, }; use sp_core::OpaqueMetadata; use sp_runtime::{ @@ -1809,7 +1810,7 @@ sp_api::impl_runtime_apis! { } } - impl primitives::v2::ParachainHost for Runtime { + impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() } @@ -1906,6 +1907,10 @@ sp_api::impl_runtime_apis! { { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } + + fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + unimplemented!() + } } impl beefy_primitives::BeefyApi for Runtime { diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index d7e2486c66a0..85858edcb69b 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -38,11 +38,11 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, - ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, - ValidatorIndex, ValidatorSignature, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, Signature, + ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; use runtime_common::{ assigned_slots, auctions, crowdloan, impl_runtime_weights, impls::ToAuthor, paras_registrar, @@ -1158,7 +1158,7 @@ sp_api::impl_runtime_apis! { } } - impl primitives::v2::ParachainHost for Runtime { + impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { runtime_api_impl::validators::() } @@ -1252,6 +1252,10 @@ sp_api::impl_runtime_apis! { { runtime_api_impl::validation_code_hash::(para_id, assumption) } + + fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + unimplemented!() + } } impl fg_primitives::GrandpaApi for Runtime { diff --git a/runtime/test-runtime/Cargo.toml b/runtime/test-runtime/Cargo.toml index 50336ae79c32..9906cbe11a79 100644 --- a/runtime/test-runtime/Cargo.toml +++ b/runtime/test-runtime/Cargo.toml @@ -59,7 +59,7 @@ runtime-common = { package = "polkadot-runtime-common", path = "../common", defa primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } polkadot-parachain = { path = "../../parachain", default-features = false } -polkadot-runtime-parachains = { path = "../parachains", default-features = false } +polkadot-runtime-parachains = { path = "../parachains", default-features = false, features = ["vstaging"]} xcm-builder = { path = "../../xcm/xcm-builder", default-features = false } xcm-executor = { path = "../../xcm/xcm-executor", default-features = false } xcm = { path = "../../xcm", default-features = false } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index f1d047765eaa..045844c9d4ae 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -45,11 +45,12 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash as HashT, Id as ParaId, InboundDownwardMessage, - InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, - ScrapedOnChainVotes, SessionInfo as SessionInfoData, Signature, ValidationCode, - ValidationCodeHash, ValidatorId, ValidatorIndex, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash as HashT, + Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, + OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, + SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId, + ValidatorIndex, }; use runtime_common::{ claims, impl_runtime_weights, paras_sudo_wrapper, BlockHashCount, BlockLength, @@ -799,7 +800,7 @@ sp_api::impl_runtime_apis! { } } - impl primitives::v2::ParachainHost for Runtime { + impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { runtime_impl::validators::() } @@ -893,6 +894,10 @@ sp_api::impl_runtime_apis! { { runtime_impl::validation_code_hash::(para_id, assumption) } + + fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + polkadot_runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::() + } } impl beefy_primitives::BeefyApi for Runtime { diff --git a/runtime/westend/Cargo.toml b/runtime/westend/Cargo.toml index 62da4403e140..60308c08c5b8 100644 --- a/runtime/westend/Cargo.toml +++ b/runtime/westend/Cargo.toml @@ -84,7 +84,7 @@ hex-literal = { version = "0.3.4", optional = true } runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } polkadot-parachain = { path = "../../parachain", default-features = false } -runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } +runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false, features = ["vstaging"] } xcm = { package = "xcm", path = "../../xcm", default-features = false } xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 5f5580b55762..970145623de0 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -37,11 +37,11 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, - CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, - Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, - ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, - ValidatorIndex, ValidatorSignature, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, Signature, + ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; use runtime_common::{ assigned_slots, auctions, crowdloan, elections::OnChainSeqPhragmen, impl_runtime_weights, @@ -1216,7 +1216,7 @@ sp_api::impl_runtime_apis! { } } - impl primitives::v2::ParachainHost for Runtime { + impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() } @@ -1313,6 +1313,10 @@ sp_api::impl_runtime_apis! { { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } + + fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::() + } } impl beefy_primitives::BeefyApi for Runtime {