mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 18:41:03 +00:00
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:
committed by
GitHub
parent
3394cbb142
commit
49f7e5cce4
@@ -21,7 +21,7 @@ use crate::{
|
||||
};
|
||||
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
|
||||
use frame_support::pallet_prelude::*;
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
collator_signature_payload, AvailabilityBitfield, BackedCandidate, CandidateCommitments,
|
||||
CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt,
|
||||
CompactStatement, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, GroupIndex,
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::shared;
|
||||
use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_PER_MILLIS};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE};
|
||||
use primitives::v2::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE};
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
@@ -1127,7 +1127,7 @@ pub mod pallet {
|
||||
fn integrity_test() {
|
||||
assert_eq!(
|
||||
&ActiveConfig::<T>::hashed_key(),
|
||||
primitives::v1::well_known_keys::ACTIVE_CONFIG,
|
||||
primitives::v2::well_known_keys::ACTIVE_CONFIG,
|
||||
"`well_known_keys::ACTIVE_CONFIG` doesn't match key of `ActiveConfig`! Make sure that the name of the\
|
||||
configuration pallet is `Configuration` in the runtime!",
|
||||
);
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
|
||||
|
||||
pub mod v1 {
|
||||
use super::*;
|
||||
use primitives::v1::{Balance, SessionIndex};
|
||||
use primitives::v2::{Balance, SessionIndex};
|
||||
|
||||
// Copied over from configuration.rs @ 656dd280f266dc56bd0cf1dbe3ca232960912f34 and removed
|
||||
// all the comments.
|
||||
@@ -246,7 +246,7 @@ mod tests {
|
||||
// doesn't need to be read and also leaving it as one line allows to easily copy it.
|
||||
let raw_config = hex_literal::hex!["0000a000005000000a00000000c8000000c800000a0000000a00000040380000580200000000500000c8000000e87648170000000a00000000000000005039278c0400000000000000000000005039278c0400000000000000000000e8030000009001000a00000000000000009001008070000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e0000002800000000c817a804000000"];
|
||||
|
||||
let v1 = v1::HostConfiguration::<primitives::v1::BlockNumber>::decode(&mut &raw_config[..])
|
||||
let v1 = v1::HostConfiguration::<primitives::v2::BlockNumber>::decode(&mut &raw_config[..])
|
||||
.unwrap();
|
||||
|
||||
// We check only a sample of the values here. If we missed any fields or messed up data types
|
||||
@@ -270,7 +270,7 @@ mod tests {
|
||||
// We specify only the picked fields and the rest should be provided by the `Default`
|
||||
// implementation. That implementation is copied over between the two types and should work
|
||||
// fine.
|
||||
let v1 = v1::HostConfiguration::<primitives::v1::BlockNumber> {
|
||||
let v1 = v1::HostConfiguration::<primitives::v2::BlockNumber> {
|
||||
ump_max_individual_weight: 0x71616e6f6e0au64,
|
||||
needed_approvals: 69,
|
||||
thread_availability_period: 55,
|
||||
@@ -282,21 +282,21 @@ mod tests {
|
||||
let pending_configs_v1 = vec![
|
||||
(
|
||||
1,
|
||||
v1::HostConfiguration::<primitives::v1::BlockNumber> {
|
||||
v1::HostConfiguration::<primitives::v2::BlockNumber> {
|
||||
n_delay_tranches: 150,
|
||||
..v1.clone()
|
||||
},
|
||||
),
|
||||
(
|
||||
2,
|
||||
v1::HostConfiguration::<primitives::v1::BlockNumber> {
|
||||
v1::HostConfiguration::<primitives::v2::BlockNumber> {
|
||||
max_validators_per_core: Some(33),
|
||||
..v1.clone()
|
||||
},
|
||||
),
|
||||
(
|
||||
3,
|
||||
v1::HostConfiguration::<primitives::v1::BlockNumber> {
|
||||
v1::HostConfiguration::<primitives::v2::BlockNumber> {
|
||||
parathread_retries: 11,
|
||||
..v1.clone()
|
||||
},
|
||||
@@ -337,8 +337,8 @@ mod tests {
|
||||
// The same motivation as for the migration code. See `migrate_to_v2`.
|
||||
#[rustfmt::skip]
|
||||
fn assert_correct_translation(
|
||||
v1: v1::HostConfiguration<primitives::v1::BlockNumber>,
|
||||
v2: configuration::HostConfiguration<primitives::v1::BlockNumber>
|
||||
v1: v1::HostConfiguration<primitives::v2::BlockNumber>,
|
||||
v2: configuration::HostConfiguration<primitives::v2::BlockNumber>
|
||||
) {
|
||||
assert_eq!(v1.max_code_size , v2.max_code_size);
|
||||
assert_eq!(v1.max_head_data_size , v2.max_head_data_size);
|
||||
|
||||
@@ -520,7 +520,7 @@ fn verify_externally_accessible() {
|
||||
// This test verifies that the value can be accessed through the well known keys and the
|
||||
// host configuration decodes into the abridged version.
|
||||
|
||||
use primitives::v1::{well_known_keys, AbridgedHostConfiguration};
|
||||
use primitives::v2::{well_known_keys, AbridgedHostConfiguration};
|
||||
|
||||
new_test_ext(Default::default()).execute_with(|| {
|
||||
let ground_truth = HostConfiguration::default();
|
||||
|
||||
@@ -21,7 +21,7 @@ use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0};
|
||||
use frame_support::{ensure, traits::Get, weights::Weight};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
byzantine_threshold, supermajority_threshold, ApprovalVote, CandidateHash,
|
||||
CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CompactStatement, ConsensusLog,
|
||||
DisputeState, DisputeStatement, DisputeStatementSet, ExplicitDisputeStatement,
|
||||
|
||||
@@ -28,7 +28,7 @@ use frame_support::{
|
||||
assert_err, assert_noop, assert_ok,
|
||||
traits::{OnFinalize, OnInitialize},
|
||||
};
|
||||
use primitives::v1::BlockNumber;
|
||||
use primitives::v2::BlockNumber;
|
||||
use sp_core::{crypto::CryptoType, Pair};
|
||||
|
||||
/// Filtering updates the spam slots, as such update them.
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::{
|
||||
initializer,
|
||||
};
|
||||
use frame_support::pallet_prelude::*;
|
||||
use primitives::v1::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage};
|
||||
use primitives::v2::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage};
|
||||
use sp_runtime::traits::{BlakeTwo256, Hash as HashT, SaturatedConversion};
|
||||
use sp_std::{fmt, prelude::*};
|
||||
use xcm::latest::SendError;
|
||||
|
||||
@@ -18,7 +18,7 @@ use super::*;
|
||||
use crate::mock::{new_test_ext, Configuration, Dmp, MockGenesisConfig, Paras, System};
|
||||
use hex_literal::hex;
|
||||
use parity_scale_codec::Encode;
|
||||
use primitives::v1::BlockNumber;
|
||||
use primitives::v2::BlockNumber;
|
||||
|
||||
pub(crate) fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
||||
while System::block_number() < to {
|
||||
@@ -184,7 +184,7 @@ fn queue_downward_message_critical() {
|
||||
#[test]
|
||||
fn verify_dmq_mqc_head_is_externally_accessible() {
|
||||
use hex_literal::hex;
|
||||
use primitives::v1::well_known_keys;
|
||||
use primitives::v2::well_known_keys;
|
||||
|
||||
let a = ParaId::from(2020);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::{
|
||||
use frame_support::{pallet_prelude::*, traits::ReservableCurrency};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
Balance, Hash, HrmpChannelId, Id as ParaId, InboundHrmpMessage, OutboundHrmpMessage,
|
||||
SessionIndex,
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::mock::{
|
||||
System, Test,
|
||||
};
|
||||
use frame_support::{assert_noop, assert_ok, traits::Currency as _};
|
||||
use primitives::v1::BlockNumber;
|
||||
use primitives::v2::BlockNumber;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
||||
@@ -387,7 +387,7 @@ fn check_sent_messages() {
|
||||
|
||||
#[test]
|
||||
fn verify_externally_accessible() {
|
||||
use primitives::v1::{well_known_keys, AbridgedHrmpChannel};
|
||||
use primitives::v2::{well_known_keys, AbridgedHrmpChannel};
|
||||
|
||||
let para_a = 20.into();
|
||||
let para_b = 21.into();
|
||||
|
||||
@@ -27,7 +27,7 @@ use crate::{
|
||||
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
|
||||
use frame_support::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
AvailabilityBitfield, BackedCandidate, CandidateCommitments, CandidateDescriptor,
|
||||
CandidateHash, CandidateReceipt, CommittedCandidateReceipt, CoreIndex, GroupIndex, Hash,
|
||||
HeadData, Id as ParaId, SigningContext, UncheckedSignedAvailabilityBitfields, ValidatorId,
|
||||
@@ -574,7 +574,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
// check the signatures in the backing and that it is a majority.
|
||||
{
|
||||
let maybe_amount_validated = primitives::v1::check_candidate_backing(
|
||||
let maybe_amount_validated = primitives::v2::check_candidate_backing(
|
||||
&backed_candidate,
|
||||
&signing_context,
|
||||
group_vals.len(),
|
||||
@@ -692,7 +692,7 @@ impl<T: Config> Pallet<T> {
|
||||
/// Run the acceptance criteria checks on the given candidate commitments.
|
||||
pub(crate) fn check_validation_outputs_for_runtime_api(
|
||||
para_id: ParaId,
|
||||
validation_outputs: primitives::v1::CandidateCommitments,
|
||||
validation_outputs: primitives::v2::CandidateCommitments,
|
||||
) -> bool {
|
||||
// This function is meant to be called from the runtime APIs against the relay-parent, hence
|
||||
// `relay_parent_number` is equal to `now`.
|
||||
@@ -1038,11 +1038,11 @@ impl<T: Config> CandidateCheckContext<T> {
|
||||
&self,
|
||||
para_id: ParaId,
|
||||
head_data: &HeadData,
|
||||
new_validation_code: &Option<primitives::v1::ValidationCode>,
|
||||
new_validation_code: &Option<primitives::v2::ValidationCode>,
|
||||
processed_downward_messages: u32,
|
||||
upward_messages: &[primitives::v1::UpwardMessage],
|
||||
upward_messages: &[primitives::v2::UpwardMessage],
|
||||
hrmp_watermark: T::BlockNumber,
|
||||
horizontal_messages: &[primitives::v1::OutboundHrmpMessage<ParaId>],
|
||||
horizontal_messages: &[primitives::v2::OutboundHrmpMessage<ParaId>],
|
||||
) -> Result<(), AcceptanceCheckErr<T::BlockNumber>> {
|
||||
ensure!(
|
||||
head_data.0.len() <= self.config.max_head_data_size as _,
|
||||
|
||||
@@ -30,13 +30,11 @@ use assert_matches::assert_matches;
|
||||
use frame_support::assert_noop;
|
||||
use futures::executor::block_on;
|
||||
use keyring::Sr25519Keyring;
|
||||
use primitives::{
|
||||
v0::PARACHAIN_KEY_TYPE_ID,
|
||||
v1::{
|
||||
BlockNumber, CandidateCommitments, CandidateDescriptor, CollatorId,
|
||||
CompactStatement as Statement, Hash, SignedAvailabilityBitfield, SignedStatement,
|
||||
UncheckedSignedAvailabilityBitfield, ValidationCode, ValidatorId, ValidityAttestation,
|
||||
},
|
||||
use primitives::v2::{
|
||||
BlockNumber, CandidateCommitments, CandidateDescriptor, CollatorId,
|
||||
CompactStatement as Statement, Hash, SignedAvailabilityBitfield, SignedStatement,
|
||||
UncheckedSignedAvailabilityBitfield, ValidationCode, ValidatorId, ValidityAttestation,
|
||||
PARACHAIN_KEY_TYPE_ID,
|
||||
};
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
@@ -93,7 +91,7 @@ pub(crate) fn collator_sign_candidate(
|
||||
) {
|
||||
candidate.descriptor.collator = collator.public().into();
|
||||
|
||||
let payload = primitives::v1::collator_signature_payload(
|
||||
let payload = primitives::v2::collator_signature_payload(
|
||||
&candidate.descriptor.relay_parent,
|
||||
&candidate.descriptor.para_id,
|
||||
&candidate.descriptor.persisted_validation_data_hash,
|
||||
@@ -148,7 +146,7 @@ pub(crate) async fn back_candidate(
|
||||
let backed = BackedCandidate { candidate, validity_votes, validator_indices };
|
||||
|
||||
let successfully_backed =
|
||||
primitives::v1::check_candidate_backing(&backed, signing_context, group.len(), |i| {
|
||||
primitives::v2::check_candidate_backing(&backed, signing_context, group.len(), |i| {
|
||||
Some(validators[group[i].0 as usize].public().into())
|
||||
})
|
||||
.ok()
|
||||
|
||||
@@ -30,7 +30,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_system::limits::BlockWeights;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::v1::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId};
|
||||
use primitives::v2::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use super::*;
|
||||
use frame_benchmarking::benchmarks;
|
||||
use frame_system::RawOrigin;
|
||||
use primitives::v1::ConsensusLog;
|
||||
use primitives::v2::ConsensusLog;
|
||||
use sp_runtime::DigestItem;
|
||||
|
||||
// Random large number for the digest
|
||||
|
||||
@@ -18,7 +18,7 @@ use super::*;
|
||||
use crate::mock::{
|
||||
new_test_ext, Configuration, Dmp, Initializer, MockGenesisConfig, Paras, SessionInfo, System,
|
||||
};
|
||||
use primitives::v1::{HeadData, Id as ParaId};
|
||||
use primitives::v2::{HeadData, Id as ParaId};
|
||||
use test_helpers::dummy_validation_code;
|
||||
|
||||
use frame_support::{
|
||||
|
||||
@@ -50,7 +50,7 @@ mod mock;
|
||||
|
||||
pub use origin::{ensure_parachain, Origin};
|
||||
pub use paras::ParaLifecycle;
|
||||
use primitives::v1::Id as ParaId;
|
||||
use primitives::v2::Id as ParaId;
|
||||
|
||||
/// Schedule a para to be initialized at the start of the next session with the given genesis data.
|
||||
///
|
||||
@@ -65,7 +65,7 @@ pub fn schedule_para_initialize<T: paras::Config>(
|
||||
/// Schedule a para to be cleaned up at the start of the next session.
|
||||
///
|
||||
/// See [`paras::Pallet::schedule_para_cleanup`] for more details.
|
||||
pub fn schedule_para_cleanup<T: paras::Config>(id: primitives::v1::Id) -> Result<(), ()> {
|
||||
pub fn schedule_para_cleanup<T: paras::Config>(id: primitives::v2::Id) -> Result<(), ()> {
|
||||
<paras::Pallet<T>>::schedule_para_cleanup(id).map_err(|_| ())
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Runtime declaration of the parachain metrics.
|
||||
|
||||
use polkadot_runtime_metrics::{Counter, CounterVec};
|
||||
use primitives::v1::metric_definitions::{
|
||||
use primitives::v2::metric_definitions::{
|
||||
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
|
||||
PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED,
|
||||
PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED,
|
||||
|
||||
@@ -30,7 +30,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_support_test::TestRandomness;
|
||||
use parity_scale_codec::Decode;
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
AuthorityDiscoveryId, Balance, BlockNumber, Header, Moment, SessionIndex, UpwardMessage,
|
||||
ValidatorIndex,
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Declaration of the parachain specific origin and a pallet that hosts it.
|
||||
|
||||
use primitives::v1::Id as ParaId;
|
||||
use primitives::v2::Id as ParaId;
|
||||
use sp_runtime::traits::BadOrigin;
|
||||
use sp_std::result;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use pallet_babe::{self, CurrentBlockRandomness};
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
BackedCandidate, CandidateHash, CandidateReceipt, CheckedDisputeStatementSet,
|
||||
CheckedMultiDisputeStatementSet, CoreIndex, DisputeStatementSet,
|
||||
InherentData as ParachainsInherentData, MultiDisputeStatementSet, ScrapedOnChainVotes,
|
||||
|
||||
@@ -139,7 +139,7 @@ mod enter {
|
||||
#[test]
|
||||
fn test_session_is_tracked_in_on_chain_scraping() {
|
||||
use crate::disputes::run_to_block;
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
DisputeStatement, DisputeStatementSet, ExplicitDisputeStatement,
|
||||
InvalidDisputeStatementKind, ValidDisputeStatementKind,
|
||||
};
|
||||
@@ -861,8 +861,8 @@ mod enter {
|
||||
}
|
||||
}
|
||||
|
||||
fn default_header() -> primitives::v1::Header {
|
||||
primitives::v1::Header {
|
||||
fn default_header() -> primitives::v2::Header {
|
||||
primitives::v2::Header {
|
||||
parent_hash: Default::default(),
|
||||
number: 0,
|
||||
state_root: Default::default(),
|
||||
@@ -878,7 +878,7 @@ mod sanitizers {
|
||||
back_candidate, collator_sign_candidate, BackingKind, TestCandidateBuilder,
|
||||
};
|
||||
use bitvec::order::Lsb0;
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
AvailabilityBitfield, GroupIndex, Hash, Id as ParaId, SignedAvailabilityBitfield,
|
||||
ValidatorIndex,
|
||||
};
|
||||
@@ -887,7 +887,7 @@ mod sanitizers {
|
||||
use crate::mock::Test;
|
||||
use futures::executor::block_on;
|
||||
use keyring::Sr25519Keyring;
|
||||
use primitives::v0::PARACHAIN_KEY_TYPE_ID;
|
||||
use primitives::v2::PARACHAIN_KEY_TYPE_ID;
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
use crate::shared;
|
||||
use pallet_staking::SessionInterface;
|
||||
use primitives::v1::ValidatorIndex;
|
||||
use primitives::v2::ValidatorIndex;
|
||||
|
||||
/// The amount of era points given by backing a candidate that is included.
|
||||
pub const BACKING_POINTS: u32 = 20;
|
||||
@@ -74,7 +74,7 @@ mod tests {
|
||||
mock::{new_test_ext, MockGenesisConfig, ParasShared, Test},
|
||||
};
|
||||
use keyring::Sr25519Keyring;
|
||||
use primitives::v1::ValidatorId;
|
||||
use primitives::v2::ValidatorId;
|
||||
|
||||
#[test]
|
||||
fn rewards_based_on_indirection() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+10
-13
@@ -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)
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
//! over time.
|
||||
|
||||
use frame_support::pallet_prelude::*;
|
||||
use primitives::v1::{
|
||||
use primitives::v2::{
|
||||
CollatorId, CoreIndex, CoreOccupied, GroupIndex, GroupRotationInfo, Id as ParaId,
|
||||
ParathreadClaim, ParathreadEntry, ScheduledCore, ValidatorIndex,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ use super::*;
|
||||
|
||||
use frame_support::assert_ok;
|
||||
use keyring::Sr25519Keyring;
|
||||
use primitives::v1::{BlockNumber, CollatorId, SessionIndex, ValidatorId};
|
||||
use primitives::v2::{BlockNumber, CollatorId, SessionIndex, ValidatorId};
|
||||
|
||||
use crate::{
|
||||
configuration::HostConfiguration,
|
||||
|
||||
@@ -24,10 +24,7 @@ use crate::{
|
||||
util::{take_active_subset, take_active_subset_and_inactive},
|
||||
};
|
||||
use frame_support::{pallet_prelude::*, traits::OneSessionHandler};
|
||||
use primitives::{
|
||||
v1::{AssignmentId, AuthorityDiscoveryId, SessionIndex},
|
||||
v2::SessionInfo,
|
||||
};
|
||||
use primitives::v2::{AssignmentId, AuthorityDiscoveryId, SessionIndex, SessionInfo};
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
|
||||
pub fn migrate_to_v1<T: Config>() -> Weight {
|
||||
let mut vs = 0;
|
||||
|
||||
<Pallet<T> as Store>::Sessions::translate_values(|old: primitives::v1::SessionInfo| {
|
||||
<Pallet<T> as Store>::Sessions::translate_values(|old: primitives::v2::OldV1SessionInfo| {
|
||||
vs += 1;
|
||||
Some(primitives::v2::SessionInfo::from(old))
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ use crate::{
|
||||
util::take_active_subset,
|
||||
};
|
||||
use keyring::Sr25519Keyring;
|
||||
use primitives::v1::{BlockNumber, ValidatorId, ValidatorIndex};
|
||||
use primitives::v2::{BlockNumber, ValidatorId, ValidatorIndex};
|
||||
|
||||
fn run_to_block(
|
||||
to: BlockNumber,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//! dependent on any of the other pallets.
|
||||
|
||||
use frame_support::pallet_prelude::*;
|
||||
use primitives::v1::{SessionIndex, ValidatorId, ValidatorIndex};
|
||||
use primitives::v2::{SessionIndex, ValidatorId, ValidatorIndex};
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
use rand::{seq::SliceRandom, SeedableRng};
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::{
|
||||
};
|
||||
use frame_support::{pallet_prelude::*, traits::EnsureOrigin};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use primitives::v1::{Id as ParaId, UpwardMessage};
|
||||
use primitives::v2::{Id as ParaId, UpwardMessage};
|
||||
use sp_std::{
|
||||
collections::btree_map::BTreeMap, convert::TryFrom, fmt, marker::PhantomData, mem, prelude::*,
|
||||
};
|
||||
|
||||
@@ -261,7 +261,7 @@ fn verify_relay_dispatch_queue_size_is_externally_accessible() {
|
||||
// keys and is decodable into a (u32, u32).
|
||||
|
||||
use parity_scale_codec::Decode as _;
|
||||
use primitives::v1::well_known_keys;
|
||||
use primitives::v2::well_known_keys;
|
||||
|
||||
let a = ParaId::from(228);
|
||||
let msg = vec![1, 2, 3];
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Utilities that don't belong to any particular module but may draw
|
||||
//! on all modules.
|
||||
|
||||
use primitives::v1::{Id as ParaId, PersistedValidationData, ValidatorIndex};
|
||||
use primitives::v2::{Id as ParaId, PersistedValidationData, ValidatorIndex};
|
||||
use sp_std::{collections::btree_set::BTreeSet, vec::Vec};
|
||||
|
||||
use crate::{configuration, hrmp, paras};
|
||||
@@ -103,7 +103,7 @@ mod tests {
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
use crate::util::{split_active_subset, take_active_subset};
|
||||
use primitives::v1::ValidatorIndex;
|
||||
use primitives::v2::ValidatorIndex;
|
||||
|
||||
#[test]
|
||||
fn take_active_subset_is_compatible_with_split_active_subset() {
|
||||
|
||||
Reference in New Issue
Block a user