Finish migration to v2 primitives (#5037)

* remove v0 primitives from polkadot-primitives

* first pass: remove v0

* fix fallout in erasure-coding

* remove v1 primitives, consolidate to v2

* the great import update

* update runtime_api_impl_v1 to v2 as well

* guide: add `Version` request for runtime API

* add version query to runtime API

* reintroduce OldV1SessionInfo in a limited way
This commit is contained in:
Robert Habermeier
2022-03-09 14:01:13 -06:00
committed by GitHub
parent 3394cbb142
commit 49f7e5cce4
215 changed files with 2312 additions and 3123 deletions
@@ -17,7 +17,7 @@
//! Runtime API implementations for Parachains.
//!
//! These are exposed as different modules using different sets of primitives.
//! At the moment there is only a v1 module and it is not completely clear how migration
//! At the moment there is only a v2 module and it is not completely clear how migration
//! to a v2 would be done.
pub mod v1;
pub mod v2;
@@ -11,25 +11,22 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//! A module exporting runtime API implementation functions for all runtime APIs using v1
//! A module exporting runtime API implementation functions for all runtime APIs using v2
//! primitives.
//!
//! Runtimes implementing the v1 runtime API are recommended to forward directly to these
//! Runtimes implementing the v2 runtime API are recommended to forward directly to these
//! functions.
use crate::{
configuration, dmp, hrmp, inclusion, initializer, paras, paras_inherent, scheduler,
session_info, shared,
};
use primitives::{
v1::{
AuthorityDiscoveryId, CandidateEvent, CommittedCandidateReceipt, CoreIndex, CoreOccupied,
CoreState, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage,
InboundHrmpMessage, OccupiedCore, OccupiedCoreAssumption, PersistedValidationData,
ScheduledCore, ScrapedOnChainVotes, SessionIndex, ValidationCode, ValidationCodeHash,
ValidatorId, ValidatorIndex, ValidatorSignature,
},
v2::{PvfCheckStatement, SessionInfo},
use primitives::v2::{
AuthorityDiscoveryId, CandidateEvent, CommittedCandidateReceipt, CoreIndex, CoreOccupied,
CoreState, GroupIndex, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage,
InboundHrmpMessage, OccupiedCore, OccupiedCoreAssumption, PersistedValidationData,
PvfCheckStatement, ScheduledCore, ScrapedOnChainVotes, SessionIndex, SessionInfo,
ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
};
use sp_runtime::traits::One;
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
@@ -90,7 +87,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
Some(g) => g,
None => {
log::warn!(
target: "runtime::polkadot-api::v1",
target: "runtime::polkadot-api::v2",
"Could not determine the group responsible for core extracted \
from list of cores for some prior block in same session",
);
@@ -259,7 +256,7 @@ pub fn assumed_validation_data<T: initializer::Config>(
/// Implementation for the `check_validation_outputs` function of the runtime API.
pub fn check_validation_outputs<T: initializer::Config>(
para_id: ParaId,
outputs: primitives::v1::CandidateCommitments,
outputs: primitives::v2::CandidateCommitments,
) -> bool {
<inclusion::Pallet<T>>::check_validation_outputs_for_runtime_api(para_id, outputs)
}