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
@@ -18,7 +18,7 @@ use super::*;
use crate::{configuration::HostConfiguration, shared};
use frame_benchmarking::benchmarks;
use frame_system::RawOrigin;
use primitives::v1::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE};
use primitives::v2::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE};
use sp_runtime::traits::{One, Saturating};
// 2 ^ 10, because binary search time complexity is O(log(2, n)) and n = 1024 gives us a big and
+4 -7
View File
@@ -111,12 +111,9 @@ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use frame_support::{pallet_prelude::*, traits::EstimateNextSessionRotation};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode};
use primitives::{
v1::{
ConsensusLog, HeadData, Id as ParaId, SessionIndex, UpgradeGoAhead, UpgradeRestriction,
ValidationCode, ValidationCodeHash, ValidatorSignature,
},
v2::PvfCheckStatement,
use primitives::v2::{
ConsensusLog, HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, UpgradeGoAhead,
UpgradeRestriction, ValidationCode, ValidationCodeHash, ValidatorSignature,
};
use scale_info::TypeInfo;
use sp_core::RuntimeDebug;
@@ -387,7 +384,7 @@ impl<BlockNumber> PvfCheckActiveVoteState<BlockNumber> {
/// Returns `None` if the quorum is not reached, or the direction of the decision.
fn quorum(&self, n_validators: usize) -> Option<PvfCheckOutcome> {
let q_threshold = primitives::v1::supermajority_threshold(n_validators);
let q_threshold = primitives::v2::supermajority_threshold(n_validators);
// NOTE: counting the reject votes is deliberately placed first. This is to err on the safe.
if self.votes_reject.count_ones() >= q_threshold {
Some(PvfCheckOutcome::Rejected)
@@ -17,10 +17,7 @@
use super::*;
use frame_support::{assert_err, assert_ok, assert_storage_noop};
use keyring::Sr25519Keyring;
use primitives::{
v0::PARACHAIN_KEY_TYPE_ID,
v1::{BlockNumber, ValidatorId},
};
use primitives::v2::{BlockNumber, ValidatorId, PARACHAIN_KEY_TYPE_ID};
use sc_keystore::LocalKeystore;
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
use std::sync::Arc;
@@ -116,7 +113,7 @@ fn check_code_is_not_stored(validation_code: &ValidationCode) {
/// An utility for checking that certain events were deposited.
struct EventValidator {
events:
Vec<frame_system::EventRecord<<Test as frame_system::Config>::Event, primitives::v1::Hash>>,
Vec<frame_system::EventRecord<<Test as frame_system::Config>::Event, primitives::v2::Hash>>,
}
impl EventValidator {
@@ -1545,7 +1542,7 @@ fn add_trusted_validation_code_enacts_existing_pvf_vote() {
#[test]
fn verify_upgrade_go_ahead_signal_is_externally_accessible() {
use primitives::v1::well_known_keys;
use primitives::v2::well_known_keys;
let a = ParaId::from(2020);
@@ -1561,7 +1558,7 @@ fn verify_upgrade_go_ahead_signal_is_externally_accessible() {
#[test]
fn verify_upgrade_restriction_signal_is_externally_accessible() {
use primitives::v1::well_known_keys;
use primitives::v2::well_known_keys;
let a = ParaId::from(2020);