Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for primitives consolidation into v2 #1071

Merged
merged 5 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
499 changes: 250 additions & 249 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use polkadot_node_primitives::{
};
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
use polkadot_overseer::Handle as OverseerHandle;
use polkadot_primitives::v1::{CollatorPair, Id as ParaId};
use polkadot_primitives::v2::{CollatorPair, Id as ParaId};

use codec::{Decode, Encode};
use futures::{channel::oneshot, FutureExt};
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use codec::{Decode, Encode};
use cumulus_client_consensus_common::{
ParachainBlockImport, ParachainCandidate, ParachainConsensus,
};
use cumulus_primitives_core::{relay_chain::v1::Hash as PHash, PersistedValidationData};
use cumulus_primitives_core::{relay_chain::v2::Hash as PHash, PersistedValidationData};

use futures::lock::Mutex;
use sc_client_api::{backend::AuxStore, BlockOf};
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use polkadot_primitives::v1::{Hash as PHash, PersistedValidationData};
use polkadot_primitives::v2::{Hash as PHash, PersistedValidationData};
use sc_consensus::BlockImport;
use sp_runtime::traits::Block as BlockT;

Expand Down
2 changes: 1 addition & 1 deletion client/consensus/common/src/parachain_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use sp_runtime::{
traits::{Block as BlockT, Header as HeaderT},
};

use polkadot_primitives::v1::{Hash as PHash, Id as ParaId, OccupiedCoreAssumption};
use polkadot_primitives::v2::{Hash as PHash, Id as ParaId, OccupiedCoreAssumption};

use codec::Decode;
use futures::{select, FutureExt, Stream, StreamExt};
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use cumulus_test_client::{
};
use futures::{channel::mpsc, executor::block_on, select, FutureExt, Stream, StreamExt};
use futures_timer::Delay;
use polkadot_primitives::v1::Id as ParaId;
use polkadot_primitives::v2::Id as ParaId;
use sc_client_api::UsageProvider;
use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy};
use sp_blockchain::Error as ClientError;
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/relay-chain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use cumulus_client_consensus_common::{
ParachainBlockImport, ParachainCandidate, ParachainConsensus,
};
use cumulus_primitives_core::{relay_chain::v1::Hash as PHash, ParaId, PersistedValidationData};
use cumulus_primitives_core::{relay_chain::v2::Hash as PHash, ParaId, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;
use parking_lot::Mutex;

Expand Down
2 changes: 1 addition & 1 deletion client/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_node_primitives::{CollationSecondedSignal, Statement};
use polkadot_parachain::primitives::HeadData;
use polkadot_primitives::v1::{
use polkadot_primitives::v2::{
CandidateReceipt, CompactStatement, Hash as PHash, Id as ParaId, OccupiedCoreAssumption,
SigningContext, UncheckedSigned,
};
Expand Down
2 changes: 1 addition & 1 deletion client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cumulus_test_service::runtime::{Block, Hash, Header};
use futures::{executor::block_on, poll, task::Poll, FutureExt, Stream, StreamExt};
use parking_lot::Mutex;
use polkadot_node_primitives::{SignedFullStatement, Statement};
use polkadot_primitives::v1::{
use polkadot_primitives::v2::{
CandidateCommitments, CandidateDescriptor, CollatorPair, CommittedCandidateReceipt,
Hash as PHash, HeadData, Header as PHeader, Id as ParaId, InboundDownwardMessage,
InboundHrmpMessage, OccupiedCoreAssumption, PersistedValidationData, SessionIndex,
Expand Down
2 changes: 1 addition & 1 deletion client/pov-recovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use sp_runtime::{

use polkadot_node_primitives::{AvailableData, POV_BOMB_LIMIT};
use polkadot_overseer::Handle as OverseerHandle;
use polkadot_primitives::v1::{
use polkadot_primitives::v2::{
CandidateReceipt, CommittedCandidateReceipt, Id as ParaId, SessionIndex,
};

Expand Down
2 changes: 1 addition & 1 deletion client/relay-chain-inprocess-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch =
polkadot-test-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }

# Cumulus
cumulus-test-service = { path = "../../test/service" }
cumulus-test-service = { path = "../../test/service" }
8 changes: 5 additions & 3 deletions client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ use std::{pin::Pin, sync::Arc, time::Duration};
use async_trait::async_trait;
use cumulus_primitives_core::{
relay_chain::{
v1::{CommittedCandidateReceipt, OccupiedCoreAssumption, SessionIndex, ValidatorId},
v2::ParachainHost,
v2::{
CommittedCandidateReceipt, OccupiedCoreAssumption, ParachainHost, SessionIndex,
ValidatorId,
},
Block as PBlock, BlockId, Hash as PHash, Header as PHeader, InboundHrmpMessage,
},
InboundDownwardMessage, ParaId, PersistedValidationData,
Expand Down Expand Up @@ -384,7 +386,7 @@ mod tests {

use super::*;

use polkadot_primitives::v1::Block as PBlock;
use polkadot_primitives::v2::Block as PBlock;
use polkadot_test_client::{
construct_transfer_extrinsic, BlockBuilderExt, Client, ClientBlockImportExt,
DefaultTestClientBuilderExt, ExecutionStrategy, InitPolkadotBlockBuilder,
Expand Down
2 changes: 1 addition & 1 deletion client/relay-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::{collections::BTreeMap, pin::Pin, sync::Arc};

use cumulus_primitives_core::{
relay_chain::{
v1::{CommittedCandidateReceipt, OccupiedCoreAssumption, SessionIndex, ValidatorId},
v2::{CommittedCandidateReceipt, OccupiedCoreAssumption, SessionIndex, ValidatorId},
Hash as PHash, Header as PHeader, InboundHrmpMessage,
},
InboundDownwardMessage, ParaId, PersistedValidationData,
Expand Down
2 changes: 1 addition & 1 deletion client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use backoff::{future::retry_notify, ExponentialBackoff};
use core::time::Duration;
use cumulus_primitives_core::{
relay_chain::{
v1::{CommittedCandidateReceipt, OccupiedCoreAssumption, SessionIndex, ValidatorId},
v2::{CommittedCandidateReceipt, OccupiedCoreAssumption, SessionIndex, ValidatorId},
Hash as PHash, Header as PHeader, InboundHrmpMessage,
},
InboundDownwardMessage, ParaId, PersistedValidationData,
Expand Down
2 changes: 1 addition & 1 deletion client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cumulus_client_cli::CollatorOptions;
use cumulus_client_consensus_common::ParachainConsensus;
use cumulus_primitives_core::{CollectCollationInfo, ParaId};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_primitives::v1::CollatorPair;
use polkadot_primitives::v2::CollatorPair;
use sc_client_api::{
Backend as BackendT, BlockBackend, BlockchainEvents, Finalizer, UsageProvider,
};
Expand Down
10 changes: 5 additions & 5 deletions pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ pub mod pallet {
.read_upgrade_go_ahead_signal()
.expect("Invalid upgrade go ahead signal");
match upgrade_go_ahead_signal {
Some(relay_chain::v1::UpgradeGoAhead::GoAhead) => {
Some(relay_chain::v2::UpgradeGoAhead::GoAhead) => {
assert!(
<PendingValidationCode<T>>::exists(),
"No new validation function found in storage, GoAhead signal is not expected",
Expand All @@ -332,7 +332,7 @@ pub mod pallet {
<T::OnSystemEvent as OnSystemEvent>::on_validation_code_applied();
Self::deposit_event(Event::ValidationFunctionApplied(vfp.relay_parent_number));
},
Some(relay_chain::v1::UpgradeGoAhead::Abort) => {
Some(relay_chain::v2::UpgradeGoAhead::Abort) => {
<PendingValidationCode<T>>::kill();
Self::deposit_event(Event::ValidationFunctionDiscarded);
},
Expand Down Expand Up @@ -482,7 +482,7 @@ pub mod pallet {
/// set after the inherent.
#[pallet::storage]
pub(super) type UpgradeRestrictionSignal<T: Config> =
StorageValue<_, Option<relay_chain::v1::UpgradeRestriction>, ValueQuery>;
StorageValue<_, Option<relay_chain::v2::UpgradeRestriction>, ValueQuery>;

/// The snapshot of some state related to messaging relevant to the current parachain as per
/// the relay parent.
Expand Down Expand Up @@ -531,7 +531,7 @@ pub mod pallet {
/// This will be cleared in `on_initialize` of each new block.
#[pallet::storage]
pub(super) type HrmpWatermark<T: Config> =
StorageValue<_, relay_chain::v1::BlockNumber, ValueQuery>;
StorageValue<_, relay_chain::v2::BlockNumber, ValueQuery>;

/// HRMP messages that were sent in a block.
///
Expand Down Expand Up @@ -779,7 +779,7 @@ impl<T: Config> Pallet<T> {
fn process_inbound_horizontal_messages(
ingress_channels: &[(ParaId, cumulus_primitives_core::AbridgedHrmpChannel)],
horizontal_messages: BTreeMap<ParaId, Vec<InboundHrmpMessage>>,
relay_parent_number: relay_chain::v1::BlockNumber,
relay_parent_number: relay_chain::v2::BlockNumber,
) -> Weight {
// First, check that all submitted messages are sent from channels that exist. The
// channel exists if its MQC head is present in `vfp.hrmp_mqc_heads`.
Expand Down
14 changes: 7 additions & 7 deletions pallets/parachain-system/src/relay_state_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl RelayChainStateProof {
/// `proof`.
pub fn new(
para_id: ParaId,
relay_parent_storage_root: relay_chain::v1::Hash,
relay_parent_storage_root: relay_chain::v2::Hash,
proof: StorageProof,
) -> Result<Self, Error> {
let db = proof.into_memory_db::<HashFor<relay_chain::Block>>();
Expand Down Expand Up @@ -191,7 +191,7 @@ impl RelayChainStateProof {

let mut ingress_channels = Vec::with_capacity(ingress_channel_index.len());
for sender in ingress_channel_index {
let channel_id = relay_chain::v1::HrmpChannelId { sender, recipient: self.para_id };
let channel_id = relay_chain::v2::HrmpChannelId { sender, recipient: self.para_id };
let hrmp_channel: AbridgedHrmpChannel = read_entry(
&self.trie_backend,
&relay_chain::well_known_keys::hrmp_channels(channel_id),
Expand All @@ -203,7 +203,7 @@ impl RelayChainStateProof {

let mut egress_channels = Vec::with_capacity(egress_channel_index.len());
for recipient in egress_channel_index {
let channel_id = relay_chain::v1::HrmpChannelId { sender: self.para_id, recipient };
let channel_id = relay_chain::v2::HrmpChannelId { sender: self.para_id, recipient };
let hrmp_channel: AbridgedHrmpChannel = read_entry(
&self.trie_backend,
&relay_chain::well_known_keys::hrmp_channels(channel_id),
Expand Down Expand Up @@ -231,12 +231,12 @@ impl RelayChainStateProof {
.map_err(Error::Config)
}

/// Read the [`Slot`](relay_chain::v1::Slot) from the relay chain state proof.
/// Read the [`Slot`](relay_chain::v2::Slot) from the relay chain state proof.
///
/// The slot is slot of the relay chain block this state proof was extracted from.
///
/// Returns an error if anything failed at reading or decoding.
pub fn read_slot(&self) -> Result<relay_chain::v1::Slot, Error> {
pub fn read_slot(&self) -> Result<relay_chain::v2::Slot, Error> {
read_entry(&self.trie_backend, relay_chain::well_known_keys::CURRENT_SLOT, None)
.map_err(Error::Slot)
}
Expand All @@ -250,7 +250,7 @@ impl RelayChainStateProof {
/// Returns an error if anything failed at reading or decoding.
pub fn read_upgrade_go_ahead_signal(
&self,
) -> Result<Option<relay_chain::v1::UpgradeGoAhead>, Error> {
) -> Result<Option<relay_chain::v2::UpgradeGoAhead>, Error> {
read_optional_entry(
&self.trie_backend,
&relay_chain::well_known_keys::upgrade_go_ahead_signal(self.para_id),
Expand All @@ -266,7 +266,7 @@ impl RelayChainStateProof {
/// Returns an error if anything failed at reading or decoding.
pub fn read_upgrade_restriction_signal(
&self,
) -> Result<Option<relay_chain::v1::UpgradeRestriction>, Error> {
) -> Result<Option<relay_chain::v2::UpgradeRestriction>, Error> {
read_optional_entry(
&self.trie_backend,
&relay_chain::well_known_keys::upgrade_restriction_signal(self.para_id),
Expand Down
8 changes: 4 additions & 4 deletions pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use frame_support::{
};
use frame_system::RawOrigin;
use hex_literal::hex;
use relay_chain::v1::HrmpChannelId;
use relay_chain::v2::HrmpChannelId;
use sp_core::H256;
use sp_runtime::{
testing::Header,
Expand Down Expand Up @@ -392,7 +392,7 @@ fn events() {
BlockTests::new()
.with_relay_sproof_builder(|_, block_number, builder| {
if block_number > 123 {
builder.upgrade_go_ahead = Some(relay_chain::v1::UpgradeGoAhead::GoAhead);
builder.upgrade_go_ahead = Some(relay_chain::v2::UpgradeGoAhead::GoAhead);
}
})
.add_with_post_test(
Expand Down Expand Up @@ -443,7 +443,7 @@ fn manipulates_storage() {
BlockTests::new()
.with_relay_sproof_builder(|_, block_number, builder| {
if block_number > 123 {
builder.upgrade_go_ahead = Some(relay_chain::v1::UpgradeGoAhead::GoAhead);
builder.upgrade_go_ahead = Some(relay_chain::v2::UpgradeGoAhead::GoAhead);
}
})
.add(123, || {
Expand Down Expand Up @@ -471,7 +471,7 @@ fn aborted_upgrade() {
BlockTests::new()
.with_relay_sproof_builder(|_, block_number, builder| {
if block_number > 123 {
builder.upgrade_go_ahead = Some(relay_chain::v1::UpgradeGoAhead::Abort);
builder.upgrade_go_ahead = Some(relay_chain::v2::UpgradeGoAhead::Abort);
}
})
.add(123, || {
Expand Down
2 changes: 1 addition & 1 deletion pallets/solo-to-para/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use cumulus_pallet_parachain_system as parachain_system;
use frame_support::{dispatch::DispatchResult, pallet_prelude::*, weights::DispatchInfo};
use frame_system::pallet_prelude::*;
pub use pallet::*;
use polkadot_primitives::v1::PersistedValidationData;
use polkadot_primitives::v2::PersistedValidationData;
use scale_info::TypeInfo;
use sp_runtime::{
traits::{DispatchInfoOf, Dispatchable, SignedExtension},
Expand Down
2 changes: 1 addition & 1 deletion pallets/xcmp-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ std = [

runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
2 changes: 1 addition & 1 deletion parachain-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ runtime-benchmarks = [
"parachain-template-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks",
]
try-runtime = ["parachain-template-runtime/try-runtime"]
try-runtime = ["parachain-template-runtime/try-runtime"]
2 changes: 1 addition & 1 deletion parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub fn run() -> Result<()> {
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account(&id);

let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
Expand Down
8 changes: 4 additions & 4 deletions polkadot-parachains/parachains-common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<R> OnUnbalanced<NegativeImbalance<R>> for ToStakingPot<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config,
AccountIdOf<R>:
From<polkadot_primitives::v1::AccountId> + Into<polkadot_primitives::v1::AccountId>,
From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
{
fn on_nonzero_unbalanced(amount: NegativeImbalance<R>) {
Expand All @@ -56,7 +56,7 @@ impl<R> OnUnbalanced<NegativeImbalance<R>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_collator_selection::Config,
AccountIdOf<R>:
From<polkadot_primitives::v1::AccountId> + Into<polkadot_primitives::v1::AccountId>,
From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
<R as frame_system::Config>::Event: From<pallet_balances::Event<R>>,
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance<R>>) {
Expand All @@ -76,7 +76,7 @@ impl<R> HandleCredit<AccountIdOf<R>, pallet_assets::Pallet<R>> for AssetsToBlock
where
R: pallet_authorship::Config + pallet_assets::Config,
AccountIdOf<R>:
From<polkadot_primitives::v1::AccountId> + Into<polkadot_primitives::v1::AccountId>,
From<polkadot_primitives::v2::AccountId> + Into<polkadot_primitives::v2::AccountId>,
{
fn handle_credit(credit: CreditOf<AccountIdOf<R>, pallet_assets::Pallet<R>>) {
if let Some(author) = pallet_authorship::Pallet::<R>::author() {
Expand Down Expand Up @@ -119,7 +119,7 @@ mod tests {
};
use frame_system::{limits, EnsureRoot};
use pallet_collator_selection::IdentityCollator;
use polkadot_primitives::v1::AccountId;
use polkadot_primitives::v2::AccountId;
use sp_core::H256;
use sp_runtime::{
testing::Header,
Expand Down
2 changes: 1 addition & 1 deletion polkadot-parachains/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ pub fn run() -> Result<()> {
let id = ParaId::from(para_id);

let parachain_account =
AccountIdConversion::<polkadot_primitives::v0::AccountId>::into_account(&id);
AccountIdConversion::<polkadot_primitives::v2::AccountId>::into_account(&id);

let state_version =
RelayChainCli::native_runtime_version(&config.chain_spec).state_version();
Expand Down
2 changes: 1 addition & 1 deletion polkadot-parachains/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
};
use cumulus_primitives_core::{
relay_chain::v1::{Hash as PHash, PersistedValidationData},
relay_chain::v2::{Hash as PHash, PersistedValidationData},
ParaId,
};
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
Expand Down
Loading