diff --git a/bridges/relays/utils/Cargo.toml b/bridges/relays/utils/Cargo.toml index 1264f582983f..4765730a0b4f 100644 --- a/bridges/relays/utils/Cargo.toml +++ b/bridges/relays/utils/Cargo.toml @@ -36,4 +36,4 @@ bp-runtime = { path = "../../primitives/runtime" } # Substrate dependencies sp-runtime = { path = "../../../substrate/primitives/runtime" } -substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } diff --git a/bridges/relays/utils/src/error.rs b/bridges/relays/utils/src/error.rs index 26f1d0cacefd..48c02bb9bd7a 100644 --- a/bridges/relays/utils/src/error.rs +++ b/bridges/relays/utils/src/error.rs @@ -42,5 +42,5 @@ pub enum Error { ExposingMetricsInvalidHost(String, AddrParseError), /// Prometheus error. #[error("{0}")] - Prometheus(#[from] substrate_prometheus_endpoint::prometheus::Error), + Prometheus(#[from] prometheus_endpoint::prometheus::Error), } diff --git a/bridges/relays/utils/src/metrics.rs b/bridges/relays/utils/src/metrics.rs index 2e6c8236da45..4c946651b058 100644 --- a/bridges/relays/utils/src/metrics.rs +++ b/bridges/relays/utils/src/metrics.rs @@ -16,7 +16,7 @@ pub use float_json_value::FloatJsonValueMetric; pub use global::GlobalMetrics; -pub use substrate_prometheus_endpoint::{ +pub use prometheus_endpoint::{ prometheus::core::{Atomic, Collector}, register, Counter, CounterVec, Gauge, GaugeVec, Opts, PrometheusError, Registry, F64, I64, U64, }; diff --git a/bridges/relays/utils/src/relay_loop.rs b/bridges/relays/utils/src/relay_loop.rs index 7105190a4583..7f84fdc98f3c 100644 --- a/bridges/relays/utils/src/relay_loop.rs +++ b/bridges/relays/utils/src/relay_loop.rs @@ -21,8 +21,8 @@ use crate::{ }; use async_trait::async_trait; +use prometheus_endpoint::{init_prometheus, Registry}; use std::{fmt::Debug, future::Future, net::SocketAddr, time::Duration}; -use substrate_prometheus_endpoint::{init_prometheus, Registry}; /// Default pause between reconnect attempts. pub const RECONNECT_DELAY: Duration = Duration::from_secs(10); diff --git a/bridges/snowbridge/pallets/ethereum-client/Cargo.toml b/bridges/snowbridge/pallets/ethereum-client/Cargo.toml index e60934e34740..cab2b06b0931 100644 --- a/bridges/snowbridge/pallets/ethereum-client/Cargo.toml +++ b/bridges/snowbridge/pallets/ethereum-client/Cargo.toml @@ -33,7 +33,7 @@ sp-io = { path = "../../../../substrate/primitives/io", default-features = false snowbridge-core = { path = "../../primitives/core", default-features = false } snowbridge-ethereum = { path = "../../primitives/ethereum", default-features = false } snowbridge-pallet-ethereum-client-fixtures = { path = "fixtures", default-features = false, optional = true } -primitives = { package = "snowbridge-beacon-primitives", path = "../../primitives/beacon", default-features = false } +snowbridge-beacon-primitives = { path = "../../primitives/beacon", default-features = false } static_assertions = { version = "1.1.0", default-features = false } pallet-timestamp = { path = "../../../../substrate/frame/timestamp", default-features = false, optional = true } @@ -62,9 +62,9 @@ std = [ "frame-system/std", "log/std", "pallet-timestamp/std", - "primitives/std", "scale-info/std", "serde", + "snowbridge-beacon-primitives/std", "snowbridge-core/std", "snowbridge-ethereum/std", "snowbridge-pallet-ethereum-client-fixtures/std", diff --git a/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/mod.rs b/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/mod.rs index 4b8796b628d7..12aa3f4ca1fa 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/mod.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/mod.rs @@ -9,7 +9,7 @@ use frame_system::RawOrigin; use snowbridge_pallet_ethereum_client_fixtures::*; -use primitives::{ +use snowbridge_beacon_primitives::{ fast_aggregate_verify, prepare_aggregate_pubkey, prepare_aggregate_signature, verify_merkle_branch, }; diff --git a/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/util.rs b/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/util.rs index 7e5ded6e1f0d..95e16d9fd434 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/util.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/benchmarking/util.rs @@ -4,7 +4,7 @@ use crate::{ decompress_sync_committee_bits, Config, CurrentSyncCommittee, Pallet as EthereumBeaconClient, Update, ValidatorsRoot, Vec, }; -use primitives::PublicKeyPrepared; +use snowbridge_beacon_primitives::PublicKeyPrepared; use sp_core::H256; pub fn participant_pubkeys( diff --git a/bridges/snowbridge/pallets/ethereum-client/src/config/mod.rs b/bridges/snowbridge/pallets/ethereum-client/src/config/mod.rs index ba3ea47b94f9..1ab1f67d6397 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/config/mod.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/config/mod.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -use primitives::merkle_proof::{generalized_index_length, subtree_index}; +use snowbridge_beacon_primitives::merkle_proof::{generalized_index_length, subtree_index}; use static_assertions::const_assert; /// Generalized Indices diff --git a/bridges/snowbridge/pallets/ethereum-client/src/functions.rs b/bridges/snowbridge/pallets/ethereum-client/src/functions.rs index 751e63c7f86a..781ae6c67638 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/functions.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/functions.rs @@ -10,9 +10,10 @@ use crate::config::{ pub fn decompress_sync_committee_bits( input: [u8; SYNC_COMMITTEE_BITS_SIZE], ) -> [u8; SYNC_COMMITTEE_SIZE] { - primitives::decompress_sync_committee_bits::( - input, - ) + snowbridge_beacon_primitives::decompress_sync_committee_bits::< + SYNC_COMMITTEE_SIZE, + SYNC_COMMITTEE_BITS_SIZE, + >(input) } /// Compute the sync committee period in which a slot is contained. diff --git a/bridges/snowbridge/pallets/ethereum-client/src/impls.rs b/bridges/snowbridge/pallets/ethereum-client/src/impls.rs index f600b1f67e29..2def6f58ba30 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/impls.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/impls.rs @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 2023 Snowfork use super::*; use frame_support::ensure; -use primitives::ExecutionProof; +use snowbridge_beacon_primitives::ExecutionProof; use snowbridge_core::inbound::{ VerificationError::{self, *}, diff --git a/bridges/snowbridge/pallets/ethereum-client/src/lib.rs b/bridges/snowbridge/pallets/ethereum-client/src/lib.rs index 6a5972ca7a14..6894977c21f4 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/lib.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/lib.rs @@ -36,7 +36,7 @@ use frame_support::{ dispatch::DispatchResult, pallet_prelude::OptionQuery, traits::Get, transactional, }; use frame_system::ensure_signed; -use primitives::{ +use snowbridge_beacon_primitives::{ fast_aggregate_verify, verify_merkle_branch, verify_receipt_proof, BeaconHeader, BlsError, CompactBeaconState, ForkData, ForkVersion, ForkVersions, PublicKeyPrepared, SigningData, }; diff --git a/bridges/snowbridge/pallets/ethereum-client/src/mock.rs b/bridges/snowbridge/pallets/ethereum-client/src/mock.rs index bd6144ebd8f9..96298d4fa896 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/mock.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/mock.rs @@ -4,7 +4,7 @@ use crate as ethereum_beacon_client; use crate::config; use frame_support::{derive_impl, dispatch::DispatchResult, parameter_types}; use pallet_timestamp; -use primitives::{Fork, ForkVersions}; +use snowbridge_beacon_primitives::{Fork, ForkVersions}; use snowbridge_core::inbound::{Log, Proof}; use sp_std::default::Default; use std::{fs::File, path::PathBuf}; @@ -21,32 +21,40 @@ where serde_json::from_reader(File::open(filepath).unwrap()) } -pub fn load_execution_proof_fixture() -> primitives::ExecutionProof { +pub fn load_execution_proof_fixture() -> snowbridge_beacon_primitives::ExecutionProof { load_fixture("execution-proof.json".to_string()).unwrap() } pub fn load_checkpoint_update_fixture( -) -> primitives::CheckpointUpdate<{ config::SYNC_COMMITTEE_SIZE }> { +) -> snowbridge_beacon_primitives::CheckpointUpdate<{ config::SYNC_COMMITTEE_SIZE }> { load_fixture("initial-checkpoint.json".to_string()).unwrap() } -pub fn load_sync_committee_update_fixture( -) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> { +pub fn load_sync_committee_update_fixture() -> snowbridge_beacon_primitives::Update< + { config::SYNC_COMMITTEE_SIZE }, + { config::SYNC_COMMITTEE_BITS_SIZE }, +> { load_fixture("sync-committee-update.json".to_string()).unwrap() } -pub fn load_finalized_header_update_fixture( -) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> { +pub fn load_finalized_header_update_fixture() -> snowbridge_beacon_primitives::Update< + { config::SYNC_COMMITTEE_SIZE }, + { config::SYNC_COMMITTEE_BITS_SIZE }, +> { load_fixture("finalized-header-update.json".to_string()).unwrap() } -pub fn load_next_sync_committee_update_fixture( -) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> { +pub fn load_next_sync_committee_update_fixture() -> snowbridge_beacon_primitives::Update< + { config::SYNC_COMMITTEE_SIZE }, + { config::SYNC_COMMITTEE_BITS_SIZE }, +> { load_fixture("next-sync-committee-update.json".to_string()).unwrap() } -pub fn load_next_finalized_header_update_fixture( -) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> { +pub fn load_next_finalized_header_update_fixture() -> snowbridge_beacon_primitives::Update< + { config::SYNC_COMMITTEE_SIZE }, + { config::SYNC_COMMITTEE_BITS_SIZE }, +> { load_fixture("next-finalized-header-update.json".to_string()).unwrap() } diff --git a/bridges/snowbridge/pallets/ethereum-client/src/tests.rs b/bridges/snowbridge/pallets/ethereum-client/src/tests.rs index da762dc2fd80..c16743b75ea4 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/tests.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/tests.rs @@ -17,7 +17,7 @@ pub use crate::mock::*; use crate::config::{EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT}; use frame_support::{assert_err, assert_noop, assert_ok}; use hex_literal::hex; -use primitives::{ +use snowbridge_beacon_primitives::{ types::deneb, Fork, ForkVersions, NextSyncCommitteeUpdate, VersionedExecutionPayloadHeader, }; use snowbridge_core::inbound::{VerificationError, Verifier}; @@ -171,7 +171,8 @@ pub fn sync_committee_participation_is_supermajority() { let bits = hex!("bffffffff7f1ffdfcfeffeffbfdffffbfffffdffffefefffdffff7f7ffff77fffdf7bff77ffdf7fffafffffff77fefffeff7effffffff5f7fedfffdfb6ddff7b" ); - let participation = primitives::decompress_sync_committee_bits::<512, 64>(bits); + let participation = + snowbridge_beacon_primitives::decompress_sync_committee_bits::<512, 64>(bits); assert_ok!(EthereumBeaconClient::sync_committee_participation_is_supermajority(&participation)); } diff --git a/bridges/snowbridge/pallets/ethereum-client/src/types.rs b/bridges/snowbridge/pallets/ethereum-client/src/types.rs index 92b9f77f739b..a670e691612e 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/types.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/types.rs @@ -8,14 +8,14 @@ use frame_support::storage::types::OptionQuery; use snowbridge_core::RingBufferMapImpl; // Specialize types based on configured sync committee size -pub type SyncCommittee = primitives::SyncCommittee; -pub type SyncCommitteePrepared = primitives::SyncCommitteePrepared; -pub type SyncAggregate = primitives::SyncAggregate; -pub type CheckpointUpdate = primitives::CheckpointUpdate; -pub type Update = primitives::Update; -pub type NextSyncCommitteeUpdate = primitives::NextSyncCommitteeUpdate; +pub type SyncCommittee = snowbridge_beacon_primitives::SyncCommittee; +pub type SyncCommitteePrepared = snowbridge_beacon_primitives::SyncCommitteePrepared; +pub type SyncAggregate = snowbridge_beacon_primitives::SyncAggregate; +pub type CheckpointUpdate = snowbridge_beacon_primitives::CheckpointUpdate; +pub type Update = snowbridge_beacon_primitives::Update; +pub type NextSyncCommitteeUpdate = snowbridge_beacon_primitives::NextSyncCommitteeUpdate; -pub use primitives::{AncestryProof, ExecutionProof}; +pub use snowbridge_beacon_primitives::{AncestryProof, ExecutionProof}; /// FinalizedState ring buffer implementation pub type FinalizedBeaconStateBuffer = RingBufferMapImpl< diff --git a/bridges/snowbridge/primitives/router/Cargo.toml b/bridges/snowbridge/primitives/router/Cargo.toml index 1d3fc43909df..ec0888dd41b0 100644 --- a/bridges/snowbridge/primitives/router/Cargo.toml +++ b/bridges/snowbridge/primitives/router/Cargo.toml @@ -30,7 +30,7 @@ snowbridge-core = { path = "../core", default-features = false } hex-literal = { version = "0.4.1" } [dev-dependencies] -hex = { package = "rustc-hex", version = "2.1.0" } +rustc-hex = { version = "2.1.0" } [features] default = ["std"] diff --git a/cumulus/client/consensus/aura/Cargo.toml b/cumulus/client/consensus/aura/Cargo.toml index 547137b73064..fad30e59e869 100644 --- a/cumulus/client/consensus/aura/Cargo.toml +++ b/cumulus/client/consensus/aura/Cargo.toml @@ -35,7 +35,7 @@ sp-keystore = { path = "../../../../substrate/primitives/keystore" } sp-runtime = { path = "../../../../substrate/primitives/runtime" } sp-timestamp = { path = "../../../../substrate/primitives/timestamp" } sp-state-machine = { path = "../../../../substrate/primitives/state-machine" } -substrate-prometheus-endpoint = { path = "../../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../../substrate/utils/prometheus" } # Cumulus cumulus-client-consensus-common = { path = "../common" } diff --git a/cumulus/client/consensus/aura/src/equivocation_import_queue.rs b/cumulus/client/consensus/aura/src/equivocation_import_queue.rs index c3b601123b56..be554bdcfc79 100644 --- a/cumulus/client/consensus/aura/src/equivocation_import_queue.rs +++ b/cumulus/client/consensus/aura/src/equivocation_import_queue.rs @@ -224,7 +224,7 @@ pub fn fully_verifying_import_queue( block_import: I, create_inherent_data_providers: CIDP, spawner: &impl sp_core::traits::SpawnEssentialNamed, - registry: Option<&substrate_prometheus_endpoint::Registry>, + registry: Option<&prometheus_endpoint::Registry>, telemetry: Option, ) -> BasicQueue where diff --git a/cumulus/client/consensus/aura/src/import_queue.rs b/cumulus/client/consensus/aura/src/import_queue.rs index 2611eaf532f8..cbbfbe8d2223 100644 --- a/cumulus/client/consensus/aura/src/import_queue.rs +++ b/cumulus/client/consensus/aura/src/import_queue.rs @@ -18,6 +18,7 @@ use codec::Codec; use cumulus_client_consensus_common::ParachainBlockImportMarker; +use prometheus_endpoint::Registry; use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider}; use sc_consensus::{import_queue::DefaultImportQueue, BlockImport}; use sc_consensus_aura::{AuraVerifier, CompatibilityMode}; @@ -32,7 +33,6 @@ use sp_core::crypto::Pair; use sp_inherents::CreateInherentDataProviders; use sp_runtime::traits::Block as BlockT; use std::{fmt::Debug, sync::Arc}; -use substrate_prometheus_endpoint::Registry; /// Parameters for [`import_queue`]. pub struct ImportQueueParams<'a, I, C, CIDP, S> { diff --git a/cumulus/client/consensus/common/Cargo.toml b/cumulus/client/consensus/common/Cargo.toml index 3a7c6b57d6d9..d369304e2e33 100644 --- a/cumulus/client/consensus/common/Cargo.toml +++ b/cumulus/client/consensus/common/Cargo.toml @@ -28,7 +28,7 @@ sp-core = { path = "../../../../substrate/primitives/core" } sp-runtime = { path = "../../../../substrate/primitives/runtime" } sp-timestamp = { path = "../../../../substrate/primitives/timestamp" } sp-trie = { path = "../../../../substrate/primitives/trie" } -substrate-prometheus-endpoint = { path = "../../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../../substrate/utils/prometheus" } # Polkadot polkadot-primitives = { path = "../../../../polkadot/primitives" } diff --git a/cumulus/client/consensus/common/src/import_queue.rs b/cumulus/client/consensus/common/src/import_queue.rs index 311a2b7ad8cf..8024b7695a28 100644 --- a/cumulus/client/consensus/common/src/import_queue.rs +++ b/cumulus/client/consensus/common/src/import_queue.rs @@ -63,7 +63,7 @@ impl Verifier for VerifyNothing { pub fn verify_nothing_import_queue( block_import: I, spawner: &impl sp_core::traits::SpawnEssentialNamed, - registry: Option<&substrate_prometheus_endpoint::Registry>, + registry: Option<&prometheus_endpoint::Registry>, ) -> BasicQueue where I: BlockImport diff --git a/cumulus/client/consensus/relay-chain/Cargo.toml b/cumulus/client/consensus/relay-chain/Cargo.toml index cb32b9804576..7c3a901db6c3 100644 --- a/cumulus/client/consensus/relay-chain/Cargo.toml +++ b/cumulus/client/consensus/relay-chain/Cargo.toml @@ -24,7 +24,7 @@ sp-consensus = { path = "../../../../substrate/primitives/consensus/common" } sp-core = { path = "../../../../substrate/primitives/core" } sp-inherents = { path = "../../../../substrate/primitives/inherents" } sp-runtime = { path = "../../../../substrate/primitives/runtime" } -substrate-prometheus-endpoint = { path = "../../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../../substrate/utils/prometheus" } # Cumulus cumulus-client-consensus-common = { path = "../common" } diff --git a/cumulus/client/consensus/relay-chain/src/import_queue.rs b/cumulus/client/consensus/relay-chain/src/import_queue.rs index f44f44093243..1b521e79d482 100644 --- a/cumulus/client/consensus/relay-chain/src/import_queue.rs +++ b/cumulus/client/consensus/relay-chain/src/import_queue.rs @@ -114,7 +114,7 @@ pub fn import_queue( block_import: I, create_inherent_data_providers: CIDP, spawner: &impl sp_core::traits::SpawnEssentialNamed, - registry: Option<&substrate_prometheus_endpoint::Registry>, + registry: Option<&prometheus_endpoint::Registry>, ) -> ClientResult> where I: BlockImport diff --git a/cumulus/client/relay-chain-interface/Cargo.toml b/cumulus/client/relay-chain-interface/Cargo.toml index 5962c68bba7a..5d612cdc0eef 100644 --- a/cumulus/client/relay-chain-interface/Cargo.toml +++ b/cumulus/client/relay-chain-interface/Cargo.toml @@ -23,4 +23,4 @@ futures = "0.3.28" async-trait = "0.1.79" thiserror = { workspace = true } jsonrpsee-core = "0.22" -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } diff --git a/cumulus/client/relay-chain-interface/src/lib.rs b/cumulus/client/relay-chain-interface/src/lib.rs index bb93e6a168c8..7c7796b468c0 100644 --- a/cumulus/client/relay-chain-interface/src/lib.rs +++ b/cumulus/client/relay-chain-interface/src/lib.rs @@ -22,8 +22,8 @@ use sc_client_api::StorageProof; use futures::Stream; use async_trait::async_trait; +use codec::Error as CodecError; use jsonrpsee_core::ClientError as JsonRpcError; -use parity_scale_codec::Error as CodecError; use sp_api::ApiError; use cumulus_primitives_core::relay_chain::BlockId; diff --git a/cumulus/client/relay-chain-minimal-node/Cargo.toml b/cumulus/client/relay-chain-minimal-node/Cargo.toml index 88673a8f08fe..0b541092a3de 100644 --- a/cumulus/client/relay-chain-minimal-node/Cargo.toml +++ b/cumulus/client/relay-chain-minimal-node/Cargo.toml @@ -32,7 +32,7 @@ sc-network = { path = "../../../substrate/client/network" } sc-network-common = { path = "../../../substrate/client/network/common" } sc-service = { path = "../../../substrate/client/service" } sc-client-api = { path = "../../../substrate/client/api" } -substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } sc-tracing = { path = "../../../substrate/client/tracing" } sc-utils = { path = "../../../substrate/client/utils" } sp-api = { path = "../../../substrate/primitives/api" } diff --git a/cumulus/client/relay-chain-minimal-node/src/lib.rs b/cumulus/client/relay-chain-minimal-node/src/lib.rs index 699393e2d48a..9101b8154aa7 100644 --- a/cumulus/client/relay-chain-minimal-node/src/lib.rs +++ b/cumulus/client/relay-chain-minimal-node/src/lib.rs @@ -190,7 +190,7 @@ async fn new_minimal_relay_chain(pallet_session::Pallet); pub trait Config: pallet_session::Config {} diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/Cargo.toml index 7ac65b0ee1de..113036b4c00e 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/Cargo.toml @@ -16,8 +16,8 @@ workspace = true sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false } sp-authority-discovery = { path = "../../../../../../../substrate/primitives/authority-discovery", default-features = false } sp-consensus-babe = { path = "../../../../../../../substrate/primitives/consensus/babe", default-features = false } -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../../../substrate/primitives/consensus/beefy" } -grandpa = { package = "sc-consensus-grandpa", path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false } +sp-consensus-beefy = { path = "../../../../../../../substrate/primitives/consensus/beefy" } +sc-consensus-grandpa = { path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false } # Polkadot polkadot-primitives = { path = "../../../../../../../polkadot/primitives", default-features = false } diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs index 55437645b052..074a1de5e185 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/relays/rococo/src/genesis.rs @@ -14,10 +14,10 @@ // limitations under the License. // Substrate -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; -use grandpa::AuthorityId as GrandpaId; +use sc_consensus_grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; use sp_core::{sr25519, storage::Storage}; // Polkadot diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/Cargo.toml index e4688a1c9f02..b952477c47a7 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/Cargo.toml @@ -17,8 +17,8 @@ sp-core = { path = "../../../../../../../substrate/primitives/core", default-fea sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false } sp-authority-discovery = { path = "../../../../../../../substrate/primitives/authority-discovery", default-features = false } sp-consensus-babe = { path = "../../../../../../../substrate/primitives/consensus/babe", default-features = false } -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../../../substrate/primitives/consensus/beefy" } -grandpa = { package = "sc-consensus-grandpa", path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false } +sp-consensus-beefy = { path = "../../../../../../../substrate/primitives/consensus/beefy" } +sc-consensus-grandpa = { path = "../../../../../../../substrate/client/consensus/grandpa", default-features = false } pallet-staking = { path = "../../../../../../../substrate/frame/staking", default-features = false } # Polkadot diff --git a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs index 700b80e63f6c..b9f12932b84e 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/relays/westend/src/genesis.rs @@ -14,10 +14,10 @@ // limitations under the License. // Substrate -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; -use grandpa::AuthorityId as GrandpaId; +use sc_consensus_grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; use sp_core::storage::Storage; use sp_runtime::Perbill; diff --git a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml index b010d2a29638..d9ec81323230 100644 --- a/cumulus/parachains/integration-tests/emulated/common/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/common/Cargo.toml @@ -14,8 +14,8 @@ codec = { package = "parity-scale-codec", version = "3.6.12", default-features = paste = "1.0.14" # Substrate -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../../../substrate/primitives/consensus/beefy" } -grandpa = { package = "sc-consensus-grandpa", path = "../../../../../substrate/client/consensus/grandpa" } +sp-consensus-beefy = { path = "../../../../../substrate/primitives/consensus/beefy" } +sc-consensus-grandpa = { path = "../../../../../substrate/client/consensus/grandpa" } sp-authority-discovery = { path = "../../../../../substrate/primitives/authority-discovery" } sp-runtime = { path = "../../../../../substrate/primitives/runtime" } frame-support = { path = "../../../../../substrate/frame/support" } diff --git a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs index cbde0642f1a2..4a9d3b3a5aaf 100644 --- a/cumulus/parachains/integration-tests/emulated/common/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/common/src/lib.rs @@ -20,11 +20,11 @@ pub mod xcm_helpers; pub use xcm_emulator; // Substrate -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; use frame_support::parameter_types; -use grandpa::AuthorityId as GrandpaId; +use sc_consensus_grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; use sp_core::{sr25519, storage::Storage, Pair, Public}; use sp_runtime::{ traits::{AccountIdConversion, IdentifyAccount, Verify}, diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index def7d95fd566..639b8b3d4dcf 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -86,9 +86,9 @@ sp-inherents = { path = "../../substrate/primitives/inherents" } sp-api = { path = "../../substrate/primitives/api" } sp-consensus-aura = { path = "../../substrate/primitives/consensus/aura" } sc-sysinfo = { path = "../../substrate/client/sysinfo" } -substrate-prometheus-endpoint = { path = "../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../substrate/utils/prometheus" } sc-transaction-pool-api = { path = "../../substrate/client/transaction-pool/api" } -frame-rpc-system = { package = "substrate-frame-rpc-system", path = "../../substrate/utils/frame/rpc/system" } +substrate-frame-rpc-system = { path = "../../substrate/utils/frame/rpc/system" } pallet-transaction-payment-rpc = { path = "../../substrate/frame/transaction-payment/rpc" } substrate-state-trie-migration-rpc = { path = "../../substrate/utils/frame/rpc/state-trie-migration-rpc" } diff --git a/cumulus/polkadot-parachain/src/rpc.rs b/cumulus/polkadot-parachain/src/rpc.rs index caee14e55522..7437bb1f4b93 100644 --- a/cumulus/polkadot-parachain/src/rpc.rs +++ b/cumulus/polkadot-parachain/src/rpc.rs @@ -54,15 +54,15 @@ where + Send + Sync + 'static, - C::Api: frame_rpc_system::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, B: sc_client_api::Backend + Send + Sync + 'static, B::State: sc_client_api::backend::StateBackend>, { - use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use substrate_frame_rpc_system::{System, SystemApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut module = RpcExtension::new(()); @@ -88,14 +88,14 @@ where + Send + Sync + 'static, - C::Api: frame_rpc_system::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BlockBuilder, P: TransactionPool + Sync + Send + 'static, { - use frame_rpc_system::{System, SystemApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_rpc::dev::{Dev, DevApiServer}; + use substrate_frame_rpc_system::{System, SystemApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; diff --git a/cumulus/polkadot-parachain/src/service.rs b/cumulus/polkadot-parachain/src/service.rs index 12eda3e8a9cb..19ad75e384ce 100644 --- a/cumulus/polkadot-parachain/src/service.rs +++ b/cumulus/polkadot-parachain/src/service.rs @@ -43,6 +43,7 @@ pub use parachains_common::{AccountId, AuraId, Balance, Block, Hash, Header, Non use cumulus_client_consensus_relay_chain::Verifier as RelayChainVerifier; use futures::{lock::Mutex, prelude::*}; +use prometheus_endpoint::Registry; use sc_consensus::{ import_queue::{BasicQueue, Verifier as VerifierT}, BlockImportParams, ImportQueue, @@ -61,7 +62,6 @@ use sp_runtime::{ traits::{Block as BlockT, Header as HeaderT}, }; use std::{marker::PhantomData, sync::Arc, time::Duration}; -use substrate_prometheus_endpoint::Registry; use polkadot_primitives::CollatorPair; @@ -209,7 +209,7 @@ where + sp_block_builder::BlockBuilder + cumulus_primitives_core::CollectCollationInfo + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi, + + substrate_frame_rpc_system::AccountNonceApi, RB: Fn( DenyUnsafe, Arc>, @@ -471,7 +471,7 @@ where RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue + sp_block_builder::BlockBuilder + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi, + + substrate_frame_rpc_system::AccountNonceApi, { let deps = rpc::FullDeps { client, pool, deny_unsafe }; @@ -736,7 +736,7 @@ where + cumulus_primitives_core::CollectCollationInfo + sp_consensus_aura::AuraApi::Pair as Pair>::Public> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + frame_rpc_system::AccountNonceApi + + substrate_frame_rpc_system::AccountNonceApi + cumulus_primitives_aura::AuraUnincludedSegmentApi, <::Pair as Pair>::Signature: TryFrom> + std::hash::Hash + sp_runtime::traits::Member + Codec, diff --git a/docs/sdk/Cargo.toml b/docs/sdk/Cargo.toml index a8c873be556c..292811920128 100644 --- a/docs/sdk/Cargo.toml +++ b/docs/sdk/Cargo.toml @@ -15,7 +15,7 @@ workspace = true [dependencies] # Needed for all FRAME-based code -parity-scale-codec = { version = "3.6.12", default-features = false } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false } scale-info = { version = "2.6.0", default-features = false } frame = { package = "polkadot-sdk-frame", path = "../../substrate/frame", features = [ "experimental", diff --git a/docs/sdk/src/reference_docs/extrinsic_encoding.rs b/docs/sdk/src/reference_docs/extrinsic_encoding.rs index 8c8568a228fa..31ce92c67e98 100644 --- a/docs/sdk/src/reference_docs/extrinsic_encoding.rs +++ b/docs/sdk/src/reference_docs/extrinsic_encoding.rs @@ -191,7 +191,7 @@ #[docify::export] pub mod call_data { - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; // The outer enum composes calls within // different pallets together. We have two @@ -224,7 +224,7 @@ pub mod call_data { pub mod encoding_example { use super::call_data::{Call, PalletACall}; use crate::reference_docs::signed_extensions::signed_extensions_example; - use parity_scale_codec::Encode; + use codec::Encode; use sp_core::crypto::AccountId32; use sp_keyring::sr25519::Keyring; use sp_runtime::{ diff --git a/docs/sdk/src/reference_docs/signed_extensions.rs b/docs/sdk/src/reference_docs/signed_extensions.rs index 28b1426536bc..43a6bcc14c5d 100644 --- a/docs/sdk/src/reference_docs/signed_extensions.rs +++ b/docs/sdk/src/reference_docs/signed_extensions.rs @@ -8,7 +8,7 @@ #[docify::export] pub mod signed_extensions_example { - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::traits::SignedExtension; diff --git a/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index 719d00490a9d..1917dcd579c4 100644 --- a/polkadot/cli/Cargo.toml +++ b/polkadot/cli/Cargo.toml @@ -23,10 +23,10 @@ clap = { version = "4.5.3", features = ["derive"], optional = true } log = { workspace = true, default-features = true } thiserror = { workspace = true } futures = "0.3.30" -pyro = { package = "pyroscope", version = "0.5.3", optional = true } +pyroscope = { version = "0.5.3", optional = true } pyroscope_pprofrs = { version = "0.2", optional = true } -service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true } +polkadot-service = { path = "../node/service", default-features = false, optional = true } sp-core = { path = "../../substrate/primitives/core" } sp-io = { path = "../../substrate/primitives/io" } @@ -48,7 +48,8 @@ substrate-build-script-utils = { path = "../../substrate/utils/build-script-util [features] default = ["cli", "db", "full-node"] -db = ["service/db"] +db = ["polkadot-service/db"] +service = ["dep:polkadot-service"] cli = [ "clap", "frame-benchmarking-cli", @@ -60,24 +61,24 @@ cli = [ runtime-benchmarks = [ "frame-benchmarking-cli?/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks", + "polkadot-service?/runtime-benchmarks", "sc-service?/runtime-benchmarks", - "service/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] -full-node = ["service/full-node"] +full-node = ["polkadot-service/full-node"] try-runtime = [ - "service/try-runtime", + "polkadot-service?/try-runtime", "sp-runtime/try-runtime", ] -fast-runtime = ["service/fast-runtime"] -pyroscope = ["pyro", "pyroscope_pprofrs"] +fast-runtime = ["polkadot-service/fast-runtime"] +pyroscope = ["dep:pyroscope", "pyroscope_pprofrs"] # Configure the native runtimes to use. -westend-native = ["service/westend-native"] -rococo-native = ["service/rococo-native"] +westend-native = ["polkadot-service/westend-native"] +rococo-native = ["polkadot-service/rococo-native"] -malus = ["full-node", "service/malus"] +malus = ["full-node", "polkadot-service/malus"] runtime-metrics = [ "polkadot-node-metrics/runtime-metrics", - "service/runtime-metrics", + "polkadot-service/runtime-metrics", ] diff --git a/polkadot/cli/src/command.rs b/polkadot/cli/src/command.rs index f5ee538e8cec..b89054b4dc32 100644 --- a/polkadot/cli/src/command.rs +++ b/polkadot/cli/src/command.rs @@ -18,17 +18,17 @@ use crate::cli::{Cli, Subcommand, NODE_VERSION}; use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE}; use futures::future::TryFutureExt; use log::info; -use sc_cli::SubstrateCli; -use service::{ +use polkadot_service::{ self, benchmarking::{benchmark_inherent_data, RemarkBuilder, TransferKeepAliveBuilder}, HeaderBackend, IdentifyVariant, }; +use sc_cli::SubstrateCli; use sp_core::crypto::Ss58AddressFormatRegistry; use sp_keyring::Sr25519Keyring; use std::net::ToSocketAddrs; -pub use crate::{error::Error, service::BlockId}; +pub use crate::error::Error; #[cfg(feature = "hostperfcheck")] pub use polkadot_performance_test::PerfCheckError; #[cfg(feature = "pyroscope")] @@ -85,55 +85,55 @@ impl SubstrateCli for Cli { id }; Ok(match id { - "kusama" => Box::new(service::chain_spec::kusama_config()?), + "kusama" => Box::new(polkadot_service::chain_spec::kusama_config()?), name if name.starts_with("kusama-") && !name.ends_with(".json") => Err(format!("`{name}` is not supported anymore as the kusama native runtime no longer part of the node."))?, - "polkadot" => Box::new(service::chain_spec::polkadot_config()?), + "polkadot" => Box::new(polkadot_service::chain_spec::polkadot_config()?), name if name.starts_with("polkadot-") && !name.ends_with(".json") => Err(format!("`{name}` is not supported anymore as the polkadot native runtime no longer part of the node."))?, - "paseo" => Box::new(service::chain_spec::paseo_config()?), - "rococo" => Box::new(service::chain_spec::rococo_config()?), + "paseo" => Box::new(polkadot_service::chain_spec::paseo_config()?), + "rococo" => Box::new(polkadot_service::chain_spec::rococo_config()?), #[cfg(feature = "rococo-native")] - "dev" | "rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?), + "dev" | "rococo-dev" => Box::new(polkadot_service::chain_spec::rococo_development_config()?), #[cfg(feature = "rococo-native")] - "rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?), + "rococo-local" => Box::new(polkadot_service::chain_spec::rococo_local_testnet_config()?), #[cfg(feature = "rococo-native")] - "rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?), + "rococo-staging" => Box::new(polkadot_service::chain_spec::rococo_staging_testnet_config()?), #[cfg(not(feature = "rococo-native"))] name if name.starts_with("rococo-") && !name.ends_with(".json") || name == "dev" => Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?, - "westend" => Box::new(service::chain_spec::westend_config()?), + "westend" => Box::new(polkadot_service::chain_spec::westend_config()?), #[cfg(feature = "westend-native")] - "westend-dev" => Box::new(service::chain_spec::westend_development_config()?), + "westend-dev" => Box::new(polkadot_service::chain_spec::westend_development_config()?), #[cfg(feature = "westend-native")] - "westend-local" => Box::new(service::chain_spec::westend_local_testnet_config()?), + "westend-local" => Box::new(polkadot_service::chain_spec::westend_local_testnet_config()?), #[cfg(feature = "westend-native")] - "westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()?), + "westend-staging" => Box::new(polkadot_service::chain_spec::westend_staging_testnet_config()?), #[cfg(not(feature = "westend-native"))] name if name.starts_with("westend-") && !name.ends_with(".json") => Err(format!("`{}` only supported with `westend-native` feature enabled.", name))?, - "wococo" => Box::new(service::chain_spec::wococo_config()?), + "wococo" => Box::new(polkadot_service::chain_spec::wococo_config()?), #[cfg(feature = "rococo-native")] - "wococo-dev" => Box::new(service::chain_spec::wococo_development_config()?), + "wococo-dev" => Box::new(polkadot_service::chain_spec::wococo_development_config()?), #[cfg(feature = "rococo-native")] - "wococo-local" => Box::new(service::chain_spec::wococo_local_testnet_config()?), + "wococo-local" => Box::new(polkadot_service::chain_spec::wococo_local_testnet_config()?), #[cfg(not(feature = "rococo-native"))] name if name.starts_with("wococo-") => Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?, #[cfg(feature = "rococo-native")] - "versi-dev" => Box::new(service::chain_spec::versi_development_config()?), + "versi-dev" => Box::new(polkadot_service::chain_spec::versi_development_config()?), #[cfg(feature = "rococo-native")] - "versi-local" => Box::new(service::chain_spec::versi_local_testnet_config()?), + "versi-local" => Box::new(polkadot_service::chain_spec::versi_local_testnet_config()?), #[cfg(feature = "rococo-native")] - "versi-staging" => Box::new(service::chain_spec::versi_staging_testnet_config()?), + "versi-staging" => Box::new(polkadot_service::chain_spec::versi_staging_testnet_config()?), #[cfg(not(feature = "rococo-native"))] name if name.starts_with("versi-") => Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?, path => { let path = std::path::PathBuf::from(path); - let chain_spec = Box::new(service::GenericChainSpec::from_json_file(path.clone())?) - as Box; + let chain_spec = Box::new(polkadot_service::GenericChainSpec::from_json_file(path.clone())?) + as Box; // When `force_*` is given or the file name starts with the name of one of the known // chains, we use the chain spec for the specific chain. @@ -142,11 +142,11 @@ impl SubstrateCli for Cli { chain_spec.is_wococo() || chain_spec.is_versi() { - Box::new(service::RococoChainSpec::from_json_file(path)?) + Box::new(polkadot_service::RococoChainSpec::from_json_file(path)?) } else if self.run.force_kusama || chain_spec.is_kusama() { - Box::new(service::GenericChainSpec::from_json_file(path)?) + Box::new(polkadot_service::GenericChainSpec::from_json_file(path)?) } else if self.run.force_westend || chain_spec.is_westend() { - Box::new(service::WestendChainSpec::from_json_file(path)?) + Box::new(polkadot_service::WestendChainSpec::from_json_file(path)?) } else { chain_spec } @@ -155,7 +155,7 @@ impl SubstrateCli for Cli { } } -fn set_default_ss58_version(spec: &Box) { +fn set_default_ss58_version(spec: &Box) { let ss58_version = if spec.is_kusama() { Ss58AddressFormatRegistry::KusamaAccount } else if spec.is_westend() { @@ -176,7 +176,7 @@ fn set_default_ss58_version(spec: &Box) { #[cfg(feature = "malus")] pub fn run_node( run: Cli, - overseer_gen: impl service::OverseerGen, + overseer_gen: impl polkadot_service::OverseerGen, malus_finality_delay: Option, ) -> Result<()> { run_node_inner(run, overseer_gen, malus_finality_delay, |_logger_builder, _config| {}) @@ -184,7 +184,7 @@ pub fn run_node( fn run_node_inner( cli: Cli, - overseer_gen: impl service::OverseerGen, + overseer_gen: impl polkadot_service::OverseerGen, maybe_malus_finality_delay: Option, logger_hook: F, ) -> Result<()> @@ -235,10 +235,10 @@ where .flatten(); let database_source = config.database.clone(); - let task_manager = service::build_full( + let task_manager = polkadot_service::build_full( config, - service::NewFullParams { - is_parachain_node: service::IsParachainNode::No, + polkadot_service::NewFullParams { + is_parachain_node: polkadot_service::IsParachainNode::No, enable_beefy, force_authoring_backoff: cli.run.force_authoring_backoff, jaeger_agent, @@ -284,7 +284,7 @@ pub fn run() -> Result<()> { .next() .ok_or_else(|| Error::AddressResolutionMissing)?; // The pyroscope agent requires a `http://` prefix, so we just do that. - let agent = pyro::PyroscopeAgent::builder( + let agent = pyroscope::PyroscopeAgent::builder( "http://".to_owned() + address.to_string().as_str(), "polkadot".to_owned(), ) @@ -303,7 +303,7 @@ pub fn run() -> Result<()> { match &cli.subcommand { None => run_node_inner( cli, - service::ValidatorOverseerGen, + polkadot_service::ValidatorOverseerGen, None, polkadot_node_metrics::logger_hook(), ), @@ -319,7 +319,7 @@ pub fn run() -> Result<()> { runner.async_run(|mut config| { let (client, _, import_queue, task_manager) = - service::new_chain_ops(&mut config, None)?; + polkadot_service::new_chain_ops(&mut config, None)?; Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager)) }) }, @@ -331,7 +331,8 @@ pub fn run() -> Result<()> { Ok(runner.async_run(|mut config| { let (client, _, _, task_manager) = - service::new_chain_ops(&mut config, None).map_err(Error::PolkadotService)?; + polkadot_service::new_chain_ops(&mut config, None) + .map_err(Error::PolkadotService)?; Ok((cmd.run(client, config.database).map_err(Error::SubstrateCli), task_manager)) })?) }, @@ -342,7 +343,8 @@ pub fn run() -> Result<()> { set_default_ss58_version(chain_spec); Ok(runner.async_run(|mut config| { - let (client, _, _, task_manager) = service::new_chain_ops(&mut config, None)?; + let (client, _, _, task_manager) = + polkadot_service::new_chain_ops(&mut config, None)?; Ok((cmd.run(client, config.chain_spec).map_err(Error::SubstrateCli), task_manager)) })?) }, @@ -354,7 +356,7 @@ pub fn run() -> Result<()> { Ok(runner.async_run(|mut config| { let (client, _, import_queue, task_manager) = - service::new_chain_ops(&mut config, None)?; + polkadot_service::new_chain_ops(&mut config, None)?; Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager)) })?) }, @@ -369,15 +371,18 @@ pub fn run() -> Result<()> { set_default_ss58_version(chain_spec); Ok(runner.async_run(|mut config| { - let (client, backend, _, task_manager) = service::new_chain_ops(&mut config, None)?; + let (client, backend, _, task_manager) = + polkadot_service::new_chain_ops(&mut config, None)?; let aux_revert = Box::new(|client, backend, blocks| { - service::revert_backend(client, backend, blocks, config).map_err(|err| { - match err { - service::Error::Blockchain(err) => err.into(), - // Generic application-specific error. - err => sc_cli::Error::Application(err.into()), - } - }) + polkadot_service::revert_backend(client, backend, blocks, config).map_err( + |err| { + match err { + polkadot_service::Error::Blockchain(err) => err.into(), + // Generic application-specific error. + err => sc_cli::Error::Application(err.into()), + } + }, + ) }); Ok(( cmd.run(client, backend, Some(aux_revert)).map_err(Error::SubstrateCli), @@ -400,21 +405,22 @@ pub fn run() -> Result<()> { .into()), #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| { - let (client, backend, _, _) = service::new_chain_ops(&mut config, None)?; + let (client, backend, _, _) = + polkadot_service::new_chain_ops(&mut config, None)?; let db = backend.expose_db(); let storage = backend.expose_storage(); cmd.run(config, client.clone(), db, storage).map_err(Error::SubstrateCli) }), BenchmarkCmd::Block(cmd) => runner.sync_run(|mut config| { - let (client, _, _, _) = service::new_chain_ops(&mut config, None)?; + let (client, _, _, _) = polkadot_service::new_chain_ops(&mut config, None)?; cmd.run(client.clone()).map_err(Error::SubstrateCli) }), // These commands are very similar and can be handled in nearly the same way. BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) => runner.sync_run(|mut config| { - let (client, _, _, _) = service::new_chain_ops(&mut config, None)?; + let (client, _, _, _) = polkadot_service::new_chain_ops(&mut config, None)?; let header = client.header(client.info().genesis_hash).unwrap().unwrap(); let inherent_data = benchmark_inherent_data(header) .map_err(|e| format!("generating inherent data: {:?}", e))?; @@ -454,7 +460,7 @@ pub fn run() -> Result<()> { if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| { - cmd.run_with_spec::, ()>( + cmd.run_with_spec::, ()>( Some(config.chain_spec), ) .map_err(|e| Error::SubstrateCli(e)) @@ -481,7 +487,7 @@ pub fn run() -> Result<()> { Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?), Some(Subcommand::ChainInfo(cmd)) => { let runner = cli.create_runner(cmd)?; - Ok(runner.sync_run(|config| cmd.run::(&config))?) + Ok(runner.sync_run(|config| cmd.run::(&config))?) }, }?; diff --git a/polkadot/cli/src/error.rs b/polkadot/cli/src/error.rs index 219289796522..1fcd2ca04bb0 100644 --- a/polkadot/cli/src/error.rs +++ b/polkadot/cli/src/error.rs @@ -17,7 +17,7 @@ #[derive(thiserror::Error, Debug)] pub enum Error { #[error(transparent)] - PolkadotService(#[from] service::Error), + PolkadotService(#[from] polkadot_service::Error), #[error(transparent)] SubstrateCli(#[from] sc_cli::Error), @@ -34,7 +34,7 @@ pub enum Error { #[cfg(feature = "pyroscope")] #[error("Failed to connect to pyroscope agent")] - PyroscopeError(#[from] pyro::error::PyroscopeError), + PyroscopeError(#[from] pyroscope::error::PyroscopeError), #[error("Failed to resolve provided URL")] AddressResolutionFailure(#[from] std::io::Error), diff --git a/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index 4bb0dfb75835..944f8438f20f 100644 --- a/polkadot/cli/src/lib.rs +++ b/polkadot/cli/src/lib.rs @@ -26,10 +26,12 @@ mod command; mod error; #[cfg(feature = "service")] -pub use service::{self, Block, CoreApi, IdentifyVariant, ProvideRuntimeApi, TFullClient}; +pub use polkadot_service::{ + self as service, Block, CoreApi, IdentifyVariant, ProvideRuntimeApi, TFullClient, +}; #[cfg(feature = "malus")] -pub use service::overseer::validator_overseer_builder; +pub use polkadot_service::overseer::validator_overseer_builder; #[cfg(feature = "cli")] pub use cli::*; diff --git a/polkadot/core-primitives/Cargo.toml b/polkadot/core-primitives/Cargo.toml index 9794f8286ac3..7d94196fa26d 100644 --- a/polkadot/core-primitives/Cargo.toml +++ b/polkadot/core-primitives/Cargo.toml @@ -14,12 +14,12 @@ sp-core = { path = "../../substrate/primitives/core", default-features = false } sp-std = { path = "../../substrate/primitives/std", default-features = false } sp-runtime = { path = "../../substrate/primitives/runtime", default-features = false } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } [features] default = ["std"] std = [ - "parity-scale-codec/std", + "codec/std", "scale-info/std", "sp-core/std", "sp-runtime/std", diff --git a/polkadot/core-primitives/src/lib.rs b/polkadot/core-primitives/src/lib.rs index a74cdef3ad76..072c045a8c70 100644 --- a/polkadot/core-primitives/src/lib.rs +++ b/polkadot/core-primitives/src/lib.rs @@ -20,7 +20,7 @@ //! //! These core Polkadot types are used by the relay chain and the Parachains. -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_runtime::{ generic, diff --git a/polkadot/erasure-coding/Cargo.toml b/polkadot/erasure-coding/Cargo.toml index bf152e03be71..3c14fd95eee3 100644 --- a/polkadot/erasure-coding/Cargo.toml +++ b/polkadot/erasure-coding/Cargo.toml @@ -13,7 +13,7 @@ workspace = true polkadot-primitives = { path = "../primitives" } polkadot-node-primitives = { package = "polkadot-node-primitives", path = "../node/primitives" } novelpoly = { package = "reed-solomon-novelpoly", version = "2.0.0" } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive", "std"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive", "std"] } sp-core = { path = "../../substrate/primitives/core" } sp-trie = { path = "../../substrate/primitives/trie" } thiserror = { workspace = true } diff --git a/polkadot/erasure-coding/fuzzer/Cargo.toml b/polkadot/erasure-coding/fuzzer/Cargo.toml index 4e5ef9d229d8..bd254f6d5165 100644 --- a/polkadot/erasure-coding/fuzzer/Cargo.toml +++ b/polkadot/erasure-coding/fuzzer/Cargo.toml @@ -13,7 +13,7 @@ workspace = true polkadot-erasure-coding = { path = ".." } honggfuzz = "0.5" polkadot-primitives = { path = "../../primitives" } -primitives = { package = "polkadot-node-primitives", path = "../../node/primitives" } +polkadot-node-primitives = { path = "../../node/primitives" } [[bin]] name = "reconstruct" diff --git a/polkadot/erasure-coding/fuzzer/src/reconstruct.rs b/polkadot/erasure-coding/fuzzer/src/reconstruct.rs index b2f9690a6fd3..6cb5742bc7d1 100644 --- a/polkadot/erasure-coding/fuzzer/src/reconstruct.rs +++ b/polkadot/erasure-coding/fuzzer/src/reconstruct.rs @@ -16,7 +16,7 @@ use honggfuzz::fuzz; use polkadot_erasure_coding::*; -use primitives::AvailableData; +use polkadot_node_primitives::AvailableData; fn main() { loop { diff --git a/polkadot/erasure-coding/fuzzer/src/round_trip.rs b/polkadot/erasure-coding/fuzzer/src/round_trip.rs index 2e38becf651d..627c9724d494 100644 --- a/polkadot/erasure-coding/fuzzer/src/round_trip.rs +++ b/polkadot/erasure-coding/fuzzer/src/round_trip.rs @@ -16,8 +16,8 @@ use honggfuzz::fuzz; use polkadot_erasure_coding::*; +use polkadot_node_primitives::{AvailableData, BlockData, PoV}; use polkadot_primitives::PersistedValidationData; -use primitives::{AvailableData, BlockData, PoV}; use std::sync::Arc; fn main() { diff --git a/polkadot/erasure-coding/src/lib.rs b/polkadot/erasure-coding/src/lib.rs index b354c3dac64c..9ebf5d11d7a7 100644 --- a/polkadot/erasure-coding/src/lib.rs +++ b/polkadot/erasure-coding/src/lib.rs @@ -24,7 +24,7 @@ //! f is the maximum number of faulty validators in the system. //! The data is coded so any f+1 chunks can be used to reconstruct the full data. -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_primitives::{AvailableData, Proof}; use polkadot_primitives::{BlakeTwo256, Hash as H256, HashT}; use sp_core::Blake2Hasher; @@ -71,7 +71,7 @@ pub enum Error { BadPayload, /// Unable to decode reconstructed bytes. #[error("Unable to decode reconstructed payload: {0}")] - Decode(#[source] parity_scale_codec::Error), + Decode(#[source] codec::Error), /// Invalid branch proof. #[error("Invalid branch proof")] InvalidBranchProof, diff --git a/polkadot/node/collation-generation/Cargo.toml b/polkadot/node/collation-generation/Cargo.toml index 0a28c3a830d1..da5d10d79949 100644 --- a/polkadot/node/collation-generation/Cargo.toml +++ b/polkadot/node/collation-generation/Cargo.toml @@ -20,11 +20,11 @@ polkadot-primitives = { path = "../../primitives" } sp-core = { path = "../../../substrate/primitives/core" } sp-maybe-compressed-blob = { path = "../../../substrate/primitives/maybe-compressed-blob" } thiserror = { workspace = true } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" } assert_matches = "1.4.0" rstest = "0.18.2" sp-keyring = { path = "../../../substrate/primitives/keyring" } diff --git a/polkadot/node/collation-generation/src/lib.rs b/polkadot/node/collation-generation/src/lib.rs index 374f090a2671..0c2f8ee14a58 100644 --- a/polkadot/node/collation-generation/src/lib.rs +++ b/polkadot/node/collation-generation/src/lib.rs @@ -31,8 +31,8 @@ #![deny(missing_docs)] +use codec::Encode; use futures::{channel::oneshot, future::FutureExt, join, select}; -use parity_scale_codec::Encode; use polkadot_node_primitives::{ AvailableData, Collation, CollationGenerationConfig, CollationSecondedSignal, PoV, SubmitCollationParams, diff --git a/polkadot/node/collation-generation/src/tests.rs b/polkadot/node/collation-generation/src/tests.rs index 10c391cba25d..0feee79e763c 100644 --- a/polkadot/node/collation-generation/src/tests.rs +++ b/polkadot/node/collation-generation/src/tests.rs @@ -34,15 +34,15 @@ use polkadot_primitives::{ AsyncBackingParams, BlockNumber, CollatorPair, HeadData, PersistedValidationData, ScheduledCore, ValidationCode, }; +use polkadot_primitives_test_helpers::{ + dummy_candidate_descriptor, dummy_hash, dummy_head_data, dummy_validator, make_candidate, +}; use rstest::rstest; use sp_keyring::sr25519::Keyring as Sr25519Keyring; use std::{ collections::{BTreeMap, VecDeque}, pin::Pin, }; -use test_helpers::{ - dummy_candidate_descriptor, dummy_hash, dummy_head_data, dummy_validator, make_candidate, -}; type VirtualOverseer = TestSubsystemContextHandle; diff --git a/polkadot/node/core/approval-voting/Cargo.toml b/polkadot/node/core/approval-voting/Cargo.toml index 5bf80d59ede9..7da3d7ddd781 100644 --- a/polkadot/node/core/approval-voting/Cargo.toml +++ b/polkadot/node/core/approval-voting/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] futures = "0.3.30" futures-timer = "3.0.2" -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } gum = { package = "tracing-gum", path = "../../gum" } bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } schnellru = "0.2.1" @@ -50,7 +50,7 @@ sp-consensus-babe = { path = "../../../../substrate/primitives/consensus/babe" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } assert_matches = "1.4.0" kvdb-memorydb = "0.13.0" -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } log = { workspace = true, default-features = true } env_logger = "0.11" diff --git a/polkadot/node/core/approval-voting/src/approval_checking.rs b/polkadot/node/core/approval-voting/src/approval_checking.rs index 693a28800114..8667d3639185 100644 --- a/polkadot/node/core/approval-voting/src/approval_checking.rs +++ b/polkadot/node/core/approval-voting/src/approval_checking.rs @@ -482,9 +482,9 @@ pub fn tranches_to_approve( mod tests { use super::*; use crate::{approval_db, BTreeMap}; - use ::test_helpers::{dummy_candidate_receipt, dummy_hash}; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0, vec::BitVec}; use polkadot_primitives::GroupIndex; + use polkadot_primitives_test_helpers::{dummy_candidate_receipt, dummy_hash}; #[test] fn pending_is_not_approved() { diff --git a/polkadot/node/core/approval-voting/src/approval_db/common/mod.rs b/polkadot/node/core/approval-voting/src/approval_db/common/mod.rs index 249dcf912df5..11266f0b99d8 100644 --- a/polkadot/node/core/approval-voting/src/approval_db/common/mod.rs +++ b/polkadot/node/core/approval-voting/src/approval_db/common/mod.rs @@ -17,7 +17,7 @@ //! Common helper functions for all versions of approval-voting database. use std::sync::Arc; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_subsystem::{SubsystemError, SubsystemResult}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; use polkadot_primitives::{BlockNumber, CandidateHash, CandidateIndex, Hash}; @@ -64,7 +64,7 @@ impl DbBackend { #[derive(Debug, derive_more::From, derive_more::Display)] pub enum Error { Io(std::io::Error), - InvalidDecoding(parity_scale_codec::Error), + InvalidDecoding(codec::Error), InternalError(SubsystemError), } diff --git a/polkadot/node/core/approval-voting/src/approval_db/v1/mod.rs b/polkadot/node/core/approval-voting/src/approval_db/v1/mod.rs index 011d0a559c02..53e9db64f636 100644 --- a/polkadot/node/core/approval-voting/src/approval_db/v1/mod.rs +++ b/polkadot/node/core/approval-voting/src/approval_db/v1/mod.rs @@ -22,7 +22,7 @@ //! its data in the database. Any breaking changes here will still //! require a db migration (check `node/service/src/parachains_db/upgrade.rs`). -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_primitives::approval::v1::{AssignmentCert, DelayTranche}; use polkadot_primitives::{ BlockNumber, CandidateHash, CandidateReceipt, CoreIndex, GroupIndex, Hash, SessionIndex, diff --git a/polkadot/node/core/approval-voting/src/approval_db/v1/tests.rs b/polkadot/node/core/approval-voting/src/approval_db/v1/tests.rs index b0966ad01f7b..4c08d22f3ca2 100644 --- a/polkadot/node/core/approval-voting/src/approval_db/v1/tests.rs +++ b/polkadot/node/core/approval-voting/src/approval_db/v1/tests.rs @@ -25,7 +25,9 @@ use polkadot_node_subsystem_util::database::Database; use polkadot_primitives::Id as ParaId; use std::{collections::HashMap, sync::Arc}; -use ::test_helpers::{dummy_candidate_receipt, dummy_candidate_receipt_bad_sig, dummy_hash}; +use polkadot_primitives_test_helpers::{ + dummy_candidate_receipt, dummy_candidate_receipt_bad_sig, dummy_hash, +}; const DATA_COL: u32 = 0; diff --git a/polkadot/node/core/approval-voting/src/approval_db/v2/mod.rs b/polkadot/node/core/approval-voting/src/approval_db/v2/mod.rs index da42fc5be485..cd9256a5d47e 100644 --- a/polkadot/node/core/approval-voting/src/approval_db/v2/mod.rs +++ b/polkadot/node/core/approval-voting/src/approval_db/v2/mod.rs @@ -16,7 +16,7 @@ //! Version 2 of the DB schema. -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_primitives::approval::{v1::DelayTranche, v2::AssignmentCertV2}; use polkadot_node_subsystem::{SubsystemError, SubsystemResult}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; diff --git a/polkadot/node/core/approval-voting/src/approval_db/v2/tests.rs b/polkadot/node/core/approval-voting/src/approval_db/v2/tests.rs index 5fa915add416..06a3cc1e306b 100644 --- a/polkadot/node/core/approval-voting/src/approval_db/v2/tests.rs +++ b/polkadot/node/core/approval-voting/src/approval_db/v2/tests.rs @@ -34,7 +34,9 @@ use polkadot_primitives::Id as ParaId; use sp_consensus_slots::Slot; use std::{collections::HashMap, sync::Arc}; -use ::test_helpers::{dummy_candidate_receipt, dummy_candidate_receipt_bad_sig, dummy_hash}; +use polkadot_primitives_test_helpers::{ + dummy_candidate_receipt, dummy_candidate_receipt_bad_sig, dummy_hash, +}; const DATA_COL: u32 = 0; diff --git a/polkadot/node/core/approval-voting/src/approval_db/v3/mod.rs b/polkadot/node/core/approval-voting/src/approval_db/v3/mod.rs index 3e4f43021952..7118fb6770fd 100644 --- a/polkadot/node/core/approval-voting/src/approval_db/v3/mod.rs +++ b/polkadot/node/core/approval-voting/src/approval_db/v3/mod.rs @@ -19,7 +19,7 @@ //! Version 3 modifies the `our_approval` format of `ApprovalEntry` //! and adds a new field `pending_signatures` for `BlockEntry` -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_primitives::approval::v2::CandidateBitfield; use polkadot_node_subsystem::SubsystemResult; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; diff --git a/polkadot/node/core/approval-voting/src/approval_db/v3/tests.rs b/polkadot/node/core/approval-voting/src/approval_db/v3/tests.rs index 7c0cf9d4f7da..d2a1d7d400b1 100644 --- a/polkadot/node/core/approval-voting/src/approval_db/v3/tests.rs +++ b/polkadot/node/core/approval-voting/src/approval_db/v3/tests.rs @@ -33,7 +33,9 @@ use polkadot_primitives::Id as ParaId; use sp_consensus_slots::Slot; use std::{collections::HashMap, sync::Arc}; -use ::test_helpers::{dummy_candidate_receipt, dummy_candidate_receipt_bad_sig, dummy_hash}; +use polkadot_primitives_test_helpers::{ + dummy_candidate_receipt, dummy_candidate_receipt_bad_sig, dummy_hash, +}; const DATA_COL: u32 = 0; diff --git a/polkadot/node/core/approval-voting/src/criteria.rs b/polkadot/node/core/approval-voting/src/criteria.rs index 57c0ac272dc5..fb9d281e43bc 100644 --- a/polkadot/node/core/approval-voting/src/criteria.rs +++ b/polkadot/node/core/approval-voting/src/criteria.rs @@ -16,8 +16,8 @@ //! Assignment criteria VRF generation and checking. +use codec::{Decode, Encode}; use itertools::Itertools; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::approval::{ self as approval_types, v1::{AssignmentCert, AssignmentCertKind, DelayTranche, RelayVRFStory}, diff --git a/polkadot/node/core/approval-voting/src/import.rs b/polkadot/node/core/approval-voting/src/import.rs index 13b0b1bae1bc..59b6f91c0a82 100644 --- a/polkadot/node/core/approval-voting/src/import.rs +++ b/polkadot/node/core/approval-voting/src/import.rs @@ -609,7 +609,6 @@ pub(crate) mod tests { approval_db::common::{load_block_entry, DbBackend}, RuntimeInfo, RuntimeInfoConfig, MAX_BLOCKS_WITH_ASSIGNMENT_TIMESTAMPS, }; - use ::test_helpers::{dummy_candidate_receipt, dummy_hash}; use assert_matches::assert_matches; use polkadot_node_primitives::{ approval::v1::{VrfSignature, VrfTranscript}, @@ -622,6 +621,7 @@ pub(crate) mod tests { node_features::FeatureIndex, ExecutorParams, Id as ParaId, IndexedVec, NodeFeatures, SessionInfo, ValidatorId, ValidatorIndex, }; + use polkadot_primitives_test_helpers::{dummy_candidate_receipt, dummy_hash}; use schnellru::{ByLength, LruMap}; pub(crate) use sp_consensus_babe::{ digests::{CompatibleDigestItem, PreDigest, SecondaryVRFPreDigest}, diff --git a/polkadot/node/core/approval-voting/src/tests.rs b/polkadot/node/core/approval-voting/src/tests.rs index 43af8d476a6b..5cbae7f908fc 100644 --- a/polkadot/node/core/approval-voting/src/tests.rs +++ b/polkadot/node/core/approval-voting/src/tests.rs @@ -68,7 +68,7 @@ use super::{ }, }; -use ::test_helpers::{dummy_candidate_receipt, dummy_candidate_receipt_bad_sig}; +use polkadot_primitives_test_helpers::{dummy_candidate_receipt, dummy_candidate_receipt_bad_sig}; const SLOT_DURATION_MILLIS: u64 = 5000; @@ -463,7 +463,8 @@ fn sign_approval_multiple_candidates( .into() } -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; #[derive(Default)] struct HarnessConfigBuilder { @@ -552,7 +553,8 @@ fn test_harness>( config; let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool); let keystore = LocalKeystore::in_memory(); let _ = keystore.sr25519_generate_new( diff --git a/polkadot/node/core/av-store/Cargo.toml b/polkadot/node/core/av-store/Cargo.toml index c5b3c382011b..62f7ff0b61e6 100644 --- a/polkadot/node/core/av-store/Cargo.toml +++ b/polkadot/node/core/av-store/Cargo.toml @@ -17,8 +17,8 @@ thiserror = { workspace = true } gum = { package = "tracing-gum", path = "../../gum" } bitvec = "1.0.0" -parity-scale-codec = { version = "3.6.12", features = ["derive"] } -erasure = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["derive"] } +polkadot-erasure-coding = { path = "../../../erasure-coding" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-overseer = { path = "../../overseer" } @@ -38,4 +38,4 @@ polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } sp-keyring = { path = "../../../../substrate/primitives/keyring" } parking_lot = "0.12.1" -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/polkadot/node/core/av-store/src/lib.rs b/polkadot/node/core/av-store/src/lib.rs index 59a35a6a45a9..7b245c9e3c52 100644 --- a/polkadot/node/core/av-store/src/lib.rs +++ b/polkadot/node/core/av-store/src/lib.rs @@ -26,6 +26,7 @@ use std::{ time::{Duration, SystemTime, SystemTimeError, UNIX_EPOCH}, }; +use codec::{Decode, Encode, Error as CodecError, Input}; use futures::{ channel::{ mpsc::{channel, Receiver as MpscReceiver, Sender as MpscSender}, @@ -34,7 +35,6 @@ use futures::{ future, select, FutureExt, SinkExt, StreamExt, }; use futures_timer::Delay; -use parity_scale_codec::{Decode, Encode, Error as CodecError, Input}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; use sp_consensus::SyncOracle; @@ -354,7 +354,7 @@ pub enum Error { ChainApi(#[from] ChainApiError), #[error(transparent)] - Erasure(#[from] erasure::Error), + Erasure(#[from] polkadot_erasure_coding::Error), #[error(transparent)] Io(#[from] io::Error), @@ -1321,8 +1321,8 @@ fn store_available_data( // Important note: This check below is critical for consensus and the `backing` subsystem relies // on it to ensure candidate validity. - let chunks = erasure::obtain_chunks_v1(n_validators, &available_data)?; - let branches = erasure::branches(chunks.as_ref()); + let chunks = polkadot_erasure_coding::obtain_chunks_v1(n_validators, &available_data)?; + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); if branches.root() != expected_erasure_root { return Err(Error::InvalidErasureRoot) diff --git a/polkadot/node/core/av-store/src/tests.rs b/polkadot/node/core/av-store/src/tests.rs index e87f7cc3b8d6..04a223730bcd 100644 --- a/polkadot/node/core/av-store/src/tests.rs +++ b/polkadot/node/core/av-store/src/tests.rs @@ -21,7 +21,6 @@ use futures::{channel::oneshot, executor, future, Future}; use util::availability_chunks::availability_chunk_index; use self::test_helpers::mock::new_leaf; -use ::test_helpers::TestCandidateBuilder; use parking_lot::Mutex; use polkadot_node_primitives::{AvailableData, BlockData, PoV, Proof}; use polkadot_node_subsystem::{ @@ -35,6 +34,7 @@ use polkadot_primitives::{ node_features, CandidateHash, CandidateReceipt, CoreIndex, GroupIndex, HeadData, Header, PersistedValidationData, ValidatorId, }; +use polkadot_primitives_test_helpers::TestCandidateBuilder; use sp_keyring::Sr25519Keyring; mod columns { @@ -45,7 +45,8 @@ mod columns { const TEST_CONFIG: Config = Config { col_data: columns::DATA, col_meta: columns::META }; -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; #[derive(Clone)] struct TestClock { @@ -128,7 +129,8 @@ fn test_harness>( .try_init(); let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let subsystem = AvailabilityStoreSubsystem::with_pruning_config_and_clock( store, @@ -485,9 +487,11 @@ fn store_pov_and_queries_work() { validation_data: test_state.persisted_validation_data.clone(), }; - let chunks = erasure::obtain_chunks_v1(n_validators as _, &available_data).unwrap(); + let chunks = + polkadot_erasure_coding::obtain_chunks_v1(n_validators as _, &available_data) + .unwrap(); - let branches = erasure::branches(chunks.as_ref()); + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); let (tx, rx) = oneshot::channel(); let block_msg = AvailabilityStoreMessage::StoreAvailableData { @@ -568,9 +572,11 @@ fn store_pov_and_queries_work() { validation_data: test_state.persisted_validation_data.clone(), }; - let chunks = erasure::obtain_chunks_v1(n_validators as _, &available_data).unwrap(); + let chunks = + polkadot_erasure_coding::obtain_chunks_v1(n_validators as _, &available_data) + .unwrap(); - let branches = erasure::branches(chunks.as_ref()); + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); let core_index = CoreIndex(core_index); let (tx, rx) = oneshot::channel(); @@ -667,8 +673,9 @@ fn query_all_chunks_works() { { let chunks_expected = - erasure::obtain_chunks_v1(n_validators as _, &available_data).unwrap(); - let branches = erasure::branches(chunks_expected.as_ref()); + polkadot_erasure_coding::obtain_chunks_v1(n_validators as _, &available_data) + .unwrap(); + let branches = polkadot_erasure_coding::branches(chunks_expected.as_ref()); let (tx, rx) = oneshot::channel(); let block_msg = AvailabilityStoreMessage::StoreAvailableData { candidate_hash: candidate_hash_1, @@ -762,8 +769,9 @@ fn stored_but_not_included_data_is_pruned() { }; let (tx, rx) = oneshot::channel(); - let chunks = erasure::obtain_chunks_v1(n_validators as _, &available_data).unwrap(); - let branches = erasure::branches(chunks.as_ref()); + let chunks = + polkadot_erasure_coding::obtain_chunks_v1(n_validators as _, &available_data).unwrap(); + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); let block_msg = AvailabilityStoreMessage::StoreAvailableData { candidate_hash, @@ -819,8 +827,9 @@ fn stored_data_kept_until_finalized() { let parent = Hash::repeat_byte(2); let block_number = 10; - let chunks = erasure::obtain_chunks_v1(n_validators as _, &available_data).unwrap(); - let branches = erasure::branches(chunks.as_ref()); + let chunks = + polkadot_erasure_coding::obtain_chunks_v1(n_validators as _, &available_data).unwrap(); + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); let (tx, rx) = oneshot::channel(); let block_msg = AvailabilityStoreMessage::StoreAvailableData { @@ -1096,8 +1105,10 @@ fn forkfullness_works() { validation_data: test_state.persisted_validation_data.clone(), }; - let chunks = erasure::obtain_chunks_v1(n_validators as _, &available_data_1).unwrap(); - let branches = erasure::branches(chunks.as_ref()); + let chunks = + polkadot_erasure_coding::obtain_chunks_v1(n_validators as _, &available_data_1) + .unwrap(); + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); let (tx, rx) = oneshot::channel(); let msg = AvailabilityStoreMessage::StoreAvailableData { @@ -1114,8 +1125,10 @@ fn forkfullness_works() { rx.await.unwrap().unwrap(); - let chunks = erasure::obtain_chunks_v1(n_validators as _, &available_data_2).unwrap(); - let branches = erasure::branches(chunks.as_ref()); + let chunks = + polkadot_erasure_coding::obtain_chunks_v1(n_validators as _, &available_data_2) + .unwrap(); + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); let (tx, rx) = oneshot::channel(); let msg = AvailabilityStoreMessage::StoreAvailableData { diff --git a/polkadot/node/core/backing/Cargo.toml b/polkadot/node/core/backing/Cargo.toml index f426f73284e8..ffd6de076889 100644 --- a/polkadot/node/core/backing/Cargo.toml +++ b/polkadot/node/core/backing/Cargo.toml @@ -16,8 +16,8 @@ polkadot-primitives = { path = "../../../primitives" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } -erasure-coding = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" } -statement-table = { package = "polkadot-statement-table", path = "../../../statement-table" } +polkadot-erasure-coding = { path = "../../../erasure-coding" } +polkadot-statement-table = { path = "../../../statement-table" } bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } gum = { package = "tracing-gum", path = "../../gum" } thiserror = { workspace = true } @@ -34,4 +34,4 @@ futures = { version = "0.3.30", features = ["thread-pool"] } assert_matches = "1.4.0" rstest = "0.18.2" polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/polkadot/node/core/backing/src/error.rs b/polkadot/node/core/backing/src/error.rs index 52684f3fe306..568f71402644 100644 --- a/polkadot/node/core/backing/src/error.rs +++ b/polkadot/node/core/backing/src/error.rs @@ -88,7 +88,7 @@ pub enum Error { JoinMultiple(#[source] oneshot::Canceled), #[error("Obtaining erasure chunks failed")] - ObtainErasureChunks(#[from] erasure_coding::Error), + ObtainErasureChunks(#[from] polkadot_erasure_coding::Error), #[error(transparent)] ValidationFailed(#[from] ValidationFailed), diff --git a/polkadot/node/core/backing/src/lib.rs b/polkadot/node/core/backing/src/lib.rs index 2fa8ad29efe5..38e8a93bb048 100644 --- a/polkadot/node/core/backing/src/lib.rs +++ b/polkadot/node/core/backing/src/lib.rs @@ -111,8 +111,7 @@ use polkadot_primitives::{ PvfExecKind, SessionIndex, SigningContext, ValidationCode, ValidatorId, ValidatorIndex, ValidatorSignature, ValidityAttestation, }; -use sp_keystore::KeystorePtr; -use statement_table::{ +use polkadot_statement_table::{ generic::AttestedCandidate as TableAttestedCandidate, v2::{ SignedStatement as TableSignedStatement, Statement as TableStatement, @@ -120,6 +119,7 @@ use statement_table::{ }, Config as TableConfig, Context as TableContextTrait, Table, }; +use sp_keystore::KeystorePtr; use util::{runtime::request_node_features, vstaging::get_disabled_validators_with_fallback}; mod error; diff --git a/polkadot/node/core/backing/src/tests/mod.rs b/polkadot/node/core/backing/src/tests/mod.rs index 00f9e4cd8ff6..bb23c7fbeb24 100644 --- a/polkadot/node/core/backing/src/tests/mod.rs +++ b/polkadot/node/core/backing/src/tests/mod.rs @@ -16,10 +16,6 @@ use self::test_helpers::mock::new_leaf; use super::*; -use ::test_helpers::{ - dummy_candidate_receipt_bad_sig, dummy_collator, dummy_collator_signature, - dummy_committed_candidate_receipt, dummy_hash, validator_pubkeys, -}; use assert_matches::assert_matches; use futures::{future, Future}; use polkadot_node_primitives::{BlockData, InvalidCandidate, SignedFullStatement, Statement}; @@ -36,12 +32,16 @@ use polkadot_primitives::{ node_features, CandidateDescriptor, GroupRotationInfo, HeadData, PersistedValidationData, PvfExecKind, ScheduledCore, SessionIndex, LEGACY_MIN_BACKING_VOTES, }; +use polkadot_primitives_test_helpers::{ + dummy_candidate_receipt_bad_sig, dummy_collator, dummy_collator_signature, + dummy_committed_candidate_receipt, dummy_hash, validator_pubkeys, +}; +use polkadot_statement_table::v2::Misbehavior; use rstest::rstest; use sp_application_crypto::AppCrypto; use sp_keyring::Sr25519Keyring; use sp_keystore::Keystore; use sp_tracing as _; -use statement_table::v2::Misbehavior; use std::{collections::HashMap, time::Duration}; mod prospective_parachains; @@ -164,7 +164,8 @@ impl Default for TestState { } } -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; fn test_harness>( keystore: KeystorePtr, @@ -172,7 +173,8 @@ fn test_harness>( ) { let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let subsystem = async move { if let Err(e) = super::run(context, keystore, Metrics(None)).await { @@ -196,8 +198,9 @@ fn test_harness>( fn make_erasure_root(test: &TestState, pov: PoV, validation_data: PersistedValidationData) -> Hash { let available_data = AvailableData { validation_data, pov: Arc::new(pov) }; - let chunks = erasure_coding::obtain_chunks_v1(test.validators.len(), &available_data).unwrap(); - erasure_coding::branches(&chunks).root() + let chunks = + polkadot_erasure_coding::obtain_chunks_v1(test.validators.len(), &available_data).unwrap(); + polkadot_erasure_coding::branches(&chunks).root() } #[derive(Default, Clone)] @@ -1955,7 +1958,7 @@ fn candidate_backing_reorders_votes() { data[32..36].copy_from_slice(idx.encode().as_slice()); let sig = ValidatorSignature::try_from(data).unwrap(); - statement_table::generic::ValidityAttestation::Implicit(sig) + polkadot_statement_table::generic::ValidityAttestation::Implicit(sig) }; let attested = TableAttestedCandidate { diff --git a/polkadot/node/core/backing/src/tests/prospective_parachains.rs b/polkadot/node/core/backing/src/tests/prospective_parachains.rs index 5ef3a3b15285..74490c84eb18 100644 --- a/polkadot/node/core/backing/src/tests/prospective_parachains.rs +++ b/polkadot/node/core/backing/src/tests/prospective_parachains.rs @@ -1607,7 +1607,8 @@ fn occupied_core_assignment() { let previous_para_id = test_state.chain_ids[1]; // Set the core state to occupied. - let mut candidate_descriptor = ::test_helpers::dummy_candidate_descriptor(Hash::zero()); + let mut candidate_descriptor = + polkadot_primitives_test_helpers::dummy_candidate_descriptor(Hash::zero()); candidate_descriptor.para_id = previous_para_id; test_state.availability_cores[0] = CoreState::Occupied(OccupiedCore { group_responsible: Default::default(), diff --git a/polkadot/node/core/bitfield-signing/Cargo.toml b/polkadot/node/core/bitfield-signing/Cargo.toml index 0663e0f1b699..335e733987b0 100644 --- a/polkadot/node/core/bitfield-signing/Cargo.toml +++ b/polkadot/node/core/bitfield-signing/Cargo.toml @@ -21,4 +21,4 @@ thiserror = { workspace = true } [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/polkadot/node/core/bitfield-signing/src/tests.rs b/polkadot/node/core/bitfield-signing/src/tests.rs index 0e61e6086d28..eeaa524d1c63 100644 --- a/polkadot/node/core/bitfield-signing/src/tests.rs +++ b/polkadot/node/core/bitfield-signing/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use futures::{executor::block_on, pin_mut, StreamExt}; use polkadot_node_subsystem::messages::{AllMessages, RuntimeApiMessage, RuntimeApiRequest}; use polkadot_primitives::{CandidateHash, OccupiedCore}; -use test_helpers::dummy_candidate_descriptor; +use polkadot_primitives_test_helpers::dummy_candidate_descriptor; fn occupied_core(para_id: u32, candidate_hash: CandidateHash) -> CoreState { CoreState::Occupied(OccupiedCore { diff --git a/polkadot/node/core/candidate-validation/Cargo.toml b/polkadot/node/core/candidate-validation/Cargo.toml index e79b3a734b8f..a0b25e6c25f9 100644 --- a/polkadot/node/core/candidate-validation/Cargo.toml +++ b/polkadot/node/core/candidate-validation/Cargo.toml @@ -16,7 +16,7 @@ futures-timer = "3.0.2" gum = { package = "tracing-gum", path = "../../gum" } sp-maybe-compressed-blob = { package = "sp-maybe-compressed-blob", path = "../../../../substrate/primitives/maybe-compressed-blob" } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } polkadot-primitives = { path = "../../../primitives" } polkadot-parachain-primitives = { path = "../../../parachain" } @@ -35,4 +35,4 @@ futures = { version = "0.3.30", features = ["thread-pool"] } assert_matches = "1.4.0" polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } sp-core = { path = "../../../../substrate/primitives/core" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/polkadot/node/core/candidate-validation/src/lib.rs b/polkadot/node/core/candidate-validation/src/lib.rs index 08881dad1961..76619bd391f2 100644 --- a/polkadot/node/core/candidate-validation/src/lib.rs +++ b/polkadot/node/core/candidate-validation/src/lib.rs @@ -53,7 +53,7 @@ use polkadot_primitives::{ ValidationCodeHash, }; -use parity_scale_codec::Encode; +use codec::Encode; use futures::{channel::oneshot, prelude::*, stream::FuturesUnordered}; diff --git a/polkadot/node/core/candidate-validation/src/tests.rs b/polkadot/node/core/candidate-validation/src/tests.rs index e492d51e239e..491ed7a335d8 100644 --- a/polkadot/node/core/candidate-validation/src/tests.rs +++ b/polkadot/node/core/candidate-validation/src/tests.rs @@ -15,14 +15,13 @@ // along with Polkadot. If not, see . use super::*; -use ::test_helpers::{dummy_hash, make_valid_candidate_descriptor}; use assert_matches::assert_matches; use futures::executor; use polkadot_node_core_pvf::PrepareError; use polkadot_node_subsystem::messages::AllMessages; -use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::reexports::SubsystemContext; use polkadot_primitives::{HeadData, Id as ParaId, UpwardMessage}; +use polkadot_primitives_test_helpers::{dummy_hash, make_valid_candidate_descriptor}; use sp_core::testing::TaskExecutor; use sp_keyring::Sr25519Keyring; @@ -47,8 +46,10 @@ fn correctly_checks_included_assumption() { ); let pool = TaskExecutor::new(); - let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + let (mut ctx, mut ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let (check_fut, check_result) = check_assumption_validation_data( ctx.sender(), @@ -119,8 +120,10 @@ fn correctly_checks_timed_out_assumption() { ); let pool = TaskExecutor::new(); - let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + let (mut ctx, mut ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let (check_fut, check_result) = check_assumption_validation_data( ctx.sender(), @@ -189,8 +192,10 @@ fn check_is_bad_request_if_no_validation_data() { ); let pool = TaskExecutor::new(); - let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + let (mut ctx, mut ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let (check_fut, check_result) = check_assumption_validation_data( ctx.sender(), @@ -243,8 +248,10 @@ fn check_is_bad_request_if_no_validation_code() { ); let pool = TaskExecutor::new(); - let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + let (mut ctx, mut ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let (check_fut, check_result) = check_assumption_validation_data( ctx.sender(), @@ -309,8 +316,10 @@ fn check_does_not_match() { ); let pool = TaskExecutor::new(); - let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + let (mut ctx, mut ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let (check_fut, check_result) = check_assumption_validation_data( ctx.sender(), @@ -850,7 +859,10 @@ fn candidate_validation_code_mismatch_is_invalid() { let candidate_receipt = CandidateReceipt { descriptor, commitments_hash: Hash::zero() }; let pool = TaskExecutor::new(); - let (_ctx, _ctx_handle) = test_helpers::make_subsystem_context::(pool.clone()); + let (_ctx, _ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let v = executor::block_on(validate_candidate_exhaustive( MockValidateCandidateBackend::with_hardcoded_result(Err(ValidationError::Invalid( @@ -960,7 +972,10 @@ fn code_decompression_failure_is_error() { let candidate_receipt = CandidateReceipt { descriptor, commitments_hash: Hash::zero() }; let pool = TaskExecutor::new(); - let (_ctx, _ctx_handle) = test_helpers::make_subsystem_context::(pool.clone()); + let (_ctx, _ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let v = executor::block_on(validate_candidate_exhaustive( MockValidateCandidateBackend::with_hardcoded_result(Ok(validation_result)), @@ -1012,7 +1027,10 @@ fn pov_decompression_failure_is_invalid() { let candidate_receipt = CandidateReceipt { descriptor, commitments_hash: Hash::zero() }; let pool = TaskExecutor::new(); - let (_ctx, _ctx_handle) = test_helpers::make_subsystem_context::(pool.clone()); + let (_ctx, _ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let v = executor::block_on(validate_candidate_exhaustive( MockValidateCandidateBackend::with_hardcoded_result(Ok(validation_result)), @@ -1062,8 +1080,10 @@ fn precheck_works() { let validation_code_hash = validation_code.hash(); let pool = TaskExecutor::new(); - let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + let (mut ctx, mut ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let (check_fut, check_result) = precheck_pvf( ctx.sender(), @@ -1124,8 +1144,10 @@ fn precheck_invalid_pvf_blob_compression() { let validation_code_hash = validation_code.hash(); let pool = TaskExecutor::new(); - let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + let (mut ctx, mut ctx_handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AllMessages, + _, + >(pool.clone()); let (check_fut, check_result) = precheck_pvf( ctx.sender(), @@ -1183,7 +1205,9 @@ fn precheck_properly_classifies_outcomes() { let pool = TaskExecutor::new(); let (mut ctx, mut ctx_handle) = - test_helpers::make_subsystem_context::(pool.clone()); + polkadot_node_subsystem_test_helpers::make_subsystem_context::( + pool.clone(), + ); let (check_fut, check_result) = precheck_pvf( ctx.sender(), diff --git a/polkadot/node/core/chain-api/Cargo.toml b/polkadot/node/core/chain-api/Cargo.toml index bd8531c20784..c58024876b9c 100644 --- a/polkadot/node/core/chain-api/Cargo.toml +++ b/polkadot/node/core/chain-api/Cargo.toml @@ -21,7 +21,7 @@ sc-consensus-babe = { path = "../../../../substrate/client/consensus/babe" } [dev-dependencies] futures = { version = "0.3.30", features = ["thread-pool"] } maplit = "1.0.2" -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } polkadot-node-primitives = { path = "../../primitives" } polkadot-primitives = { path = "../../../primitives" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } diff --git a/polkadot/node/core/chain-api/src/tests.rs b/polkadot/node/core/chain-api/src/tests.rs index eae8f6fa4ac5..4e85affc540f 100644 --- a/polkadot/node/core/chain-api/src/tests.rs +++ b/polkadot/node/core/chain-api/src/tests.rs @@ -16,8 +16,8 @@ use super::*; +use codec::Encode; use futures::{channel::oneshot, future::BoxFuture}; -use parity_scale_codec::Encode; use std::collections::BTreeMap; use polkadot_node_primitives::BlockWeight; diff --git a/polkadot/node/core/chain-selection/Cargo.toml b/polkadot/node/core/chain-selection/Cargo.toml index b58053b5417e..2aa929653ccc 100644 --- a/polkadot/node/core/chain-selection/Cargo.toml +++ b/polkadot/node/core/chain-selection/Cargo.toml @@ -19,7 +19,7 @@ polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } kvdb = "0.13.0" thiserror = { workspace = true } -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } diff --git a/polkadot/node/core/chain-selection/src/db_backend/v1.rs b/polkadot/node/core/chain-selection/src/db_backend/v1.rs index 7c7144bb763d..8831b1e3c36c 100644 --- a/polkadot/node/core/chain-selection/src/db_backend/v1.rs +++ b/polkadot/node/core/chain-selection/src/db_backend/v1.rs @@ -40,7 +40,7 @@ use crate::{ use polkadot_node_primitives::BlockWeight; use polkadot_primitives::{BlockNumber, Hash}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; use std::sync::Arc; diff --git a/polkadot/node/core/chain-selection/src/lib.rs b/polkadot/node/core/chain-selection/src/lib.rs index 07c245e839bf..6c091b02709b 100644 --- a/polkadot/node/core/chain-selection/src/lib.rs +++ b/polkadot/node/core/chain-selection/src/lib.rs @@ -26,8 +26,8 @@ use polkadot_node_subsystem::{ use polkadot_node_subsystem_util::database::Database; use polkadot_primitives::{BlockNumber, ConsensusLog, Hash, Header}; +use codec::Error as CodecError; use futures::{channel::oneshot, future::Either, prelude::*}; -use parity_scale_codec::Error as CodecError; use std::{ sync::Arc, diff --git a/polkadot/node/core/chain-selection/src/tests.rs b/polkadot/node/core/chain-selection/src/tests.rs index 1fe87f04cd58..2b1e1196ede3 100644 --- a/polkadot/node/core/chain-selection/src/tests.rs +++ b/polkadot/node/core/chain-selection/src/tests.rs @@ -30,8 +30,8 @@ use std::{ }; use assert_matches::assert_matches; +use codec::Encode; use futures::channel::oneshot; -use parity_scale_codec::Encode; use parking_lot::Mutex; use sp_core::testing::TaskExecutor; @@ -229,13 +229,15 @@ impl Clock for TestClock { const TEST_STAGNANT_INTERVAL: Duration = Duration::from_millis(20); -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; fn test_harness>( test: impl FnOnce(TestBackend, TestClock, VirtualOverseer) -> T, ) { let pool = TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool); let backend = TestBackend::default(); let clock = TestClock::new(0); diff --git a/polkadot/node/core/dispute-coordinator/Cargo.toml b/polkadot/node/core/dispute-coordinator/Cargo.toml index 8bd510697c91..2c08cfa9b1ef 100644 --- a/polkadot/node/core/dispute-coordinator/Cargo.toml +++ b/polkadot/node/core/dispute-coordinator/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] futures = "0.3.30" gum = { package = "tracing-gum", path = "../../gum" } -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } kvdb = "0.13.0" thiserror = { workspace = true } schnellru = "0.2.1" @@ -33,7 +33,7 @@ sp-keyring = { path = "../../../../substrate/primitives/keyring" } sp-core = { path = "../../../../substrate/primitives/core" } sp-keystore = { path = "../../../../substrate/primitives/keystore" } assert_matches = "1.4.0" -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } futures-timer = "3.0.2" sp-application-crypto = { path = "../../../../substrate/primitives/application-crypto" } sp-tracing = { path = "../../../../substrate/primitives/tracing" } diff --git a/polkadot/node/core/dispute-coordinator/src/db/v1.rs b/polkadot/node/core/dispute-coordinator/src/db/v1.rs index 4950765cf510..0101791550ee 100644 --- a/polkadot/node/core/dispute-coordinator/src/db/v1.rs +++ b/polkadot/node/core/dispute-coordinator/src/db/v1.rs @@ -31,7 +31,7 @@ use polkadot_primitives::{ use std::sync::Arc; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use crate::{ backend::{Backend, BackendWriteOp, OverlayedBackend}, @@ -258,7 +258,7 @@ pub enum Error { #[error(transparent)] Io(#[from] std::io::Error), #[error(transparent)] - Codec(#[from] parity_scale_codec::Error), + Codec(#[from] codec::Error), } impl From for crate::error::Error { @@ -375,9 +375,9 @@ fn load_cleaned_votes_watermark( mod tests { use super::*; - use ::test_helpers::{dummy_candidate_receipt, dummy_hash}; use polkadot_node_primitives::DISPUTE_WINDOW; use polkadot_primitives::{Hash, Id as ParaId}; + use polkadot_primitives_test_helpers::{dummy_candidate_receipt, dummy_hash}; fn make_db() -> DbBackend { let db = kvdb_memorydb::create(1); diff --git a/polkadot/node/core/dispute-coordinator/src/error.rs b/polkadot/node/core/dispute-coordinator/src/error.rs index cbda3dc1d121..94bc8e9c9497 100644 --- a/polkadot/node/core/dispute-coordinator/src/error.rs +++ b/polkadot/node/core/dispute-coordinator/src/error.rs @@ -21,7 +21,7 @@ use polkadot_node_subsystem::{errors::ChainApiError, SubsystemError}; use polkadot_node_subsystem_util::runtime; use crate::{db, participation, LOG_TARGET}; -use parity_scale_codec::Error as CodecError; +use codec::Error as CodecError; pub type Result = std::result::Result; pub type FatalResult = std::result::Result; diff --git a/polkadot/node/core/dispute-coordinator/src/participation/queues/tests.rs b/polkadot/node/core/dispute-coordinator/src/participation/queues/tests.rs index 63bfc1d7d026..9176d00b2f5c 100644 --- a/polkadot/node/core/dispute-coordinator/src/participation/queues/tests.rs +++ b/polkadot/node/core/dispute-coordinator/src/participation/queues/tests.rs @@ -15,9 +15,9 @@ // along with Polkadot. If not, see . use crate::{metrics::Metrics, ParticipationPriority}; -use ::test_helpers::{dummy_candidate_receipt, dummy_hash}; use assert_matches::assert_matches; use polkadot_primitives::{BlockNumber, Hash}; +use polkadot_primitives_test_helpers::{dummy_candidate_receipt, dummy_hash}; use super::{CandidateComparator, ParticipationRequest, QueueError, Queues}; diff --git a/polkadot/node/core/dispute-coordinator/src/participation/tests.rs b/polkadot/node/core/dispute-coordinator/src/participation/tests.rs index 1316508e84cf..a80553828ac6 100644 --- a/polkadot/node/core/dispute-coordinator/src/participation/tests.rs +++ b/polkadot/node/core/dispute-coordinator/src/participation/tests.rs @@ -22,10 +22,7 @@ use std::{sync::Arc, time::Duration}; use sp_core::testing::TaskExecutor; use super::*; -use ::test_helpers::{ - dummy_candidate_commitments, dummy_candidate_receipt_bad_sig, dummy_digest, dummy_hash, -}; -use parity_scale_codec::Encode; +use codec::Encode; use polkadot_node_primitives::{AvailableData, BlockData, InvalidCandidate, PoV}; use polkadot_node_subsystem::{ messages::{ @@ -40,6 +37,9 @@ use polkadot_node_subsystem_test_helpers::{ use polkadot_primitives::{ BlakeTwo256, CandidateCommitments, HashT, Header, PersistedValidationData, ValidationCode, }; +use polkadot_primitives_test_helpers::{ + dummy_candidate_commitments, dummy_candidate_receipt_bad_sig, dummy_digest, dummy_hash, +}; type VirtualOverseer = TestSubsystemContextHandle; diff --git a/polkadot/node/core/dispute-coordinator/src/scraping/tests.rs b/polkadot/node/core/dispute-coordinator/src/scraping/tests.rs index 726dda596d7b..ed2400387ef7 100644 --- a/polkadot/node/core/dispute-coordinator/src/scraping/tests.rs +++ b/polkadot/node/core/dispute-coordinator/src/scraping/tests.rs @@ -18,11 +18,10 @@ use std::time::Duration; use assert_matches::assert_matches; +use codec::Encode; use futures::future::join; -use parity_scale_codec::Encode; use sp_core::testing::TaskExecutor; -use ::test_helpers::{dummy_collator, dummy_collator_signature, dummy_hash}; use polkadot_node_primitives::DISPUTE_CANDIDATE_LIFETIME_AFTER_FINALIZATION; use polkadot_node_subsystem::{ messages::{ @@ -40,6 +39,7 @@ use polkadot_primitives::{ BlakeTwo256, BlockNumber, CandidateDescriptor, CandidateEvent, CandidateReceipt, CoreIndex, GroupIndex, Hash, HashT, HeadData, Id as ParaId, }; +use polkadot_primitives_test_helpers::{dummy_collator, dummy_collator_signature, dummy_hash}; use crate::{scraping::Inclusions, LOG_TARGET}; diff --git a/polkadot/node/core/dispute-coordinator/src/tests.rs b/polkadot/node/core/dispute-coordinator/src/tests.rs index 13cf2df88223..f97a625a9528 100644 --- a/polkadot/node/core/dispute-coordinator/src/tests.rs +++ b/polkadot/node/core/dispute-coordinator/src/tests.rs @@ -51,7 +51,6 @@ use sp_core::{sr25519::Pair, testing::TaskExecutor, Pair as PairT}; use sp_keyring::Sr25519Keyring; use sp_keystore::{Keystore, KeystorePtr}; -use ::test_helpers::{dummy_candidate_receipt_bad_sig, dummy_digest, dummy_hash}; use polkadot_node_primitives::{Timestamp, ACTIVE_DURATION_SECS}; use polkadot_node_subsystem::{ messages::{AllMessages, BlockDescription, RuntimeApiMessage, RuntimeApiRequest}, @@ -67,6 +66,7 @@ use polkadot_primitives::{ SessionInfo, SigningContext, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature, }; +use polkadot_primitives_test_helpers::{dummy_candidate_receipt_bad_sig, dummy_digest, dummy_hash}; use crate::{ backend::Backend, diff --git a/polkadot/node/core/prospective-parachains/Cargo.toml b/polkadot/node/core/prospective-parachains/Cargo.toml index 5b4f12a5fbda..f3193153be89 100644 --- a/polkadot/node/core/prospective-parachains/Cargo.toml +++ b/polkadot/node/core/prospective-parachains/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] futures = "0.3.30" gum = { package = "tracing-gum", path = "../../gum" } -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } thiserror = { workspace = true } fatality = "0.1.1" bitvec = "1" diff --git a/polkadot/node/core/prospective-parachains/src/tests.rs b/polkadot/node/core/prospective-parachains/src/tests.rs index 4bc473672788..d2fc3cbd3623 100644 --- a/polkadot/node/core/prospective-parachains/src/tests.rs +++ b/polkadot/node/core/prospective-parachains/src/tests.rs @@ -42,7 +42,8 @@ const ASYNC_BACKING_DISABLED_ERROR: RuntimeApiError = const MAX_POV_SIZE: u32 = 1_000_000; -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; fn dummy_constraints( min_relay_parent_number: BlockNumber, @@ -97,7 +98,8 @@ fn test_harness>( ) -> View { let pool = sp_core::testing::TaskExecutor::new(); - let (mut context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (mut context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let mut view = View::new(); let subsystem = async move { diff --git a/polkadot/node/core/provisioner/Cargo.toml b/polkadot/node/core/provisioner/Cargo.toml index d19783212644..a81d22c6f828 100644 --- a/polkadot/node/core/provisioner/Cargo.toml +++ b/polkadot/node/core/provisioner/Cargo.toml @@ -26,5 +26,5 @@ schnellru = "0.2.1" sp-application-crypto = { path = "../../../../substrate/primitives/application-crypto" } sp-keystore = { path = "../../../../substrate/primitives/keystore" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } rstest = "0.18.2" diff --git a/polkadot/node/core/provisioner/src/disputes/prioritized_selection/tests.rs b/polkadot/node/core/provisioner/src/disputes/prioritized_selection/tests.rs index f6c49e52eeb9..ecb7aac78396 100644 --- a/polkadot/node/core/provisioner/src/disputes/prioritized_selection/tests.rs +++ b/polkadot/node/core/provisioner/src/disputes/prioritized_selection/tests.rs @@ -29,7 +29,6 @@ use polkadot_primitives::{ CandidateHash, DisputeState, InvalidDisputeStatementKind, SessionIndex, ValidDisputeStatementKind, ValidatorSignature, }; -use test_helpers; // // Unit tests for various functions @@ -428,7 +427,7 @@ impl TestDisputes { let onchain_votes_count = self.validators_count * 80 / 100; let session_idx = 0; let lf = leaf(); - let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash); + let dummy_receipt = polkadot_primitives_test_helpers::dummy_candidate_receipt(lf.hash); for _ in 0..dispute_count { let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Active); self.add_offchain_dispute(d, local_votes_count, dummy_receipt.clone()); @@ -446,7 +445,7 @@ impl TestDisputes { let onchain_votes_count = self.validators_count * 40 / 100; let session_idx = 1; let lf = leaf(); - let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash); + let dummy_receipt = polkadot_primitives_test_helpers::dummy_candidate_receipt(lf.hash); for _ in 0..dispute_count { let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Active); self.add_offchain_dispute(d, local_votes_count, dummy_receipt.clone()); @@ -463,7 +462,7 @@ impl TestDisputes { let local_votes_count = self.validators_count * 90 / 100; let session_idx = 2; let lf = leaf(); - let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash); + let dummy_receipt = polkadot_primitives_test_helpers::dummy_candidate_receipt(lf.hash); for _ in 0..dispute_count { let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Confirmed); self.add_offchain_dispute(d, local_votes_count, dummy_receipt.clone()); @@ -479,7 +478,7 @@ impl TestDisputes { let onchain_votes_count = self.validators_count * 75 / 100; let session_idx = 3; let lf = leaf(); - let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash); + let dummy_receipt = polkadot_primitives_test_helpers::dummy_candidate_receipt(lf.hash); for _ in 0..dispute_count { let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::ConcludedFor(0)); self.add_offchain_dispute(d, local_votes_count, dummy_receipt.clone()); @@ -495,7 +494,7 @@ impl TestDisputes { let local_votes_count = self.validators_count * 90 / 100; let session_idx = 4; let lf = leaf(); - let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash); + let dummy_receipt = polkadot_primitives_test_helpers::dummy_candidate_receipt(lf.hash); for _ in 0..dispute_count { let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::ConcludedFor(0)); self.add_offchain_dispute(d, local_votes_count, dummy_receipt.clone()); @@ -511,7 +510,7 @@ impl TestDisputes { let onchain_votes_count = self.validators_count * 10 / 100; let session_idx = 5; let lf = leaf(); - let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash); + let dummy_receipt = polkadot_primitives_test_helpers::dummy_candidate_receipt(lf.hash); for _ in 0..dispute_count { let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Active); self.add_offchain_dispute(d, local_votes_count, dummy_receipt.clone()); @@ -528,7 +527,7 @@ impl TestDisputes { let local_votes_count = self.validators_count * 10 / 100; let session_idx = 6; let lf = leaf(); - let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash); + let dummy_receipt = polkadot_primitives_test_helpers::dummy_candidate_receipt(lf.hash); for _ in 0..dispute_count { let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Active); self.add_offchain_dispute(d, local_votes_count, dummy_receipt.clone()); @@ -547,7 +546,7 @@ impl TestDisputes { .map(|idx| { ( ValidatorIndex(idx as u32), - (statement_kind.clone(), test_helpers::dummy_signature()), + (statement_kind.clone(), polkadot_primitives_test_helpers::dummy_signature()), ) }) .collect::>() diff --git a/polkadot/node/core/provisioner/src/tests.rs b/polkadot/node/core/provisioner/src/tests.rs index d463b7f16633..0d3675777cbf 100644 --- a/polkadot/node/core/provisioner/src/tests.rs +++ b/polkadot/node/core/provisioner/src/tests.rs @@ -15,9 +15,9 @@ // along with Polkadot. If not, see . use super::*; -use ::test_helpers::{dummy_candidate_descriptor, dummy_hash}; use bitvec::bitvec; use polkadot_primitives::{OccupiedCore, ScheduledCore}; +use polkadot_primitives_test_helpers::{dummy_candidate_descriptor, dummy_hash}; const MOCK_GROUP_SIZE: usize = 5; @@ -244,7 +244,6 @@ mod select_candidates { super::*, build_occupied_core, common::test_harness, default_bitvec, occupied_core, scheduled_core, MOCK_GROUP_SIZE, }; - use ::test_helpers::{dummy_candidate_descriptor, dummy_hash}; use futures::channel::mpsc; use polkadot_node_subsystem::messages::{ AllMessages, RuntimeApiMessage, @@ -257,6 +256,7 @@ mod select_candidates { use polkadot_primitives::{ BlockNumber, CandidateCommitments, CommittedCandidateReceipt, PersistedValidationData, }; + use polkadot_primitives_test_helpers::{dummy_candidate_descriptor, dummy_hash}; use rstest::rstest; use std::ops::Not; use CoreState::{Free, Scheduled}; diff --git a/polkadot/node/core/pvf-checker/Cargo.toml b/polkadot/node/core/pvf-checker/Cargo.toml index 91b12b868097..6dec407e2d2d 100644 --- a/polkadot/node/core/pvf-checker/Cargo.toml +++ b/polkadot/node/core/pvf-checker/Cargo.toml @@ -28,6 +28,6 @@ sp-runtime = { path = "../../../../substrate/primitives/runtime" } sc-keystore = { path = "../../../../substrate/client/keystore" } sp-keyring = { path = "../../../../substrate/primitives/keyring" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } sp-application-crypto = { path = "../../../../substrate/primitives/application-crypto" } futures-timer = "3.0.2" diff --git a/polkadot/node/core/pvf-checker/src/tests.rs b/polkadot/node/core/pvf-checker/src/tests.rs index b2365fe53e52..e12a44ddd2af 100644 --- a/polkadot/node/core/pvf-checker/src/tests.rs +++ b/polkadot/node/core/pvf-checker/src/tests.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use ::test_helpers::{dummy_digest, dummy_hash, validator_pubkeys}; use futures::{channel::oneshot, future::BoxFuture, prelude::*}; use polkadot_node_subsystem::{ messages::{ @@ -30,6 +29,7 @@ use polkadot_primitives::{ BlockNumber, Hash, Header, PvfCheckStatement, SessionIndex, ValidationCode, ValidationCodeHash, ValidatorId, }; +use polkadot_primitives_test_helpers::{dummy_digest, dummy_hash, validator_pubkeys}; use sp_application_crypto::AppCrypto; use sp_core::testing::TaskExecutor; use sp_keyring::Sr25519Keyring; diff --git a/polkadot/node/core/pvf/Cargo.toml b/polkadot/node/core/pvf/Cargo.toml index ba9954a10668..8aebe0b4c3f0 100644 --- a/polkadot/node/core/pvf/Cargo.toml +++ b/polkadot/node/core/pvf/Cargo.toml @@ -25,7 +25,7 @@ tempfile = "3.3.0" thiserror = { workspace = true } tokio = { version = "1.24.2", features = ["fs", "process"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [ "derive", ] } @@ -56,8 +56,8 @@ polkadot-node-core-pvf-common = { path = "common", features = ["test-utils"] } polkadot-node-core-pvf = { path = "", features = ["test-utils"] } rococo-runtime = { path = "../../../runtime/rococo" } -adder = { package = "test-parachain-adder", path = "../../../parachain/test-parachains/adder" } -halt = { package = "test-parachain-halt", path = "../../../parachain/test-parachains/halt" } +test-parachain-adder = { path = "../../../parachain/test-parachains/adder" } +test-parachain-halt = { path = "../../../parachain/test-parachains/halt" } [target.'cfg(target_os = "linux")'.dev-dependencies] libc = "0.2.153" diff --git a/polkadot/node/core/pvf/common/Cargo.toml b/polkadot/node/core/pvf/common/Cargo.toml index 5ad7409cc6c7..491f6cc49642 100644 --- a/polkadot/node/core/pvf/common/Cargo.toml +++ b/polkadot/node/core/pvf/common/Cargo.toml @@ -17,7 +17,7 @@ libc = "0.2.152" nix = { version = "0.28.0", features = ["resource", "sched"] } thiserror = { workspace = true } -parity-scale-codec = { version = "3.6.12", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [ "derive", ] } diff --git a/polkadot/node/core/pvf/common/src/error.rs b/polkadot/node/core/pvf/common/src/error.rs index adeb40c0b195..7ee05448d3c5 100644 --- a/polkadot/node/core/pvf/common/src/error.rs +++ b/polkadot/node/core/pvf/common/src/error.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use crate::prepare::{PrepareSuccess, PrepareWorkerSuccess}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; pub use sc_executor_common::error::Error as ExecuteError; /// Result of PVF preparation from a worker, with checksum of the compiled PVF and stats of the diff --git a/polkadot/node/core/pvf/common/src/execute.rs b/polkadot/node/core/pvf/common/src/execute.rs index ae6096cacec4..46862f9f80b6 100644 --- a/polkadot/node/core/pvf/common/src/execute.rs +++ b/polkadot/node/core/pvf/common/src/execute.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use crate::error::InternalValidationError; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_parachain_primitives::primitives::ValidationResult; use polkadot_primitives::ExecutorParams; use std::time::Duration; diff --git a/polkadot/node/core/pvf/common/src/executor_interface.rs b/polkadot/node/core/pvf/common/src/executor_interface.rs index 252e611db8a4..87491e70c5f2 100644 --- a/polkadot/node/core/pvf/common/src/executor_interface.rs +++ b/polkadot/node/core/pvf/common/src/executor_interface.rs @@ -372,7 +372,7 @@ impl sp_core::traits::ReadRuntimeVersion for ReadRuntimeVersion { .map_err(|e| format!("Failed to read the static section from the PVF blob: {:?}", e))? { Some(version) => { - use parity_scale_codec::Encode; + use codec::Encode; Ok(version.encode()) }, None => Err("runtime version section is not found".to_string()), diff --git a/polkadot/node/core/pvf/common/src/lib.rs b/polkadot/node/core/pvf/common/src/lib.rs index 0cd928201639..30d0aa445281 100644 --- a/polkadot/node/core/pvf/common/src/lib.rs +++ b/polkadot/node/core/pvf/common/src/lib.rs @@ -32,7 +32,7 @@ pub use sp_tracing; const LOG_TARGET: &str = "parachain::pvf-common"; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use std::{ io::{self, Read, Write}, mem, diff --git a/polkadot/node/core/pvf/common/src/prepare.rs b/polkadot/node/core/pvf/common/src/prepare.rs index 28ab682ec136..64e7f3d6bcf4 100644 --- a/polkadot/node/core/pvf/common/src/prepare.rs +++ b/polkadot/node/core/pvf/common/src/prepare.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use std::path::PathBuf; /// Result from prepare worker if successful. diff --git a/polkadot/node/core/pvf/common/src/pvf.rs b/polkadot/node/core/pvf/common/src/pvf.rs index 5f248f49b9a3..e2ac36a2406a 100644 --- a/polkadot/node/core/pvf/common/src/pvf.rs +++ b/polkadot/node/core/pvf/common/src/pvf.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use crate::prepare::PrepareJobKind; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_parachain_primitives::primitives::ValidationCodeHash; use polkadot_primitives::ExecutorParams; use std::{fmt, sync::Arc, time::Duration}; diff --git a/polkadot/node/core/pvf/common/src/worker/mod.rs b/polkadot/node/core/pvf/common/src/worker/mod.rs index 67e7bece407d..70dcf055a262 100644 --- a/polkadot/node/core/pvf/common/src/worker/mod.rs +++ b/polkadot/node/core/pvf/common/src/worker/mod.rs @@ -21,10 +21,10 @@ pub mod security; use crate::{ framed_recv_blocking, framed_send_blocking, SecurityStatus, WorkerHandshake, LOG_TARGET, }; +use codec::{Decode, Encode}; use cpu_time::ProcessTime; use futures::never::Never; use nix::{errno::Errno, sys::resource::Usage}; -use parity_scale_codec::{Decode, Encode}; use std::{ any::Any, fmt::{self}, diff --git a/polkadot/node/core/pvf/execute-worker/Cargo.toml b/polkadot/node/core/pvf/execute-worker/Cargo.toml index ac90fac4d57a..cf5b873e29d7 100644 --- a/polkadot/node/core/pvf/execute-worker/Cargo.toml +++ b/polkadot/node/core/pvf/execute-worker/Cargo.toml @@ -16,7 +16,7 @@ cfg-if = "1.0" nix = { version = "0.28.0", features = ["process", "resource", "sched"] } libc = "0.2.152" -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } polkadot-node-core-pvf-common = { path = "../common" } polkadot-parachain-primitives = { path = "../../../../parachain" } diff --git a/polkadot/node/core/pvf/execute-worker/src/lib.rs b/polkadot/node/core/pvf/execute-worker/src/lib.rs index 55f5290bd87e..35858ab36cec 100644 --- a/polkadot/node/core/pvf/execute-worker/src/lib.rs +++ b/polkadot/node/core/pvf/execute-worker/src/lib.rs @@ -27,6 +27,7 @@ pub use polkadot_node_core_pvf_common::{ // separate spawned processes. Run with e.g. `RUST_LOG=parachain::pvf-execute-worker=trace`. const LOG_TARGET: &str = "parachain::pvf-execute-worker"; +use codec::{Decode, Encode}; use cpu_time::ProcessTime; use nix::{ errno::Errno, @@ -36,7 +37,6 @@ use nix::{ }, unistd::{ForkResult, Pid}, }; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_core_pvf_common::{ error::InternalValidationError, execute::{Handshake, JobError, JobResponse, JobResult, WorkerError, WorkerResponse}, diff --git a/polkadot/node/core/pvf/prepare-worker/Cargo.toml b/polkadot/node/core/pvf/prepare-worker/Cargo.toml index 1850a2048907..f7daa0d7a89c 100644 --- a/polkadot/node/core/pvf/prepare-worker/Cargo.toml +++ b/polkadot/node/core/pvf/prepare-worker/Cargo.toml @@ -20,7 +20,7 @@ tikv-jemalloc-ctl = { version = "0.5.0", optional = true } tikv-jemallocator = { version = "0.5.0", optional = true } nix = { version = "0.28.0", features = ["process", "resource", "sched"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } polkadot-node-core-pvf-common = { path = "../common" } polkadot-primitives = { path = "../../../../primitives" } diff --git a/polkadot/node/core/pvf/prepare-worker/src/lib.rs b/polkadot/node/core/pvf/prepare-worker/src/lib.rs index d1b218f48ae8..ef33d11720eb 100644 --- a/polkadot/node/core/pvf/prepare-worker/src/lib.rs +++ b/polkadot/node/core/pvf/prepare-worker/src/lib.rs @@ -39,7 +39,7 @@ use polkadot_node_core_pvf_common::{ worker::{pipe2_cloexec, PipeFd, WorkerInfo}, }; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_core_pvf_common::{ error::{PrepareError, PrepareWorkerResult}, executor_interface::create_runtime_from_artifact_bytes, diff --git a/polkadot/node/core/pvf/src/execute/worker_interface.rs b/polkadot/node/core/pvf/src/execute/worker_interface.rs index 9dcadfb4c2a7..d15d7c15426e 100644 --- a/polkadot/node/core/pvf/src/execute/worker_interface.rs +++ b/polkadot/node/core/pvf/src/execute/worker_interface.rs @@ -24,9 +24,9 @@ use crate::{ }, LOG_TARGET, }; +use codec::{Decode, Encode}; use futures::FutureExt; use futures_timer::Delay; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_core_pvf_common::{ error::InternalValidationError, execute::{Handshake, WorkerError, WorkerResponse}, diff --git a/polkadot/node/core/pvf/src/prepare/worker_interface.rs b/polkadot/node/core/pvf/src/prepare/worker_interface.rs index d64ee1510cad..5c4245d76315 100644 --- a/polkadot/node/core/pvf/src/prepare/worker_interface.rs +++ b/polkadot/node/core/pvf/src/prepare/worker_interface.rs @@ -25,7 +25,7 @@ use crate::{ }, LOG_TARGET, }; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_core_pvf_common::{ error::{PrepareError, PrepareResult, PrepareWorkerResult}, prepare::{PrepareStats, PrepareSuccess, PrepareWorkerSuccess}, diff --git a/polkadot/node/core/pvf/src/worker_interface.rs b/polkadot/node/core/pvf/src/worker_interface.rs index 93fffc806622..e63778d4692f 100644 --- a/polkadot/node/core/pvf/src/worker_interface.rs +++ b/polkadot/node/core/pvf/src/worker_interface.rs @@ -17,9 +17,9 @@ //! Common logic for implementation of worker processes. use crate::LOG_TARGET; +use codec::Encode; use futures::FutureExt as _; use futures_timer::Delay; -use parity_scale_codec::Encode; use pin_project::pin_project; use polkadot_node_core_pvf_common::{SecurityStatus, WorkerHandshake}; use rand::Rng; diff --git a/polkadot/node/core/pvf/tests/it/adder.rs b/polkadot/node/core/pvf/tests/it/adder.rs index 9a7ddcb40890..455e8c36c88d 100644 --- a/polkadot/node/core/pvf/tests/it/adder.rs +++ b/polkadot/node/core/pvf/tests/it/adder.rs @@ -17,12 +17,12 @@ //! PVF host integration tests checking the chain production pipeline. use super::TestHost; -use adder::{hash_state, BlockData, HeadData}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_parachain_primitives::primitives::{ BlockData as GenericBlockData, HeadData as GenericHeadData, RelayChainBlockNumber, ValidationParams, }; +use test_parachain_adder::{hash_state, BlockData, HeadData}; #[tokio::test] async fn execute_good_block_on_parent() { @@ -34,7 +34,7 @@ async fn execute_good_block_on_parent() { let ret = host .validate_candidate( - adder::wasm_binary_unwrap(), + test_parachain_adder::wasm_binary_unwrap(), ValidationParams { parent_head: GenericHeadData(parent_head.encode()), block_data: GenericBlockData(block_data.encode()), @@ -68,7 +68,7 @@ async fn execute_good_chain_on_parent() { let ret = host .validate_candidate( - adder::wasm_binary_unwrap(), + test_parachain_adder::wasm_binary_unwrap(), ValidationParams { parent_head: GenericHeadData(parent_head.encode()), block_data: GenericBlockData(block_data.encode()), @@ -104,7 +104,7 @@ async fn execute_bad_block_on_parent() { let _err = host .validate_candidate( - adder::wasm_binary_unwrap(), + test_parachain_adder::wasm_binary_unwrap(), ValidationParams { parent_head: GenericHeadData(parent_head.encode()), block_data: GenericBlockData(block_data.encode()), @@ -126,7 +126,7 @@ async fn stress_spawn() { let block_data = BlockData { state: 0, add: 512 }; let ret = host .validate_candidate( - adder::wasm_binary_unwrap(), + test_parachain_adder::wasm_binary_unwrap(), ValidationParams { parent_head: GenericHeadData(parent_head.encode()), block_data: GenericBlockData(block_data.encode()), @@ -163,7 +163,7 @@ async fn execute_can_run_serially() { let block_data = BlockData { state: 0, add: 512 }; let ret = host .validate_candidate( - adder::wasm_binary_unwrap(), + test_parachain_adder::wasm_binary_unwrap(), ValidationParams { parent_head: GenericHeadData(parent_head.encode()), block_data: GenericBlockData(block_data.encode()), diff --git a/polkadot/node/core/pvf/tests/it/main.rs b/polkadot/node/core/pvf/tests/it/main.rs index 6961b93832ab..d62a1aef2309 100644 --- a/polkadot/node/core/pvf/tests/it/main.rs +++ b/polkadot/node/core/pvf/tests/it/main.rs @@ -17,7 +17,7 @@ //! General PVF host integration tests checking the functionality of the PVF host itself. use assert_matches::assert_matches; -use parity_scale_codec::Encode as _; +use codec::Encode as _; #[cfg(all(feature = "ci-only-tests", target_os = "linux"))] use polkadot_node_core_pvf::SecurityStatus; use polkadot_node_core_pvf::{ @@ -163,7 +163,7 @@ async fn execute_job_terminates_on_timeout() { let start = std::time::Instant::now(); let result = host .validate_candidate( - halt::wasm_binary_unwrap(), + test_parachain_halt::wasm_binary_unwrap(), ValidationParams { block_data: BlockData(Vec::new()), parent_head: Default::default(), @@ -190,7 +190,7 @@ async fn ensure_parallel_execution() { // Run some jobs that do not complete, thus timing out. let host = TestHost::new().await; let execute_pvf_future_1 = host.validate_candidate( - halt::wasm_binary_unwrap(), + test_parachain_halt::wasm_binary_unwrap(), ValidationParams { block_data: BlockData(Vec::new()), parent_head: Default::default(), @@ -200,7 +200,7 @@ async fn ensure_parallel_execution() { Default::default(), ); let execute_pvf_future_2 = host.validate_candidate( - halt::wasm_binary_unwrap(), + test_parachain_halt::wasm_binary_unwrap(), ValidationParams { block_data: BlockData(Vec::new()), parent_head: Default::default(), @@ -244,7 +244,7 @@ async fn execute_queue_doesnt_stall_if_workers_died() { let start = std::time::Instant::now(); futures::future::join_all((0u8..=8).map(|_| { host.validate_candidate( - halt::wasm_binary_unwrap(), + test_parachain_halt::wasm_binary_unwrap(), ValidationParams { block_data: BlockData(Vec::new()), parent_head: Default::default(), @@ -287,7 +287,7 @@ async fn execute_queue_doesnt_stall_with_varying_executor_params() { let start = std::time::Instant::now(); futures::future::join_all((0u8..6).map(|i| { host.validate_candidate( - halt::wasm_binary_unwrap(), + test_parachain_halt::wasm_binary_unwrap(), ValidationParams { block_data: BlockData(Vec::new()), parent_head: Default::default(), @@ -325,7 +325,10 @@ async fn deleting_prepared_artifact_does_not_dispute() { let host = TestHost::new().await; let cache_dir = host.cache_dir.path(); - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), Default::default()).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), Default::default()) + .await + .unwrap(); // Manually delete the prepared artifact from disk. The in-memory artifacts table won't change. { @@ -345,7 +348,7 @@ async fn deleting_prepared_artifact_does_not_dispute() { // Try to validate, artifact should get recreated. let result = host .validate_candidate( - halt::wasm_binary_unwrap(), + test_parachain_halt::wasm_binary_unwrap(), ValidationParams { block_data: BlockData(Vec::new()), parent_head: Default::default(), @@ -365,7 +368,10 @@ async fn corrupted_prepared_artifact_does_not_dispute() { let host = TestHost::new().await; let cache_dir = host.cache_dir.path(); - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), Default::default()).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), Default::default()) + .await + .unwrap(); // Manually corrupting the prepared artifact from disk. The in-memory artifacts table won't // change. @@ -395,7 +401,7 @@ async fn corrupted_prepared_artifact_does_not_dispute() { // Try to validate, artifact should get removed because of the corruption. let result = host .validate_candidate( - halt::wasm_binary_unwrap(), + test_parachain_halt::wasm_binary_unwrap(), ValidationParams { block_data: BlockData(Vec::new()), parent_head: Default::default(), @@ -412,7 +418,9 @@ async fn corrupted_prepared_artifact_does_not_dispute() { ); // because of RuntimeConstruction we may retry - host.precheck_pvf(halt::wasm_binary_unwrap(), Default::default()).await.unwrap(); + host.precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), Default::default()) + .await + .unwrap(); // The actual artifact removal is done concurrently // with sending of the result of the execution @@ -437,7 +445,10 @@ async fn cache_cleared_on_startup() { // Don't drop this host, it owns the `TempDir` which gets cleared on drop. let host = TestHost::new().await; - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), Default::default()).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), Default::default()) + .await + .unwrap(); // The cache dir should contain one artifact and one worker dir. let cache_dir = host.cache_dir.path().to_owned(); @@ -461,7 +472,7 @@ async fn prechecking_within_memory_limits() { let host = TestHost::new().await; let result = host .precheck_pvf( - ::adder::wasm_binary_unwrap(), + ::test_parachain_adder::wasm_binary_unwrap(), ExecutorParams::from(&[ExecutorParam::PrecheckingMaxMemory(10 * 1024 * 1024)][..]), ) .await; @@ -480,7 +491,7 @@ async fn prechecking_out_of_memory() { let host = TestHost::new().await; let result = host .precheck_pvf( - ::adder::wasm_binary_unwrap(), + ::test_parachain_adder::wasm_binary_unwrap(), ExecutorParams::from(&[ExecutorParam::PrecheckingMaxMemory(512 * 1024)][..]), ) .await; @@ -497,12 +508,15 @@ async fn prepare_can_run_serially() { .await; let _stats = host - .precheck_pvf(::adder::wasm_binary_unwrap(), Default::default()) + .precheck_pvf(::test_parachain_adder::wasm_binary_unwrap(), Default::default()) .await .unwrap(); // Prepare a different wasm blob to prevent skipping work. - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), Default::default()).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), Default::default()) + .await + .unwrap(); } // CI machines should be able to enable all the security features. @@ -555,7 +569,7 @@ async fn nonexistent_cache_dir() { assert!(host.security_status().await.can_unshare_user_namespace_and_change_root); let _stats = host - .precheck_pvf(::adder::wasm_binary_unwrap(), Default::default()) + .precheck_pvf(::test_parachain_adder::wasm_binary_unwrap(), Default::default()) .await .unwrap(); } @@ -574,7 +588,10 @@ async fn artifact_does_not_reprepare_on_non_meaningful_exec_parameter_change() { let set2 = ExecutorParams::from(&[ExecutorParam::PvfExecTimeout(PvfExecKind::Backing, 2500)][..]); - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), set1).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), set1) + .await + .unwrap(); let md1 = { let mut cache_dir: Vec<_> = std::fs::read_dir(cache_dir).unwrap().collect(); @@ -590,7 +607,10 @@ async fn artifact_does_not_reprepare_on_non_meaningful_exec_parameter_change() { // second attifact will be different tokio::time::sleep(Duration::from_secs(2)).await; - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), set2).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), set2) + .await + .unwrap(); let md2 = { let mut cache_dir: Vec<_> = std::fs::read_dir(cache_dir).unwrap().collect(); @@ -619,12 +639,18 @@ async fn artifact_does_reprepare_on_meaningful_exec_parameter_change() { let set2 = ExecutorParams::from(&[ExecutorParam::PvfPrepTimeout(PvfPrepKind::Prepare, 60000)][..]); - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), set1).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), set1) + .await + .unwrap(); let cache_dir_contents: Vec<_> = std::fs::read_dir(cache_dir).unwrap().collect(); assert_eq!(cache_dir_contents.len(), 2); - let _stats = host.precheck_pvf(halt::wasm_binary_unwrap(), set2).await.unwrap(); + let _stats = host + .precheck_pvf(test_parachain_halt::wasm_binary_unwrap(), set2) + .await + .unwrap(); let cache_dir_contents: Vec<_> = std::fs::read_dir(cache_dir).unwrap().collect(); assert_eq!(cache_dir_contents.len(), 3); // new artifact has been added diff --git a/polkadot/node/core/pvf/tests/it/process.rs b/polkadot/node/core/pvf/tests/it/process.rs index e989eb874ba9..b8fd2cdce0ce 100644 --- a/polkadot/node/core/pvf/tests/it/process.rs +++ b/polkadot/node/core/pvf/tests/it/process.rs @@ -18,9 +18,8 @@ //! spawned by the host) and job processes (spawned by the workers to securely perform PVF jobs). use super::TestHost; -use adder::{hash_state, BlockData, HeadData}; use assert_matches::assert_matches; -use parity_scale_codec::Encode; +use codec::Encode; use polkadot_node_core_pvf::{ InvalidCandidate, PossiblyInvalidError, PrepareError, ValidationError, }; @@ -30,6 +29,7 @@ use polkadot_parachain_primitives::primitives::{ use procfs::process; use rusty_fork::rusty_fork_test; use std::{future::Future, sync::Arc, time::Duration}; +use test_parachain_adder::{hash_state, BlockData, HeadData}; const PREPARE_PROCESS_NAME: &'static str = "polkadot-prepare-worker"; const EXECUTE_PROCESS_NAME: &'static str = "polkadot-execute-worker"; @@ -127,7 +127,7 @@ rusty_fork_test! { let block_data = BlockData { state: 0, add: 512 }; host .validate_candidate( - adder::wasm_binary_unwrap(), + test_parachain_adder::wasm_binary_unwrap(), ValidationParams { parent_head: GenericHeadData(parent_head.encode()), block_data: GenericBlockData(block_data.encode()), @@ -164,7 +164,7 @@ rusty_fork_test! { fn execute_worker_timeout() { test_wrapper(|host, sid| async move { // Prepare the artifact ahead of time. - let binary = halt::wasm_binary_unwrap(); + let binary = test_parachain_halt::wasm_binary_unwrap(); host.precheck_pvf(binary, Default::default()).await.unwrap(); let (result, _) = futures::join!( @@ -216,7 +216,7 @@ rusty_fork_test! { fn execute_worker_killed_during_job() { test_wrapper(|host, sid| async move { // Prepare the artifact ahead of time. - let binary = halt::wasm_binary_unwrap(); + let binary = test_parachain_halt::wasm_binary_unwrap(); host.precheck_pvf(binary, Default::default()).await.unwrap(); let (result, _) = futures::join!( @@ -272,7 +272,7 @@ rusty_fork_test! { fn forked_execute_job_killed_during_job() { test_wrapper(|host, sid| async move { // Prepare the artifact ahead of time. - let binary = halt::wasm_binary_unwrap(); + let binary = test_parachain_halt::wasm_binary_unwrap(); host.precheck_pvf(binary, Default::default()).await.unwrap(); let (result, _) = futures::join!( @@ -340,7 +340,7 @@ rusty_fork_test! { fn ensure_execute_processes_have_correct_num_threads() { test_wrapper(|host, sid| async move { // Prepare the artifact ahead of time. - let binary = halt::wasm_binary_unwrap(); + let binary = test_parachain_halt::wasm_binary_unwrap(); host.precheck_pvf(binary, Default::default()).await.unwrap(); let _ = futures::join!( diff --git a/polkadot/node/core/runtime-api/Cargo.toml b/polkadot/node/core/runtime-api/Cargo.toml index 91f5c35b2794..5524cc705457 100644 --- a/polkadot/node/core/runtime-api/Cargo.toml +++ b/polkadot/node/core/runtime-api/Cargo.toml @@ -29,4 +29,4 @@ async-trait = "0.1.79" futures = { version = "0.3.30", features = ["thread-pool"] } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } polkadot-node-primitives = { path = "../../primitives" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/polkadot/node/core/runtime-api/src/tests.rs b/polkadot/node/core/runtime-api/src/tests.rs index 0113de83c89e..7c382707264f 100644 --- a/polkadot/node/core/runtime-api/src/tests.rs +++ b/polkadot/node/core/runtime-api/src/tests.rs @@ -27,13 +27,13 @@ use polkadot_primitives::{ PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, Slot, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; +use polkadot_primitives_test_helpers::{dummy_committed_candidate_receipt, dummy_validation_code}; use sp_api::ApiError; use sp_core::testing::TaskExecutor; use std::{ collections::{BTreeMap, HashMap, VecDeque}, sync::{Arc, Mutex}, }; -use test_helpers::{dummy_committed_candidate_receipt, dummy_validation_code}; #[derive(Default)] struct MockSubsystemClient { diff --git a/polkadot/node/jaeger/Cargo.toml b/polkadot/node/jaeger/Cargo.toml index f879f9550d01..18b0c417aaf3 100644 --- a/polkadot/node/jaeger/Cargo.toml +++ b/polkadot/node/jaeger/Cargo.toml @@ -21,4 +21,4 @@ sp-core = { path = "../../../substrate/primitives/core" } thiserror = { workspace = true } tokio = "1.37" log = { workspace = true, default-features = true } -parity-scale-codec = { version = "3.6.12", default-features = false } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false } diff --git a/polkadot/node/jaeger/src/spans.rs b/polkadot/node/jaeger/src/spans.rs index fcee8be9a50f..efc1a9f91d19 100644 --- a/polkadot/node/jaeger/src/spans.rs +++ b/polkadot/node/jaeger/src/spans.rs @@ -83,7 +83,7 @@ //! # } //! ``` -use parity_scale_codec::Encode; +use codec::Encode; use polkadot_node_primitives::PoV; use polkadot_primitives::{ BlakeTwo256, CandidateHash, ChunkIndex, Hash, HashT, Id as ParaId, ValidatorIndex, diff --git a/polkadot/node/malus/Cargo.toml b/polkadot/node/malus/Cargo.toml index 750074fa9b3c..fec148f7d381 100644 --- a/polkadot/node/malus/Cargo.toml +++ b/polkadot/node/malus/Cargo.toml @@ -48,7 +48,7 @@ clap = { version = "4.5.3", features = ["derive"] } futures = "0.3.30" futures-timer = "3.0.2" gum = { package = "tracing-gum", path = "../gum" } -erasure = { package = "polkadot-erasure-coding", path = "../../erasure-coding" } +polkadot-erasure-coding = { path = "../../erasure-coding" } rand = "0.8.5" # Required for worker binaries to build. diff --git a/polkadot/node/malus/src/variants/suggest_garbage_candidate.rs b/polkadot/node/malus/src/variants/suggest_garbage_candidate.rs index 739ed40db362..6921352cdfc2 100644 --- a/polkadot/node/malus/src/variants/suggest_garbage_candidate.rs +++ b/polkadot/node/malus/src/variants/suggest_garbage_candidate.rs @@ -197,13 +197,13 @@ where let pov_hash = pov.hash(); let erasure_root = { - let chunks = erasure::obtain_chunks_v1( + let chunks = polkadot_erasure_coding::obtain_chunks_v1( n_validators as usize, &malicious_available_data, ) .unwrap(); - let branches = erasure::branches(chunks.as_ref()); + let branches = polkadot_erasure_coding::branches(chunks.as_ref()); branches.root() }; diff --git a/polkadot/node/metrics/Cargo.toml b/polkadot/node/metrics/Cargo.toml index e3a53cc6df1b..55df8d3daf6d 100644 --- a/polkadot/node/metrics/Cargo.toml +++ b/polkadot/node/metrics/Cargo.toml @@ -19,10 +19,10 @@ metered = { package = "prioritized-metered-channel", version = "0.6.1", default- sc-service = { path = "../../../substrate/client/service" } sc-cli = { path = "../../../substrate/client/cli" } -substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } sc-tracing = { path = "../../../substrate/client/tracing" } codec = { package = "parity-scale-codec", version = "3.6.12" } -primitives = { package = "polkadot-primitives", path = "../../primitives" } +polkadot-primitives = { path = "../../primitives" } bs58 = { version = "0.5.0", features = ["alloc"] } log = { workspace = true, default-features = true } @@ -41,7 +41,7 @@ prometheus-parse = { version = "0.2.2" } default = [] runtime-metrics = [] runtime-benchmarks = [ + "polkadot-primitives/runtime-benchmarks", "polkadot-test-service/runtime-benchmarks", - "primitives/runtime-benchmarks", "sc-service/runtime-benchmarks", ] diff --git a/polkadot/node/metrics/src/lib.rs b/polkadot/node/metrics/src/lib.rs index 9cb0f289a580..3445c3de107a 100644 --- a/polkadot/node/metrics/src/lib.rs +++ b/polkadot/node/metrics/src/lib.rs @@ -45,7 +45,7 @@ pub fn logger_hook() -> impl FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Con /// This module reexports Prometheus types and defines the [`Metrics`](metrics::Metrics) trait. pub mod metrics { /// Reexport Substrate Prometheus types. - pub use substrate_prometheus_endpoint as prometheus; + pub use prometheus_endpoint as prometheus; /// Subsystem- or job-specific Prometheus metrics. /// diff --git a/polkadot/node/metrics/src/runtime/mod.rs b/polkadot/node/metrics/src/runtime/mod.rs index 7cd24b01c117..c5ece849aa3e 100644 --- a/polkadot/node/metrics/src/runtime/mod.rs +++ b/polkadot/node/metrics/src/runtime/mod.rs @@ -28,17 +28,17 @@ #![cfg(feature = "runtime-metrics")] use codec::Decode; -use primitives::{ +use polkadot_primitives::{ metric_definitions::{CounterDefinition, CounterVecDefinition, HistogramDefinition}, RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate, }; +use prometheus_endpoint::{ + register, Counter, CounterVec, Histogram, HistogramOpts, Opts, PrometheusError, Registry, U64, +}; use std::{ collections::hash_map::HashMap, sync::{Arc, Mutex, MutexGuard}, }; -use substrate_prometheus_endpoint::{ - register, Counter, CounterVec, Histogram, HistogramOpts, Opts, PrometheusError, Registry, U64, -}; mod parachain; /// Holds the registered Prometheus metric collections. diff --git a/polkadot/node/metrics/src/runtime/parachain.rs b/polkadot/node/metrics/src/runtime/parachain.rs index becc7c64d59d..7aecaf5590f1 100644 --- a/polkadot/node/metrics/src/runtime/parachain.rs +++ b/polkadot/node/metrics/src/runtime/parachain.rs @@ -18,7 +18,7 @@ //! All of the metrics have a correspondent runtime metric definition. use crate::runtime::RuntimeMetricsProvider; -use primitives::metric_definitions::{ +use polkadot_primitives::metric_definitions::{ PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS, PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED, PARACHAIN_INHERENT_DATA_WEIGHT, diff --git a/polkadot/node/metrics/src/tests.rs b/polkadot/node/metrics/src/tests.rs index 861080228cd8..fde7c3144134 100644 --- a/polkadot/node/metrics/src/tests.rs +++ b/polkadot/node/metrics/src/tests.rs @@ -17,8 +17,8 @@ //! Polkadot runtime metrics integration test. use hyper::{Client, Uri}; +use polkadot_primitives::metric_definitions::PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED; use polkadot_test_service::{node_config, run_validator_node, test_prometheus_config}; -use primitives::metric_definitions::PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED; use sp_keyring::AccountKeyring::*; use std::collections::HashMap; diff --git a/polkadot/node/network/approval-distribution/src/tests.rs b/polkadot/node/network/approval-distribution/src/tests.rs index 3159fe2ae5e8..5ad034464767 100644 --- a/polkadot/node/network/approval-distribution/src/tests.rs +++ b/polkadot/node/network/approval-distribution/src/tests.rs @@ -36,7 +36,6 @@ use polkadot_node_primitives::approval::{ use polkadot_node_subsystem::messages::{ network_bridge_event, AllMessages, ApprovalCheckError, ReportPeerMessage, }; -use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::{reputation::add_reputation, TimeoutExt as _}; use polkadot_primitives::{AuthorityDiscoveryId, BlakeTwo256, CoreIndex, HashT}; use polkadot_primitives_test_helpers::dummy_signature; @@ -44,7 +43,8 @@ use rand::SeedableRng; use sp_authority_discovery::AuthorityPair as AuthorityDiscoveryPair; use sp_core::crypto::Pair as PairT; use std::time::Duration; -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; fn test_harness>( mut state: State, @@ -56,7 +56,8 @@ fn test_harness>( .try_init(); let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let subsystem = ApprovalDistribution::new(Default::default()); { @@ -3657,7 +3658,8 @@ fn batch_test_round(message_count: usize) { let pool = sp_core::testing::TaskExecutor::new(); let mut state = State::default(); - let (mut context, mut virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (mut context, mut virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let subsystem = ApprovalDistribution::new(Default::default()); let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(12345); let mut sender = context.sender().clone(); diff --git a/polkadot/node/network/availability-distribution/Cargo.toml b/polkadot/node/network/availability-distribution/Cargo.toml index 01b208421d79..db3a0456d9ad 100644 --- a/polkadot/node/network/availability-distribution/Cargo.toml +++ b/polkadot/node/network/availability-distribution/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] futures = "0.3.30" gum = { package = "tracing-gum", path = "../../gum" } -parity-scale-codec = { version = "3.6.12", features = ["std"] } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["std"] } polkadot-primitives = { path = "../../../primitives" } polkadot-erasure-coding = { path = "../../../erasure-coding" } polkadot-node-network-protocol = { path = "../protocol" } diff --git a/polkadot/node/network/availability-distribution/src/pov_requester/mod.rs b/polkadot/node/network/availability-distribution/src/pov_requester/mod.rs index f99002d4188b..6c632fa7efee 100644 --- a/polkadot/node/network/availability-distribution/src/pov_requester/mod.rs +++ b/polkadot/node/network/availability-distribution/src/pov_requester/mod.rs @@ -138,7 +138,7 @@ mod tests { use assert_matches::assert_matches; use futures::{executor, future}; - use parity_scale_codec::Encode; + use codec::Encode; use sc_network::ProtocolName; use sp_core::testing::TaskExecutor; @@ -169,10 +169,11 @@ mod tests { fn test_run(pov_hash: Hash, pov: PoV) { let pool = TaskExecutor::new(); - let (mut context, mut virtual_overseer) = test_helpers::make_subsystem_context::< - AvailabilityDistributionMessage, - TaskExecutor, - >(pool.clone()); + let (mut context, mut virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context::< + AvailabilityDistributionMessage, + TaskExecutor, + >(pool.clone()); let keystore = make_ferdie_keystore(); let mut runtime = polkadot_node_subsystem_util::runtime::RuntimeInfo::new(Some(keystore)); diff --git a/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs b/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs index 7bd36709bc5f..278608cc858d 100644 --- a/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs +++ b/polkadot/node/network/availability-distribution/src/requester/fetch_task/mod.rs @@ -22,7 +22,7 @@ use futures::{ FutureExt, SinkExt, }; -use parity_scale_codec::Decode; +use codec::Decode; use polkadot_erasure_coding::branch_hash; use polkadot_node_network_protocol::request_response::{ outgoing::{OutgoingRequest, Recipient, RequestError, Requests}, diff --git a/polkadot/node/network/availability-distribution/src/requester/fetch_task/tests.rs b/polkadot/node/network/availability-distribution/src/requester/fetch_task/tests.rs index 25fae37f725a..2cd4bf29a563 100644 --- a/polkadot/node/network/availability-distribution/src/requester/fetch_task/tests.rs +++ b/polkadot/node/network/availability-distribution/src/requester/fetch_task/tests.rs @@ -16,7 +16,7 @@ use std::collections::HashMap; -use parity_scale_codec::Encode; +use codec::Encode; use futures::{ channel::{mpsc, oneshot}, diff --git a/polkadot/node/network/availability-distribution/src/responder.rs b/polkadot/node/network/availability-distribution/src/responder.rs index 2c1885d27727..fb08c4712503 100644 --- a/polkadot/node/network/availability-distribution/src/responder.rs +++ b/polkadot/node/network/availability-distribution/src/responder.rs @@ -20,8 +20,8 @@ use std::sync::Arc; use futures::{channel::oneshot, select, FutureExt}; +use codec::{Decode, Encode}; use fatality::Nested; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_network_protocol::{ request_response::{v1, v2, IncomingRequest, IncomingRequestReceiver, IsRequest}, UnifiedReputationChange as Rep, diff --git a/polkadot/node/network/availability-distribution/src/tests/mod.rs b/polkadot/node/network/availability-distribution/src/tests/mod.rs index b30e11a293c8..3320871bceb5 100644 --- a/polkadot/node/network/availability-distribution/src/tests/mod.rs +++ b/polkadot/node/network/availability-distribution/src/tests/mod.rs @@ -25,8 +25,6 @@ use polkadot_node_network_protocol::request_response::{ use polkadot_primitives::{node_features, Block, CoreState, Hash, NodeFeatures}; use sp_keystore::KeystorePtr; -use polkadot_node_subsystem_test_helpers as test_helpers; - use super::*; mod state; @@ -44,7 +42,8 @@ fn test_harness>( sp_tracing::init_for_tests(); let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let (pov_req_receiver, pov_req_cfg) = IncomingRequest::get_config_receiver::< Block, diff --git a/polkadot/node/network/availability-distribution/src/tests/state.rs b/polkadot/node/network/availability-distribution/src/tests/state.rs index ecc3eefbf3da..befbff0a2f27 100644 --- a/polkadot/node/network/availability-distribution/src/tests/state.rs +++ b/polkadot/node/network/availability-distribution/src/tests/state.rs @@ -55,7 +55,9 @@ use test_helpers::mock::{make_ferdie_keystore, new_leaf}; use super::mock::{make_session_info, OccupiedCoreBuilder}; use crate::LOG_TARGET; -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle< + AvailabilityDistributionMessage, +>; pub struct TestHarness { pub virtual_overseer: VirtualOverseer, pub pov_req_cfg: RequestResponseConfig, diff --git a/polkadot/node/network/availability-recovery/Cargo.toml b/polkadot/node/network/availability-recovery/Cargo.toml index 1c2b5f4968ad..1c9c861e6f73 100644 --- a/polkadot/node/network/availability-recovery/Cargo.toml +++ b/polkadot/node/network/availability-recovery/Cargo.toml @@ -25,7 +25,7 @@ polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-network-protocol = { path = "../protocol" } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sc-network = { path = "../../../../substrate/client/network" } [dev-dependencies] diff --git a/polkadot/node/network/availability-recovery/src/task/mod.rs b/polkadot/node/network/availability-recovery/src/task/mod.rs index 800a82947d6f..0a8b52411afe 100644 --- a/polkadot/node/network/availability-recovery/src/task/mod.rs +++ b/polkadot/node/network/availability-recovery/src/task/mod.rs @@ -30,7 +30,7 @@ pub use self::strategy::{REGULAR_CHUNKS_REQ_RETRY_LIMIT, SYSTEMATIC_CHUNKS_REQ_R use crate::{metrics::Metrics, ErasureTask, PostRecoveryCheck, LOG_TARGET}; -use parity_scale_codec::Encode; +use codec::Encode; use polkadot_node_primitives::AvailableData; use polkadot_node_subsystem::{messages::AvailabilityStoreMessage, overseer, RecoveryError}; use polkadot_primitives::{AuthorityDiscoveryId, CandidateHash, Hash}; diff --git a/polkadot/node/network/availability-recovery/src/task/strategy/mod.rs b/polkadot/node/network/availability-recovery/src/task/strategy/mod.rs index fb31ff6aa779..1403277c8a95 100644 --- a/polkadot/node/network/availability-recovery/src/task/strategy/mod.rs +++ b/polkadot/node/network/availability-recovery/src/task/strategy/mod.rs @@ -29,8 +29,8 @@ use crate::{ futures_undead::FuturesUndead, ErasureTask, PostRecoveryCheck, RecoveryParams, LOG_TARGET, }; +use codec::Decode; use futures::{channel::oneshot, SinkExt}; -use parity_scale_codec::Decode; use polkadot_erasure_coding::branch_hash; #[cfg(not(test))] use polkadot_node_network_protocol::request_response::CHUNK_REQUEST_TIMEOUT; @@ -636,11 +636,11 @@ mod tests { use super::*; use crate::{tests::*, Metrics, RecoveryStrategy, RecoveryTask}; use assert_matches::assert_matches; + use codec::Error as DecodingError; use futures::{ channel::mpsc::{self, UnboundedReceiver}, executor, future, Future, FutureExt, StreamExt, }; - use parity_scale_codec::Error as DecodingError; use polkadot_erasure_coding::{recovery_threshold, systematic_recovery_threshold}; use polkadot_node_network_protocol::request_response::Protocol; use polkadot_node_primitives::{BlockData, PoV}; diff --git a/polkadot/node/network/availability-recovery/src/tests.rs b/polkadot/node/network/availability-recovery/src/tests.rs index d0a4a2d8b60e..4fd9ede40ff6 100644 --- a/polkadot/node/network/availability-recovery/src/tests.rs +++ b/polkadot/node/network/availability-recovery/src/tests.rs @@ -24,7 +24,7 @@ use futures::{executor, future}; use futures_timer::Delay; use rstest::rstest; -use parity_scale_codec::Encode; +use codec::Encode; use polkadot_node_network_protocol::request_response::{ self as req_res, v1::{AvailableDataFetchingRequest, ChunkResponse}, diff --git a/polkadot/node/network/bridge/Cargo.toml b/polkadot/node/network/bridge/Cargo.toml index b609fb1e0719..cd4e00ee1e4c 100644 --- a/polkadot/node/network/bridge/Cargo.toml +++ b/polkadot/node/network/bridge/Cargo.toml @@ -15,7 +15,7 @@ async-trait = "0.1.79" futures = "0.3.30" gum = { package = "tracing-gum", path = "../../gum" } polkadot-primitives = { path = "../../../primitives" } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sc-network = { path = "../../../../substrate/client/network" } sp-consensus = { path = "../../../../substrate/primitives/consensus/common" } polkadot-node-metrics = { path = "../../metrics" } diff --git a/polkadot/node/network/bridge/src/lib.rs b/polkadot/node/network/bridge/src/lib.rs index 0305aaa067cc..0db18bc219a9 100644 --- a/polkadot/node/network/bridge/src/lib.rs +++ b/polkadot/node/network/bridge/src/lib.rs @@ -21,8 +21,8 @@ #![deny(unused_crate_dependencies)] #![warn(missing_docs)] +use codec::{Decode, Encode}; use futures::prelude::*; -use parity_scale_codec::{Decode, Encode}; use parking_lot::Mutex; use sp_consensus::SyncOracle; diff --git a/polkadot/node/network/bridge/src/network.rs b/polkadot/node/network/bridge/src/network.rs index 17d6676b8430..b31359f48a56 100644 --- a/polkadot/node/network/bridge/src/network.rs +++ b/polkadot/node/network/bridge/src/network.rs @@ -22,7 +22,7 @@ use std::{ use async_trait::async_trait; use parking_lot::Mutex; -use parity_scale_codec::Encode; +use codec::Encode; use sc_network::{ config::parse_addr, multiaddr::Multiaddr, service::traits::NetworkService, types::ProtocolName, diff --git a/polkadot/node/network/bridge/src/rx/mod.rs b/polkadot/node/network/bridge/src/rx/mod.rs index 0a4497fc4b5a..84e935366d0c 100644 --- a/polkadot/node/network/bridge/src/rx/mod.rs +++ b/polkadot/node/network/bridge/src/rx/mod.rs @@ -20,8 +20,8 @@ use super::*; use always_assert::never; use bytes::Bytes; +use codec::{Decode, DecodeAll}; use net_protocol::filter_by_peer_version; -use parity_scale_codec::{Decode, DecodeAll}; use parking_lot::Mutex; use sc_network::{ diff --git a/polkadot/node/network/bridge/src/tx/tests.rs b/polkadot/node/network/bridge/src/tx/tests.rs index c3cf0f322f68..9265358196db 100644 --- a/polkadot/node/network/bridge/src/tx/tests.rs +++ b/polkadot/node/network/bridge/src/tx/tests.rs @@ -26,7 +26,7 @@ use sc_network::{ IfDisconnected, ObservedRole as SubstrateObservedRole, ProtocolName, ReputationChange, Roles, }; -use parity_scale_codec::DecodeAll; +use codec::DecodeAll; use polkadot_node_network_protocol::{ peer_set::{PeerSetProtocolNames, ValidationVersion}, request_response::{outgoing::Requests, ReqProtocolNames}, diff --git a/polkadot/node/network/collator-protocol/Cargo.toml b/polkadot/node/network/collator-protocol/Cargo.toml index d7291552738d..a56c1c7dfe98 100644 --- a/polkadot/node/network/collator-protocol/Cargo.toml +++ b/polkadot/node/network/collator-protocol/Cargo.toml @@ -38,7 +38,7 @@ sp-core = { path = "../../../../substrate/primitives/core", features = ["std"] } sp-keyring = { path = "../../../../substrate/primitives/keyring" } sc-keystore = { path = "../../../../substrate/client/keystore" } sc-network = { path = "../../../../substrate/client/network" } -parity-scale-codec = { version = "3.6.12", features = ["std"] } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["std"] } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs b/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs index 412792bbecfb..a13e99df4ab4 100644 --- a/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs +++ b/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs @@ -22,7 +22,7 @@ use assert_matches::assert_matches; use futures::{executor, future, Future}; use futures_timer::Delay; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use sc_network::config::IncomingRequest as RawIncomingRequest; use sp_core::crypto::Pair; @@ -222,7 +222,8 @@ impl TestState { } } -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; struct TestHarness { virtual_overseer: VirtualOverseer, @@ -244,7 +245,8 @@ fn test_harness>( let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let genesis_hash = Hash::repeat_byte(0xff); let req_protocol_names = ReqProtocolNames::new(&genesis_hash, None); diff --git a/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs b/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs index 1ba6389212cc..3f4459d8e65d 100644 --- a/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs +++ b/polkadot/node/network/collator-protocol/src/validator_side/tests/mod.rs @@ -132,7 +132,8 @@ impl Default for TestState { } } -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; struct TestHarness { virtual_overseer: VirtualOverseer, @@ -151,7 +152,8 @@ fn test_harness>( let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let keystore = Arc::new(sc_keystore::LocalKeystore::in_memory()); Keystore::sr25519_generate_new( diff --git a/polkadot/node/network/dispute-distribution/Cargo.toml b/polkadot/node/network/dispute-distribution/Cargo.toml index dff285590d97..08713209bb74 100644 --- a/polkadot/node/network/dispute-distribution/Cargo.toml +++ b/polkadot/node/network/dispute-distribution/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.3.30" futures-timer = "3.0.2" gum = { package = "tracing-gum", path = "../../gum" } derive_more = "0.99.17" -parity-scale-codec = { version = "3.6.12", features = ["std"] } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["std"] } polkadot-primitives = { path = "../../../primitives" } polkadot-erasure-coding = { path = "../../../erasure-coding" } polkadot-node-subsystem = { path = "../../subsystem" } diff --git a/polkadot/node/network/dispute-distribution/src/tests/mod.rs b/polkadot/node/network/dispute-distribution/src/tests/mod.rs index 1d0d667f5ccf..60820e62ca2d 100644 --- a/polkadot/node/network/dispute-distribution/src/tests/mod.rs +++ b/polkadot/node/network/dispute-distribution/src/tests/mod.rs @@ -24,13 +24,13 @@ use std::{ }; use assert_matches::assert_matches; +use codec::{Decode, Encode}; use futures::{ channel::oneshot, future::{poll_fn, ready}, pin_mut, Future, }; use futures_timer::Delay; -use parity_scale_codec::{Decode, Encode}; use sc_network::{config::RequestResponseConfig, ProtocolName}; diff --git a/polkadot/node/network/gossip-support/src/tests.rs b/polkadot/node/network/gossip-support/src/tests.rs index cce78df38f30..42197d00e6f3 100644 --- a/polkadot/node/network/gossip-support/src/tests.rs +++ b/polkadot/node/network/gossip-support/src/tests.rs @@ -90,7 +90,8 @@ lazy_static! { ]; } -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; #[derive(Debug, Clone)] struct MockAuthorityDiscovery { @@ -200,7 +201,8 @@ fn test_harness, AD: AuthorityDiscovery>( test_fn: impl FnOnce(VirtualOverseer) -> T, ) -> GossipSupport { let pool = sp_core::testing::TaskExecutor::new(); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let subsystem = subsystem.run(context); diff --git a/polkadot/node/network/protocol/Cargo.toml b/polkadot/node/network/protocol/Cargo.toml index c5015b8c6450..83145ce40130 100644 --- a/polkadot/node/network/protocol/Cargo.toml +++ b/polkadot/node/network/protocol/Cargo.toml @@ -16,7 +16,7 @@ hex = "0.4.3" polkadot-primitives = { path = "../../../primitives" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-jaeger = { path = "../../jaeger" } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sc-network = { path = "../../../../substrate/client/network" } sc-network-types = { path = "../../../../substrate/client/network/types" } sc-authority-discovery = { path = "../../../../substrate/client/authority-discovery" } diff --git a/polkadot/node/network/protocol/src/lib.rs b/polkadot/node/network/protocol/src/lib.rs index c38838b1ef98..ca0f8a4e4849 100644 --- a/polkadot/node/network/protocol/src/lib.rs +++ b/polkadot/node/network/protocol/src/lib.rs @@ -19,7 +19,7 @@ #![deny(unused_crate_dependencies)] #![warn(missing_docs)] -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_primitives::{BlockNumber, Hash}; use std::{collections::HashMap, fmt}; @@ -462,7 +462,7 @@ impl_versioned_try_from!( /// v1 notification protocol types. pub mod v1 { - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; use polkadot_primitives::{ CandidateHash, CandidateIndex, CollatorId, CollatorSignature, CompactStatement, Hash, @@ -621,7 +621,7 @@ pub mod v1 { /// v2 network protocol types. pub mod v2 { use bitvec::{order::Lsb0, slice::BitSlice, vec::BitVec}; - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; use polkadot_primitives::{ CandidateHash, CandidateIndex, CollatorId, CollatorSignature, GroupIndex, Hash, @@ -875,7 +875,7 @@ pub mod v2 { /// Purpose is for changing ApprovalDistributionMessage to /// include more than one assignment and approval in a message. pub mod v3 { - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; use polkadot_node_primitives::approval::v2::{ CandidateBitfield, IndirectAssignmentCertV2, IndirectSignedApprovalVoteV2, diff --git a/polkadot/node/network/protocol/src/request_response/incoming/error.rs b/polkadot/node/network/protocol/src/request_response/incoming/error.rs index 7de9d919058a..d3aa0b7275c1 100644 --- a/polkadot/node/network/protocol/src/request_response/incoming/error.rs +++ b/polkadot/node/network/protocol/src/request_response/incoming/error.rs @@ -18,7 +18,7 @@ use sc_network_types::PeerId; -use parity_scale_codec::Error as DecodingError; +use codec::Error as DecodingError; #[allow(missing_docs)] #[fatality::fatality(splitable)] diff --git a/polkadot/node/network/protocol/src/request_response/incoming/mod.rs b/polkadot/node/network/protocol/src/request_response/incoming/mod.rs index e85390729ee3..9577c690ebdc 100644 --- a/polkadot/node/network/protocol/src/request_response/incoming/mod.rs +++ b/polkadot/node/network/protocol/src/request_response/incoming/mod.rs @@ -18,7 +18,7 @@ use std::marker::PhantomData; use futures::{channel::oneshot, StreamExt}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use sc_network::{config as netconfig, NetworkBackend}; use sc_network_types::PeerId; diff --git a/polkadot/node/network/protocol/src/request_response/outgoing.rs b/polkadot/node/network/protocol/src/request_response/outgoing.rs index f578c4ffded3..27f0f34bf8d4 100644 --- a/polkadot/node/network/protocol/src/request_response/outgoing.rs +++ b/polkadot/node/network/protocol/src/request_response/outgoing.rs @@ -16,8 +16,8 @@ use futures::{channel::oneshot, prelude::Future, FutureExt}; +use codec::{Decode, Encode, Error as DecodingError}; use network::ProtocolName; -use parity_scale_codec::{Decode, Encode, Error as DecodingError}; use sc_network as network; use sc_network_types::PeerId; diff --git a/polkadot/node/network/protocol/src/request_response/v1.rs b/polkadot/node/network/protocol/src/request_response/v1.rs index c503c6e4df03..80721f1884af 100644 --- a/polkadot/node/network/protocol/src/request_response/v1.rs +++ b/polkadot/node/network/protocol/src/request_response/v1.rs @@ -16,7 +16,7 @@ //! Requests and responses as sent over the wire for the individual protocols. -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_primitives::{ AvailableData, DisputeMessage, ErasureChunk, PoV, Proof, UncheckedDisputeMessage, diff --git a/polkadot/node/network/protocol/src/request_response/v2.rs b/polkadot/node/network/protocol/src/request_response/v2.rs index 7e1a2d989168..ae65b39cd406 100644 --- a/polkadot/node/network/protocol/src/request_response/v2.rs +++ b/polkadot/node/network/protocol/src/request_response/v2.rs @@ -16,7 +16,7 @@ //! Requests and responses as sent over the wire for the individual protocols. -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_primitives::ErasureChunk; use polkadot_primitives::{ diff --git a/polkadot/node/network/statement-distribution/Cargo.toml b/polkadot/node/network/statement-distribution/Cargo.toml index 65224f9e2be6..b044acd1a86d 100644 --- a/polkadot/node/network/statement-distribution/Cargo.toml +++ b/polkadot/node/network/statement-distribution/Cargo.toml @@ -22,7 +22,7 @@ polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-network-protocol = { path = "../protocol" } arrayvec = "0.7.4" indexmap = "2.0.0" -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } thiserror = { workspace = true } fatality = "0.1.1" bitvec = "1" diff --git a/polkadot/node/network/statement-distribution/src/legacy_v1/mod.rs b/polkadot/node/network/statement-distribution/src/legacy_v1/mod.rs index e22883f89376..264333435a00 100644 --- a/polkadot/node/network/statement-distribution/src/legacy_v1/mod.rs +++ b/polkadot/node/network/statement-distribution/src/legacy_v1/mod.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use codec::Encode; use net_protocol::{filter_by_peer_version, peer_set::ProtocolVersion}; -use parity_scale_codec::Encode; use polkadot_node_network_protocol::{ self as net_protocol, diff --git a/polkadot/node/network/statement-distribution/src/legacy_v1/tests.rs b/polkadot/node/network/statement-distribution/src/legacy_v1/tests.rs index d4c5f95034ae..8e6fcbaebbf1 100644 --- a/polkadot/node/network/statement-distribution/src/legacy_v1/tests.rs +++ b/polkadot/node/network/statement-distribution/src/legacy_v1/tests.rs @@ -20,9 +20,9 @@ use super::*; use crate::{metrics::Metrics, *}; use assert_matches::assert_matches; +use codec::{Decode, Encode}; use futures::executor; use futures_timer::Delay; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_network_protocol::{ grid_topology::{SessionGridTopology, TopologyPeerInfo}, peer_set::ValidationVersion, diff --git a/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs b/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs index f9a484f47a94..66a92bb36eb2 100644 --- a/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs +++ b/polkadot/node/network/statement-distribution/src/v2/tests/mod.rs @@ -44,8 +44,8 @@ use sp_authority_discovery::AuthorityPair as AuthorityDiscoveryPair; use sp_keyring::Sr25519Keyring; use assert_matches::assert_matches; +use codec::Encode; use futures::Future; -use parity_scale_codec::Encode; use rand::{Rng, SeedableRng}; use test_helpers::mock::new_leaf; @@ -55,7 +55,8 @@ mod cluster; mod grid; mod requests; -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; const DEFAULT_ASYNC_BACKING_PARAMETERS: AsyncBackingParams = AsyncBackingParams { max_candidate_depth: 4, allowed_ancestry_len: 3 }; @@ -371,7 +372,8 @@ fn test_harness>( let test_state = TestState::from_config(config, req_cfg.inbound_queue.unwrap(), &mut rng); - let (context, virtual_overseer) = test_helpers::make_subsystem_context(pool.clone()); + let (context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool.clone()); let subsystem = async move { let subsystem = crate::StatementDistributionSubsystem { keystore, diff --git a/polkadot/node/network/statement-distribution/src/v2/tests/requests.rs b/polkadot/node/network/statement-distribution/src/v2/tests/requests.rs index 38d7a10b8652..eed469dc0be5 100644 --- a/polkadot/node/network/statement-distribution/src/v2/tests/requests.rs +++ b/polkadot/node/network/statement-distribution/src/v2/tests/requests.rs @@ -17,7 +17,7 @@ use super::*; use bitvec::order::Lsb0; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_node_network_protocol::{ request_response::v2 as request_v2, v2::BackedCandidateManifest, }; diff --git a/polkadot/node/overseer/Cargo.toml b/polkadot/node/overseer/Cargo.toml index ef79cfe2f702..e77cead4a756 100644 --- a/polkadot/node/overseer/Cargo.toml +++ b/polkadot/node/overseer/Cargo.toml @@ -10,7 +10,7 @@ description = "System overseer of the Polkadot node" workspace = true [dependencies] -client = { package = "sc-client-api", path = "../../../substrate/client/api" } +sc-client-api = { path = "../../../substrate/client/api" } sp-api = { path = "../../../substrate/primitives/api" } futures = "0.3.30" futures-timer = "3.0.2" @@ -32,8 +32,8 @@ sp-core = { path = "../../../substrate/primitives/core" } futures = { version = "0.3.30", features = ["thread-pool"] } femme = "2.2.1" assert_matches = "1.4.0" -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers" } -node-test-helpers = { package = "polkadot-node-subsystem-test-helpers", path = "../subsystem-test-helpers" } +polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" } +polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" } [target.'cfg(target_os = "linux")'.dependencies] tikv-jemalloc-ctl = "0.5.0" diff --git a/polkadot/node/overseer/examples/minimal-example.rs b/polkadot/node/overseer/examples/minimal-example.rs index 857cdba673db..86a1801a5f2d 100644 --- a/polkadot/node/overseer/examples/minimal-example.rs +++ b/polkadot/node/overseer/examples/minimal-example.rs @@ -23,7 +23,6 @@ use futures_timer::Delay; use orchestra::async_trait; use std::time::Duration; -use ::test_helpers::{dummy_candidate_descriptor, dummy_hash}; use polkadot_node_primitives::{BlockData, PoV}; use polkadot_node_subsystem_types::messages::CandidateValidationMessage; use polkadot_overseer::{ @@ -33,6 +32,7 @@ use polkadot_overseer::{ HeadSupportsParachains, SubsystemError, }; use polkadot_primitives::{CandidateReceipt, Hash, PvfExecKind}; +use polkadot_primitives_test_helpers::{dummy_candidate_descriptor, dummy_hash}; struct AlwaysSupportsParachains; diff --git a/polkadot/node/overseer/src/lib.rs b/polkadot/node/overseer/src/lib.rs index 167b32a15bc4..24985a99913d 100644 --- a/polkadot/node/overseer/src/lib.rs +++ b/polkadot/node/overseer/src/lib.rs @@ -71,8 +71,8 @@ use std::{ use futures::{channel::oneshot, future::BoxFuture, select, Future, FutureExt, StreamExt}; -use client::{BlockImportNotification, BlockchainEvents, FinalityNotification}; use polkadot_primitives::{Block, BlockNumber, Hash}; +use sc_client_api::{BlockImportNotification, BlockchainEvents, FinalityNotification}; use self::messages::{BitfieldSigningMessage, PvfCheckerMessage}; use polkadot_node_subsystem_types::messages::{ diff --git a/polkadot/node/overseer/src/tests.rs b/polkadot/node/overseer/src/tests.rs index 87484914ef97..177e3addf368 100644 --- a/polkadot/node/overseer/src/tests.rs +++ b/polkadot/node/overseer/src/tests.rs @@ -18,13 +18,12 @@ use async_trait::async_trait; use futures::{executor, pending, pin_mut, poll, select, stream, FutureExt}; use std::{collections::HashMap, sync::atomic, task::Poll}; -use ::test_helpers::{dummy_candidate_descriptor, dummy_candidate_receipt, dummy_hash}; -use node_test_helpers::mock::{dummy_unpin_handle, new_leaf}; use polkadot_node_network_protocol::{PeerId, UnifiedReputationChange}; use polkadot_node_primitives::{ BlockData, CollationGenerationConfig, CollationResult, DisputeMessage, InvalidDisputeVote, PoV, UncheckedDisputeMessage, ValidDisputeVote, }; +use polkadot_node_subsystem_test_helpers::mock::{dummy_unpin_handle, new_leaf}; use polkadot_node_subsystem_types::messages::{ NetworkBridgeEvent, ReportPeerMessage, RuntimeApiRequest, }; @@ -32,6 +31,9 @@ use polkadot_primitives::{ CandidateHash, CandidateReceipt, CollatorPair, Id as ParaId, InvalidDisputeStatementKind, PvfExecKind, SessionIndex, ValidDisputeStatementKind, ValidatorIndex, }; +use polkadot_primitives_test_helpers::{ + dummy_candidate_descriptor, dummy_candidate_receipt, dummy_hash, +}; use crate::{ self as overseer, diff --git a/polkadot/node/primitives/Cargo.toml b/polkadot/node/primitives/Cargo.toml index 526d4e480bb0..0a84e5dae2a5 100644 --- a/polkadot/node/primitives/Cargo.toml +++ b/polkadot/node/primitives/Cargo.toml @@ -13,7 +13,7 @@ workspace = true bounded-vec = "0.7" futures = "0.3.30" polkadot-primitives = { path = "../../primitives" } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sp-core = { path = "../../../substrate/primitives/core" } sp-application-crypto = { path = "../../../substrate/primitives/application-crypto" } sp-consensus-babe = { path = "../../../substrate/primitives/consensus/babe" } diff --git a/polkadot/node/primitives/src/approval.rs b/polkadot/node/primitives/src/approval.rs index b73cb4c717db..66883b33367b 100644 --- a/polkadot/node/primitives/src/approval.rs +++ b/polkadot/node/primitives/src/approval.rs @@ -23,7 +23,7 @@ pub mod v1 { Randomness, Slot, VrfPreOutput, VrfProof, VrfSignature, VrfTranscript, }; - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; use polkadot_primitives::{ BlockNumber, CandidateHash, CandidateIndex, CoreIndex, Hash, Header, SessionIndex, ValidatorIndex, ValidatorSignature, @@ -212,7 +212,7 @@ pub mod v1 { /// A list of primitives introduced by v2. pub mod v2 { - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; pub use sp_consensus_babe::{ Randomness, Slot, VrfPreOutput, VrfProof, VrfSignature, VrfTranscript, }; diff --git a/polkadot/node/primitives/src/disputes/message.rs b/polkadot/node/primitives/src/disputes/message.rs index 31fe73a7ba1c..f9dec073bf50 100644 --- a/polkadot/node/primitives/src/disputes/message.rs +++ b/polkadot/node/primitives/src/disputes/message.rs @@ -21,7 +21,7 @@ use thiserror::Error; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use super::{InvalidDisputeVote, SignedDisputeStatement, ValidDisputeVote}; use polkadot_primitives::{ diff --git a/polkadot/node/primitives/src/disputes/mod.rs b/polkadot/node/primitives/src/disputes/mod.rs index 5814ecee44f4..0f08b4733654 100644 --- a/polkadot/node/primitives/src/disputes/mod.rs +++ b/polkadot/node/primitives/src/disputes/mod.rs @@ -19,7 +19,7 @@ use std::collections::{ BTreeMap, BTreeSet, }; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use sp_application_crypto::AppCrypto; use sp_keystore::{Error as KeystoreError, KeystorePtr}; diff --git a/polkadot/node/primitives/src/disputes/status.rs b/polkadot/node/primitives/src/disputes/status.rs index d93c3ec846ce..b9a1c57d53de 100644 --- a/polkadot/node/primitives/src/disputes/status.rs +++ b/polkadot/node/primitives/src/disputes/status.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; /// Timestamp based on the 1 Jan 1970 UNIX base, which is persistent across node restarts and OS /// reboots. diff --git a/polkadot/node/primitives/src/lib.rs b/polkadot/node/primitives/src/lib.rs index 5f007bc8d67d..aded1b8fe734 100644 --- a/polkadot/node/primitives/src/lib.rs +++ b/polkadot/node/primitives/src/lib.rs @@ -25,8 +25,8 @@ use std::pin::Pin; use bounded_vec::BoundedVec; +use codec::{Decode, Encode, Error as CodecError, Input}; use futures::Future; -use parity_scale_codec::{Decode, Encode, Error as CodecError, Input}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use polkadot_primitives::{ diff --git a/polkadot/node/service/Cargo.toml b/polkadot/node/service/Cargo.toml index 0dfdf926b1b0..ec5113d2c8a5 100644 --- a/polkadot/node/service/Cargo.toml +++ b/polkadot/node/service/Cargo.toml @@ -13,9 +13,9 @@ workspace = true [dependencies] # Substrate Client sc-authority-discovery = { path = "../../../substrate/client/authority-discovery" } -babe = { package = "sc-consensus-babe", path = "../../../substrate/client/consensus/babe" } -beefy = { package = "sc-consensus-beefy", path = "../../../substrate/client/consensus/beefy" } -grandpa = { package = "sc-consensus-grandpa", path = "../../../substrate/client/consensus/grandpa" } +sc-consensus-babe = { path = "../../../substrate/client/consensus/babe" } +sc-consensus-beefy = { path = "../../../substrate/client/consensus/beefy" } +sc-consensus-grandpa = { path = "../../../substrate/client/consensus/grandpa" } mmr-gadget = { path = "../../../substrate/client/merkle-mountain-range" } sp-mmr-primitives = { path = "../../../substrate/primitives/merkle-mountain-range" } sc-block-builder = { path = "../../../substrate/client/block-builder" } @@ -35,14 +35,14 @@ sc-keystore = { path = "../../../substrate/client/keystore" } sc-basic-authorship = { path = "../../../substrate/client/basic-authorship" } sc-offchain = { path = "../../../substrate/client/offchain" } sc-sysinfo = { path = "../../../substrate/client/sysinfo" } -service = { package = "sc-service", path = "../../../substrate/client/service", default-features = false } -telemetry = { package = "sc-telemetry", path = "../../../substrate/client/telemetry" } +sc-service = { path = "../../../substrate/client/service", default-features = false } +sc-telemetry = { path = "../../../substrate/client/telemetry" } # Substrate Primitives sp-authority-discovery = { path = "../../../substrate/primitives/authority-discovery" } -consensus_common = { package = "sp-consensus", path = "../../../substrate/primitives/consensus/common" } -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../substrate/primitives/consensus/beefy" } -grandpa_primitives = { package = "sp-consensus-grandpa", path = "../../../substrate/primitives/consensus/grandpa" } +sp-consensus = { path = "../../../substrate/primitives/consensus/common" } +sp-consensus-beefy = { path = "../../../substrate/primitives/consensus/beefy" } +sp-consensus-grandpa = { path = "../../../substrate/primitives/consensus/grandpa" } sp-inherents = { path = "../../../substrate/primitives/inherents" } sp-keyring = { path = "../../../substrate/primitives/keyring" } sp-api = { path = "../../../substrate/primitives/api" } @@ -148,7 +148,7 @@ xcm-fee-payment-runtime-api = { path = "../../xcm/xcm-fee-payment-runtime-api" } [dev-dependencies] polkadot-test-client = { path = "../test/client" } polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" } env_logger = "0.11" assert_matches = "1.5.0" serial_test = "2.0.0" @@ -157,7 +157,7 @@ tempfile = "3.2" [features] default = ["db", "full-node"] -db = ["service/rocksdb"] +db = ["sc-service/rocksdb"] full-node = [ "kvdb-rocksdb", @@ -214,7 +214,7 @@ runtime-benchmarks = [ "polkadot-test-client/runtime-benchmarks", "rococo-runtime?/runtime-benchmarks", "sc-client-db/runtime-benchmarks", - "service/runtime-benchmarks", + "sc-service/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "westend-runtime?/runtime-benchmarks", "xcm-fee-payment-runtime-api/runtime-benchmarks", diff --git a/polkadot/node/service/src/chain_spec.rs b/polkadot/node/service/src/chain_spec.rs index c7019e3f0b22..0358bc300ab0 100644 --- a/polkadot/node/service/src/chain_spec.rs +++ b/polkadot/node/service/src/chain_spec.rs @@ -16,13 +16,13 @@ //! Polkadot chain configurations. -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; -use grandpa::AuthorityId as GrandpaId; #[cfg(feature = "westend-native")] use pallet_staking::Forcing; use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, ValidatorId}; +use sc_consensus_grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; #[cfg(feature = "westend-native")] use polkadot_primitives::vstaging::SchedulerParams; @@ -31,13 +31,13 @@ use rococo_runtime as rococo; use sc_chain_spec::ChainSpecExtension; #[cfg(any(feature = "westend-native", feature = "rococo-native"))] use sc_chain_spec::ChainType; +#[cfg(any(feature = "westend-native", feature = "rococo-native"))] +use sc_telemetry::TelemetryEndpoints; use serde::{Deserialize, Serialize}; use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::IdentifyAccount; #[cfg(feature = "westend-native")] use sp_runtime::Perbill; -#[cfg(any(feature = "westend-native", feature = "rococo-native"))] -use telemetry::TelemetryEndpoints; #[cfg(feature = "westend-native")] use westend_runtime as westend; #[cfg(feature = "westend-native")] @@ -70,11 +70,11 @@ pub struct Extensions { } // Generic chain spec, in case when we don't have the native runtime. -pub type GenericChainSpec = service::GenericChainSpec; +pub type GenericChainSpec = sc_service::GenericChainSpec; /// The `ChainSpec` parameterized for the westend runtime. #[cfg(feature = "westend-native")] -pub type WestendChainSpec = service::GenericChainSpec; +pub type WestendChainSpec = sc_service::GenericChainSpec; /// The `ChainSpec` parameterized for the westend runtime. // Dummy chain spec, but that is fine when we don't have the native runtime. @@ -83,7 +83,7 @@ pub type WestendChainSpec = GenericChainSpec; /// The `ChainSpec` parameterized for the rococo runtime. #[cfg(feature = "rococo-native")] -pub type RococoChainSpec = service::GenericChainSpec; +pub type RococoChainSpec = sc_service::GenericChainSpec; /// The `ChainSpec` parameterized for the rococo runtime. // Dummy chain spec, but that is fine when we don't have the native runtime. diff --git a/polkadot/node/service/src/fake_runtime_api.rs b/polkadot/node/service/src/fake_runtime_api.rs index 34abc76813ff..dd8a0a7e635b 100644 --- a/polkadot/node/service/src/fake_runtime_api.rs +++ b/polkadot/node/service/src/fake_runtime_api.rs @@ -19,8 +19,6 @@ //! These are used to provide a type that implements these runtime APIs without requiring to import //! the native runtimes. -use beefy_primitives::ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}; -use grandpa_primitives::AuthorityId as GrandpaId; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use polkadot_primitives::{ runtime_api, slashing, AccountId, AuthorityDiscoveryId, Balance, Block, BlockNumber, @@ -30,6 +28,8 @@ use polkadot_primitives::{ ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, }; +use sp_consensus_beefy::ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}; +use sp_consensus_grandpa::AuthorityId as GrandpaId; use sp_core::OpaqueMetadata; use sp_runtime::{ @@ -232,30 +232,30 @@ sp_api::impl_runtime_apis! { } } - impl beefy_primitives::BeefyApi for Runtime { + impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { unimplemented!() } - fn validator_set() -> Option> { + fn validator_set() -> Option> { unimplemented!() } fn submit_report_equivocation_unsigned_extrinsic( - _: beefy_primitives::DoubleVotingProof< + _: sp_consensus_beefy::DoubleVotingProof< BlockNumber, BeefyId, BeefySignature, >, - _: beefy_primitives::OpaqueKeyOwnershipProof, + _: sp_consensus_beefy::OpaqueKeyOwnershipProof, ) -> Option<()> { unimplemented!() } fn generate_key_ownership_proof( - _: beefy_primitives::ValidatorSetId, + _: sp_consensus_beefy::ValidatorSetId, _: BeefyId, - ) -> Option { + ) -> Option { unimplemented!() } } @@ -291,29 +291,29 @@ sp_api::impl_runtime_apis! { } } - impl grandpa_primitives::GrandpaApi for Runtime { + impl sp_consensus_grandpa::GrandpaApi for Runtime { fn grandpa_authorities() -> Vec<(GrandpaId, u64)> { unimplemented!() } - fn current_set_id() -> grandpa_primitives::SetId { + fn current_set_id() -> sp_consensus_grandpa::SetId { unimplemented!() } fn submit_report_equivocation_unsigned_extrinsic( - _: grandpa_primitives::EquivocationProof< + _: sp_consensus_grandpa::EquivocationProof< ::Hash, sp_runtime::traits::NumberFor, >, - _: grandpa_primitives::OpaqueKeyOwnershipProof, + _: sp_consensus_grandpa::OpaqueKeyOwnershipProof, ) -> Option<()> { unimplemented!() } fn generate_key_ownership_proof( - _: grandpa_primitives::SetId, - _: grandpa_primitives::AuthorityId, - ) -> Option { + _: sp_consensus_grandpa::SetId, + _: sp_consensus_grandpa::AuthorityId, + ) -> Option { unimplemented!() } } diff --git a/polkadot/node/service/src/grandpa_support.rs b/polkadot/node/service/src/grandpa_support.rs index 729dbfde5c76..c85d5eb32b19 100644 --- a/polkadot/node/service/src/grandpa_support.rs +++ b/polkadot/node/service/src/grandpa_support.rs @@ -64,7 +64,7 @@ where /// w3f validators and randomly selected validators from the latest session (at /// #1500988). #[cfg(feature = "full-node")] -pub(crate) fn kusama_hard_forks() -> Vec> { +pub(crate) fn kusama_hard_forks() -> Vec> { use sp_core::crypto::Ss58Codec; use std::str::FromStr; @@ -141,7 +141,7 @@ pub(crate) fn kusama_hard_forks() -> Vec> { .into_iter() .map(|address| { ( - grandpa_primitives::AuthorityId::from_ss58check(address) + sp_consensus_grandpa::AuthorityId::from_ss58check(address) .expect("hard fork authority addresses are static and they should be carefully defined; qed."), 1, ) @@ -154,7 +154,7 @@ pub(crate) fn kusama_hard_forks() -> Vec> { let hash = Hash::from_str(hash) .expect("hard fork hashes are static and they should be carefully defined; qed."); - grandpa::AuthoritySetHardFork { + sc_consensus_grandpa::AuthoritySetHardFork { set_id, block: (hash, number), authorities: authorities.clone(), diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index 9ee81f80d66a..b4f63bd2aa06 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -41,7 +41,6 @@ mod tests; #[cfg(feature = "full-node")] use { - grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}, gum::info, polkadot_node_core_approval_voting::{ self as approval_voting_subsystem, Config as ApprovalVotingConfig, @@ -58,6 +57,7 @@ use { request_response::ReqProtocolNames, }, sc_client_api::BlockBackend, + sc_consensus_grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}, sc_transaction_pool_api::OffchainTransactionPoolFactory, sp_core::traits::SpawnNamed, }; @@ -82,15 +82,13 @@ use std::{collections::HashMap, path::PathBuf, sync::Arc, time::Duration}; use prometheus_endpoint::Registry; #[cfg(feature = "full-node")] -use service::KeystoreContainer; -use service::RpcHandlers; -use telemetry::TelemetryWorker; +use sc_service::KeystoreContainer; +use sc_service::RpcHandlers; +use sc_telemetry::TelemetryWorker; #[cfg(feature = "full-node")] -use telemetry::{Telemetry, TelemetryWorkerHandle}; +use sc_telemetry::{Telemetry, TelemetryWorkerHandle}; -use beefy_primitives::ecdsa_crypto; pub use chain_spec::{GenericChainSpec, RococoChainSpec, WestendChainSpec}; -pub use consensus_common::{Proposal, SelectChain}; use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; use mmr_gadget::MmrGadget; use polkadot_node_subsystem_types::DefaultSubsystemClient; @@ -99,12 +97,14 @@ pub use sc_client_api::{Backend, CallExecutor}; pub use sc_consensus::{BlockImport, LongestChain}; pub use sc_executor::NativeExecutionDispatch; use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; -pub use service::{ +pub use sc_service::{ config::{DatabaseSource, PrometheusConfig}, ChainSpec, Configuration, Error as SubstrateServiceError, PruningMode, Role, TFullBackend, TFullCallExecutor, TFullClient, TaskManager, TransactionPoolOptions, }; pub use sp_api::{ApiRef, ConstructRuntimeApi, Core as CoreApi, ProvideRuntimeApi}; +pub use sp_consensus::{Proposal, SelectChain}; +use sp_consensus_beefy::ecdsa_crypto; pub use sp_runtime::{ generic, traits::{self as runtime_traits, BlakeTwo256, Block as BlockT, Header as HeaderT, NumberFor}, @@ -118,10 +118,10 @@ pub use {westend_runtime, westend_runtime_constants}; pub use fake_runtime_api::{GetLastTimestamp, RuntimeApi}; #[cfg(feature = "full-node")] -pub type FullBackend = service::TFullBackend; +pub type FullBackend = sc_service::TFullBackend; #[cfg(feature = "full-node")] -pub type FullClient = service::TFullClient< +pub type FullClient = sc_service::TFullClient< Block, RuntimeApi, WasmExecutor<(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions)>, @@ -210,7 +210,7 @@ pub enum Error { Blockchain(#[from] sp_blockchain::Error), #[error(transparent)] - Consensus(#[from] consensus_common::Error), + Consensus(#[from] sp_consensus::Error), #[error("Failed to create an overseer")] Overseer(#[from] polkadot_overseer::SubsystemError), @@ -219,7 +219,7 @@ pub enum Error { Prometheus(#[from] prometheus_endpoint::PrometheusError), #[error(transparent)] - Telemetry(#[from] telemetry::Error), + Telemetry(#[from] sc_telemetry::Error), #[error(transparent)] Jaeger(#[from] polkadot_node_subsystem::jaeger::JaegerError), @@ -393,10 +393,16 @@ fn jaeger_launch_collector_with_agent( type FullSelectChain = relay_chain_selection::SelectRelayChain; #[cfg(feature = "full-node")] type FullGrandpaBlockImport = - grandpa::GrandpaBlockImport; + sc_consensus_grandpa::GrandpaBlockImport; #[cfg(feature = "full-node")] type FullBeefyBlockImport = - beefy::import::BeefyBlockImport; + sc_consensus_beefy::import::BeefyBlockImport< + Block, + FullBackend, + FullClient, + InnerBlockImport, + AuthorityId, + >; #[cfg(feature = "full-node")] struct Basics { @@ -417,7 +423,7 @@ fn new_partial_basics( .telemetry_endpoints .clone() .filter(|x| !x.is_empty()) - .map(move |endpoints| -> Result<_, telemetry::Error> { + .map(move |endpoints| -> Result<_, sc_telemetry::Error> { let (worker, mut worker_handle) = if let Some(worker_handle) = telemetry_worker_handle { (None, worker_handle) } else { @@ -443,7 +449,7 @@ fn new_partial_basics( .build(); let (client, backend, keystore_container, task_manager) = - service::new_full_parts::( + sc_service::new_full_parts::( &config, telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), executor, @@ -472,7 +478,7 @@ fn new_partial( Basics { task_manager, backend, client, keystore_container, telemetry }: Basics, select_chain: ChainSelection, ) -> Result< - service::PartialComponents< + sc_service::PartialComponents< FullClient, FullBackend, ChainSelection, @@ -484,7 +490,7 @@ fn new_partial( polkadot_rpc::SubscriptionTaskExecutor, ) -> Result, ( - babe::BabeBlockImport< + sc_consensus_babe::BabeBlockImport< Block, FullClient, FullBeefyBlockImport< @@ -492,11 +498,11 @@ fn new_partial( ecdsa_crypto::AuthorityId, >, >, - grandpa::LinkHalf, - babe::BabeLink, - beefy::BeefyVoterLinks, + sc_consensus_grandpa::LinkHalf, + sc_consensus_babe::BabeLink, + sc_consensus_beefy::BeefyVoterLinks, ), - grandpa::SharedVoterState, + sc_consensus_grandpa::SharedVoterState, sp_consensus_babe::SlotDuration, Option, ), @@ -520,55 +526,57 @@ where Vec::new() }; - let (grandpa_block_import, grandpa_link) = grandpa::block_import_with_authority_set_hard_forks( - client.clone(), - GRANDPA_JUSTIFICATION_PERIOD, - &(client.clone() as Arc<_>), - select_chain.clone(), - grandpa_hard_forks, - telemetry.as_ref().map(|x| x.handle()), - )?; + let (grandpa_block_import, grandpa_link) = + sc_consensus_grandpa::block_import_with_authority_set_hard_forks( + client.clone(), + GRANDPA_JUSTIFICATION_PERIOD, + &(client.clone() as Arc<_>), + select_chain.clone(), + grandpa_hard_forks, + telemetry.as_ref().map(|x| x.handle()), + )?; let justification_import = grandpa_block_import.clone(); let (beefy_block_import, beefy_voter_links, beefy_rpc_links) = - beefy::beefy_block_import_and_links( + sc_consensus_beefy::beefy_block_import_and_links( grandpa_block_import, backend.clone(), client.clone(), config.prometheus_registry().cloned(), ); - let babe_config = babe::configuration(&*client)?; + let babe_config = sc_consensus_babe::configuration(&*client)?; let (block_import, babe_link) = - babe::block_import(babe_config.clone(), beefy_block_import, client.clone())?; + sc_consensus_babe::block_import(babe_config.clone(), beefy_block_import, client.clone())?; let slot_duration = babe_link.config().slot_duration(); - let (import_queue, babe_worker_handle) = babe::import_queue(babe::ImportQueueParams { - link: babe_link.clone(), - block_import: block_import.clone(), - justification_import: Some(Box::new(justification_import)), - client: client.clone(), - select_chain: select_chain.clone(), - create_inherent_data_providers: move |_, ()| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + let (import_queue, babe_worker_handle) = + sc_consensus_babe::import_queue(sc_consensus_babe::ImportQueueParams { + link: babe_link.clone(), + block_import: block_import.clone(), + justification_import: Some(Box::new(justification_import)), + client: client.clone(), + select_chain: select_chain.clone(), + create_inherent_data_providers: move |_, ()| async move { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - let slot = + let slot = sp_consensus_babe::inherents::InherentDataProvider::from_timestamp_and_slot_duration( *timestamp, slot_duration, ); - Ok((slot, timestamp)) - }, - spawner: &task_manager.spawn_essential_handle(), - registry: config.prometheus_registry(), - telemetry: telemetry.as_ref().map(|x| x.handle()), - offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()), - })?; + Ok((slot, timestamp)) + }, + spawner: &task_manager.spawn_essential_handle(), + registry: config.prometheus_registry(), + telemetry: telemetry.as_ref().map(|x| x.handle()), + offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool.clone()), + })?; let justification_stream = grandpa_link.justification_stream(); let shared_authority_set = grandpa_link.shared_authority_set().clone(); - let shared_voter_state = grandpa::SharedVoterState::empty(); + let shared_voter_state = sc_consensus_grandpa::SharedVoterState::empty(); let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service( backend.clone(), Some(shared_authority_set.clone()), @@ -587,7 +595,7 @@ where move |deny_unsafe, subscription_executor: polkadot_rpc::SubscriptionTaskExecutor| - -> Result { + -> Result { let deps = polkadot_rpc::FullDeps { client: client.clone(), pool: transaction_pool.clone(), @@ -617,7 +625,7 @@ where } }; - Ok(service::PartialComponents { + Ok(sc_service::PartialComponents { client, backend, task_manager, @@ -812,7 +820,7 @@ pub fn new_full< SelectRelayChain::new_longest_chain(basics.backend.clone()) }; - let service::PartialComponents::<_, _, SelectRelayChain<_>, _, _, _> { + let sc_service::PartialComponents::<_, _, SelectRelayChain<_>, _, _, _> { client, backend, mut task_manager, @@ -839,9 +847,10 @@ pub fn new_full< // Note: GrandPa is pushed before the Polkadot-specific protocols. This doesn't change // anything in terms of behaviour, but makes the logs more consistent with the other // Substrate nodes. - let grandpa_protocol_name = grandpa::protocol_standard_name(&genesis_hash, &config.chain_spec); + let grandpa_protocol_name = + sc_consensus_grandpa::protocol_standard_name(&genesis_hash, &config.chain_spec); let (grandpa_protocol_config, grandpa_notification_service) = - grandpa::grandpa_peers_set_config::<_, Network>( + sc_consensus_grandpa::grandpa_peers_set_config::<_, Network>( grandpa_protocol_name.clone(), metrics.clone(), Arc::clone(&peer_store_handle), @@ -849,21 +858,19 @@ pub fn new_full< net_config.add_notification_protocol(grandpa_protocol_config); let beefy_gossip_proto_name = - beefy::gossip_protocol_name(&genesis_hash, config.chain_spec.fork_id()); + sc_consensus_beefy::gossip_protocol_name(&genesis_hash, config.chain_spec.fork_id()); // `beefy_on_demand_justifications_handler` is given to `beefy-gadget` task to be run, // while `beefy_req_resp_cfg` is added to `config.network.request_response_protocols`. let (beefy_on_demand_justifications_handler, beefy_req_resp_cfg) = - beefy::communication::request_response::BeefyJustifsRequestHandler::new::<_, Network>( - &genesis_hash, - config.chain_spec.fork_id(), - client.clone(), - prometheus_registry.clone(), - ); + sc_consensus_beefy::communication::request_response::BeefyJustifsRequestHandler::new::< + _, + Network, + >(&genesis_hash, config.chain_spec.fork_id(), client.clone(), prometheus_registry.clone()); let beefy_notification_service = match enable_beefy { false => None, true => { let (beefy_notification_config, beefy_notification_service) = - beefy::communication::beefy_peers_set_config::<_, Network>( + sc_consensus_beefy::communication::beefy_peers_set_config::<_, Network>( beefy_gossip_proto_name.clone(), metrics.clone(), Arc::clone(&peer_store_handle), @@ -932,7 +939,7 @@ pub fn new_full< Vec::new() }; - let warp_sync = Arc::new(grandpa::warp_proof::NetworkProvider::new( + let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new( backend.clone(), import_setup.1.shared_authority_set().clone(), grandpa_hard_forks, @@ -1020,7 +1027,7 @@ pub fn new_full< }; let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = - service::build_network(service::BuildNetworkParams { + sc_service::build_network(sc_service::BuildNetworkParams { config: &config, net_config, client: client.clone(), @@ -1056,7 +1063,7 @@ pub fn new_full< ); } - let rpc_handlers = service::spawn_tasks(service::SpawnTasksParams { + let rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { config, backend: backend.clone(), client: client.clone(), @@ -1152,7 +1159,7 @@ pub fn new_full< let overseer_handle = if let Some(authority_discovery_service) = authority_discovery_service { let (overseer, overseer_handle) = overseer_gen - .generate::>( + .generate::>( overseer_connector, OverseerGenArgs { runtime_client, @@ -1224,7 +1231,7 @@ pub fn new_full< let overseer_handle = overseer_handle.as_ref().ok_or(Error::AuthoritiesRequireRealOverseer)?.clone(); let slot_duration = babe_link.config().slot_duration(); - let babe_config = babe::BabeParams { + let babe_config = sc_consensus_babe::BabeParams { keystore: keystore_container.keystore(), client: client.clone(), select_chain, @@ -1258,12 +1265,12 @@ pub fn new_full< force_authoring, backoff_authoring_blocks, babe_link, - block_proposal_slot_portion: babe::SlotProportion::new(2f32 / 3f32), + block_proposal_slot_portion: sc_consensus_babe::SlotProportion::new(2f32 / 3f32), max_block_proposal_slot_portion: None, telemetry: telemetry.as_ref().map(|x| x.handle()), }; - let babe = babe::start_babe(babe_config)?; + let babe = sc_consensus_babe::start_babe(babe_config)?; task_manager.spawn_essential_handle().spawn_blocking("babe", None, babe); } @@ -1274,7 +1281,7 @@ pub fn new_full< // beefy is enabled if its notification service exists if let Some(notification_service) = beefy_notification_service { let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name(); - let network_params = beefy::BeefyNetworkParams { + let network_params = sc_consensus_beefy::BeefyNetworkParams { network: Arc::new(network.clone()), sync: sync_service.clone(), gossip_protocol_name: beefy_gossip_proto_name, @@ -1282,8 +1289,8 @@ pub fn new_full< notification_service, _phantom: core::marker::PhantomData::, }; - let payload_provider = beefy_primitives::mmr::MmrRootProvider::new(client.clone()); - let beefy_params = beefy::BeefyParams { + let payload_provider = sp_consensus_beefy::mmr::MmrRootProvider::new(client.clone()); + let beefy_params = sc_consensus_beefy::BeefyParams { client: client.clone(), backend: backend.clone(), payload_provider, @@ -1297,9 +1304,16 @@ pub fn new_full< is_authority: role.is_authority(), }; - let gadget = beefy::start_beefy_gadget::<_, _, _, _, _, _, _, ecdsa_crypto::AuthorityId>( - beefy_params, - ); + let gadget = sc_consensus_beefy::start_beefy_gadget::< + _, + _, + _, + _, + _, + _, + _, + ecdsa_crypto::AuthorityId, + >(beefy_params); // BEEFY is part of consensus, if it fails we'll bring the node down with it to make sure it // is noticed. @@ -1320,7 +1334,7 @@ pub fn new_full< ); } - let config = grandpa::Config { + let config = sc_consensus_grandpa::Config { // FIXME substrate#1578 make this available through chainspec // Grandpa performance can be improved a bit by tuning this parameter, see: // https://github.com/paritytech/polkadot/issues/5464 @@ -1343,17 +1357,18 @@ pub fn new_full< // provide better guarantees of block and vote data availability than // the observer. - let mut voting_rules_builder = grandpa::VotingRulesBuilder::default(); + let mut voting_rules_builder = sc_consensus_grandpa::VotingRulesBuilder::default(); #[cfg(not(feature = "malus"))] let _malus_finality_delay = None; if let Some(delay) = _malus_finality_delay { info!(?delay, "Enabling malus finality delay",); - voting_rules_builder = voting_rules_builder.add(grandpa::BeforeBestBlockBy(delay)); + voting_rules_builder = + voting_rules_builder.add(sc_consensus_grandpa::BeforeBestBlockBy(delay)); }; - let grandpa_config = grandpa::GrandpaParams { + let grandpa_config = sc_consensus_grandpa::GrandpaParams { config, link: link_half, network: network.clone(), @@ -1369,7 +1384,7 @@ pub fn new_full< task_manager.spawn_essential_handle().spawn_blocking( "grandpa-voter", None, - grandpa::run_grandpa_voter(grandpa_config)?, + sc_consensus_grandpa::run_grandpa_voter(grandpa_config)?, ); } @@ -1398,7 +1413,7 @@ macro_rules! chain_ops { // use the longest chain selection, since there is no overseer available let chain_selection = LongestChain::new(basics.backend.clone()); - let service::PartialComponents { client, backend, import_queue, task_manager, .. } = + let sc_service::PartialComponents { client, backend, import_queue, task_manager, .. } = new_partial::>(&mut config, basics, chain_selection)?; Ok((client, backend, import_queue, task_manager)) }}; @@ -1411,7 +1426,7 @@ pub fn new_chain_ops( jaeger_agent: Option, ) -> Result<(Arc, Arc, sc_consensus::BasicQueue, TaskManager), Error> { - config.keystore = service::config::KeystoreConfig::InMemory; + config.keystore = sc_service::config::KeystoreConfig::InMemory; if config.chain_spec.is_rococo() || config.chain_spec.is_wococo() || @@ -1489,8 +1504,8 @@ pub fn revert_backend( revert_approval_voting(parachains_db.clone(), hash)?; revert_chain_selection(parachains_db, hash)?; // Revert Substrate consensus related components - babe::revert(client.clone(), backend, blocks)?; - grandpa::revert(client, blocks)?; + sc_consensus_babe::revert(client.clone(), backend, blocks)?; + sc_consensus_grandpa::revert(client, blocks)?; Ok(()) } @@ -1519,7 +1534,7 @@ fn revert_approval_voting(db: Arc, hash: Hash) -> sp_blockchain::R config, db, Arc::new(sc_keystore::LocalKeystore::in_memory()), - Box::new(consensus_common::NoNetwork), + Box::new(sp_consensus::NoNetwork), approval_voting_subsystem::Metrics::default(), ); diff --git a/polkadot/node/service/src/overseer.rs b/polkadot/node/service/src/overseer.rs index 6f35718cd18f..5f4db99b00ef 100644 --- a/polkadot/node/service/src/overseer.rs +++ b/polkadot/node/service/src/overseer.rs @@ -82,7 +82,7 @@ where /// Underlying network service implementation. pub network_service: Arc, /// Underlying syncing service implementation. - pub sync_service: Arc, + pub sync_service: Arc, /// Underlying authority discovery service. pub authority_discovery_service: AuthorityDiscoveryService, /// Collations request receiver for network protocol v1. diff --git a/polkadot/node/service/src/parachains_db/upgrade.rs b/polkadot/node/service/src/parachains_db/upgrade.rs index 4d7370859609..808acf04b4e7 100644 --- a/polkadot/node/service/src/parachains_db/upgrade.rs +++ b/polkadot/node/service/src/parachains_db/upgrade.rs @@ -463,7 +463,7 @@ mod tests { v3::migration_helpers::{v1_to_latest_sanity_check, v2_fill_test_data}, }; use polkadot_node_subsystem_util::database::kvdb_impl::DbAdapter; - use test_helpers::dummy_candidate_receipt; + use polkadot_primitives_test_helpers::dummy_candidate_receipt; #[test] fn test_paritydb_migrate_0_to_1() { diff --git a/polkadot/node/service/src/relay_chain_selection.rs b/polkadot/node/service/src/relay_chain_selection.rs index c5546c34bdba..c0b1ce8b0ebe 100644 --- a/polkadot/node/service/src/relay_chain_selection.rs +++ b/polkadot/node/service/src/relay_chain_selection.rs @@ -36,7 +36,6 @@ #![cfg(feature = "full-node")] use super::{HeaderProvider, HeaderProviderProvider}; -use consensus_common::{Error as ConsensusError, SelectChain}; use futures::channel::oneshot; use polkadot_node_primitives::MAX_FINALITY_LAG as PRIMITIVES_MAX_FINALITY_LAG; use polkadot_node_subsystem::messages::{ @@ -46,9 +45,10 @@ use polkadot_node_subsystem::messages::{ use polkadot_node_subsystem_util::metrics::{self, prometheus}; use polkadot_overseer::{AllMessages, Handle}; use polkadot_primitives::{Block as PolkadotBlock, BlockNumber, Hash, Header as PolkadotHeader}; +use sp_consensus::{Error as ConsensusError, SelectChain}; use std::sync::Arc; -pub use service::SpawnTaskHandle; +pub use sc_service::SpawnTaskHandle; /// The maximum amount of unfinalized blocks we are willing to allow due to approval checking /// or disputes. diff --git a/polkadot/node/service/src/tests.rs b/polkadot/node/service/src/tests.rs index 26c8083185d8..bebd05071013 100644 --- a/polkadot/node/service/src/tests.rs +++ b/polkadot/node/service/src/tests.rs @@ -19,7 +19,6 @@ use super::{relay_chain_selection::*, *}; use futures::channel::oneshot::Receiver; use polkadot_node_primitives::approval::v2::VrfSignature; use polkadot_node_subsystem::messages::{AllMessages, BlockDescription}; -use polkadot_node_subsystem_test_helpers as test_helpers; use polkadot_node_subsystem_util::TimeoutExt; use polkadot_test_client::Sr25519Keyring; use sp_consensus_babe::{ @@ -46,7 +45,8 @@ use polkadot_primitives::{Block, BlockNumber, Hash, Header}; use polkadot_node_subsystem_test_helpers::TestSubsystemSender; use polkadot_overseer::{SubsystemContext, SubsystemSender}; -type VirtualOverseer = test_helpers::TestSubsystemContextHandle; +type VirtualOverseer = + polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle; #[async_trait::async_trait] impl OverseerHandleT for TestSubsystemSender { @@ -76,7 +76,8 @@ fn test_harness>( .try_init(); let pool = TaskExecutor::new(); - let (mut context, virtual_overseer) = test_helpers::make_subsystem_context(pool); + let (mut context, virtual_overseer) = + polkadot_node_subsystem_test_helpers::make_subsystem_context(pool); let (finality_target_tx, finality_target_rx) = oneshot::channel::>(); diff --git a/polkadot/node/subsystem-bench/Cargo.toml b/polkadot/node/subsystem-bench/Cargo.toml index ebd9322e9f74..5001104f929a 100644 --- a/polkadot/node/subsystem-bench/Cargo.toml +++ b/polkadot/node/subsystem-bench/Cargo.toml @@ -56,7 +56,7 @@ rand_distr = "0.4.3" bitvec = "1.0.1" kvdb-memorydb = "0.13.0" -parity-scale-codec = { version = "3.6.12", features = ["derive", "std"] } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["derive", "std"] } tokio = { version = "1.24.2", features = ["parking_lot", "rt-multi-thread"] } clap-num = "1.0.2" polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" } @@ -69,7 +69,7 @@ sp-consensus = { path = "../../../substrate/primitives/consensus/common" } polkadot-node-metrics = { path = "../metrics" } itertools = "0.11" polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" } -prometheus_endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } prometheus = { version = "0.13.0", default-features = false } serde = { workspace = true, default-features = true } serde_yaml = { workspace = true } @@ -87,7 +87,7 @@ rand_core = "0.6.2" rand_chacha = { version = "0.3.1" } paste = "1.0.14" orchestra = { version = "0.3.5", default-features = false, features = ["futures_channel"] } -pyroscope = "0.5.7" +pyroscope = { version = "0.5.7" } pyroscope_pprofrs = "0.2.7" strum = { version = "0.24", features = ["derive"] } diff --git a/polkadot/node/subsystem-bench/src/lib/approval/message_generator.rs b/polkadot/node/subsystem-bench/src/lib/approval/message_generator.rs index e4a6c207970f..6d3e7dd92db1 100644 --- a/polkadot/node/subsystem-bench/src/lib/approval/message_generator.rs +++ b/polkadot/node/subsystem-bench/src/lib/approval/message_generator.rs @@ -25,9 +25,9 @@ use crate::{ mock::runtime_api::session_info_for_peers, NODE_UNDER_TEST, }; +use codec::Encode; use futures::SinkExt; use itertools::Itertools; -use parity_scale_codec::Encode; use polkadot_node_core_approval_voting::{ criteria::{compute_assignments, Config}, time::tranche_to_tick, diff --git a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs index 2e5831276ad3..5c0c65b11cdb 100644 --- a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs +++ b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs @@ -40,12 +40,12 @@ use crate::{ usage::BenchmarkUsage, NODE_UNDER_TEST, }; +use codec::{Decode, Encode}; use colored::Colorize; use futures::channel::oneshot; use itertools::Itertools; use orchestra::TimeoutExt; use overseer::{metrics::Metrics as OverseerMetrics, MetricsTrait}; -use parity_scale_codec::{Decode, Encode}; use polkadot_approval_distribution::ApprovalDistribution; use polkadot_node_core_approval_voting::{ time::{slot_number_to_tick, tick_to_slot_number, Clock, ClockExt, SystemClock}, diff --git a/polkadot/node/subsystem-bench/src/lib/approval/test_message.rs b/polkadot/node/subsystem-bench/src/lib/approval/test_message.rs index 9641b62a94d8..d23c2552b8b3 100644 --- a/polkadot/node/subsystem-bench/src/lib/approval/test_message.rs +++ b/polkadot/node/subsystem-bench/src/lib/approval/test_message.rs @@ -18,8 +18,8 @@ use crate::{ approval::{ApprovalsOptions, BlockTestData, CandidateTestData}, configuration::TestAuthorities, }; +use codec::{Decode, Encode}; use itertools::Itertools; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_network_protocol::v3 as protocol_v3; use polkadot_primitives::{CandidateIndex, Hash, ValidatorIndex}; use sc_network_types::PeerId; diff --git a/polkadot/node/subsystem-bench/src/lib/availability/mod.rs b/polkadot/node/subsystem-bench/src/lib/availability/mod.rs index 52944ffb08f3..32dc8ae2c8dc 100644 --- a/polkadot/node/subsystem-bench/src/lib/availability/mod.rs +++ b/polkadot/node/subsystem-bench/src/lib/availability/mod.rs @@ -33,7 +33,7 @@ use crate::{ use colored::Colorize; use futures::{channel::oneshot, stream::FuturesUnordered, StreamExt}; -use parity_scale_codec::Encode; +use codec::Encode; use polkadot_availability_bitfield_distribution::BitfieldDistribution; use polkadot_availability_distribution::{ AvailabilityDistributionSubsystem, IncomingRequestReceivers, diff --git a/polkadot/node/subsystem-bench/src/lib/availability/test_state.rs b/polkadot/node/subsystem-bench/src/lib/availability/test_state.rs index 5d443734bb38..173b23f6b76e 100644 --- a/polkadot/node/subsystem-bench/src/lib/availability/test_state.rs +++ b/polkadot/node/subsystem-bench/src/lib/availability/test_state.rs @@ -20,9 +20,9 @@ use crate::{ mock::runtime_api::node_features_with_chunk_mapping_enabled, }; use bitvec::bitvec; +use codec::Encode; use colored::Colorize; use itertools::Itertools; -use parity_scale_codec::Encode; use polkadot_node_network_protocol::{ request_response::{v2::ChunkFetchingRequest, ReqProtocolNames}, Versioned, VersionedValidationProtocol, diff --git a/polkadot/node/subsystem-bench/src/lib/mock/av_store.rs b/polkadot/node/subsystem-bench/src/lib/mock/av_store.rs index 14ec4ccb4c32..7586e848ab47 100644 --- a/polkadot/node/subsystem-bench/src/lib/mock/av_store.rs +++ b/polkadot/node/subsystem-bench/src/lib/mock/av_store.rs @@ -17,8 +17,8 @@ //! A generic av store subsystem mockup suitable to be used in benchmarks. use crate::network::{HandleNetworkMessage, NetworkMessage}; +use codec::Encode; use futures::{channel::oneshot, FutureExt}; -use parity_scale_codec::Encode; use polkadot_node_network_protocol::request_response::{ v1::AvailableDataFetchingResponse, v2::ChunkFetchingResponse, Protocol, ReqProtocolNames, Requests, diff --git a/polkadot/node/subsystem-bench/src/lib/network.rs b/polkadot/node/subsystem-bench/src/lib/network.rs index 775f881eaad8..331dd7d25156 100644 --- a/polkadot/node/subsystem-bench/src/lib/network.rs +++ b/polkadot/node/subsystem-bench/src/lib/network.rs @@ -38,6 +38,7 @@ use crate::{ environment::TestEnvironmentDependencies, NODE_UNDER_TEST, }; +use codec::Encode; use colored::Colorize; use futures::{ channel::{ @@ -55,7 +56,6 @@ use net_protocol::{ request_response::{Recipient, Requests, ResponseSender}, ObservedRole, VersionedValidationProtocol, View, }; -use parity_scale_codec::Encode; use polkadot_node_network_protocol::{self as net_protocol, Versioned}; use polkadot_node_subsystem::messages::StatementDistributionMessage; use polkadot_node_subsystem_types::messages::NetworkBridgeEvent; diff --git a/polkadot/node/subsystem-bench/src/lib/statement/test_state.rs b/polkadot/node/subsystem-bench/src/lib/statement/test_state.rs index b8ea64c7e331..88b5e8b76b62 100644 --- a/polkadot/node/subsystem-bench/src/lib/statement/test_state.rs +++ b/polkadot/node/subsystem-bench/src/lib/statement/test_state.rs @@ -21,9 +21,9 @@ use crate::{ NODE_UNDER_TEST, }; use bitvec::vec::BitVec; +use codec::{Decode, Encode}; use futures::channel::oneshot; use itertools::Itertools; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_network_protocol::{ request_response::{ v2::{AttestedCandidateRequest, AttestedCandidateResponse}, diff --git a/polkadot/node/subsystem-types/Cargo.toml b/polkadot/node/subsystem-types/Cargo.toml index e03fc60a1fd7..0178b193cba8 100644 --- a/polkadot/node/subsystem-types/Cargo.toml +++ b/polkadot/node/subsystem-types/Cargo.toml @@ -29,7 +29,7 @@ sp-authority-discovery = { path = "../../../substrate/primitives/authority-disco sc-client-api = { path = "../../../substrate/client/api" } sc-transaction-pool-api = { path = "../../../substrate/client/transaction-pool/api" } smallvec = "1.8.0" -substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } thiserror = { workspace = true } async-trait = "0.1.79" bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } diff --git a/polkadot/node/subsystem-types/src/errors.rs b/polkadot/node/subsystem-types/src/errors.rs index b8e70641243e..8e1b515c8db0 100644 --- a/polkadot/node/subsystem-types/src/errors.rs +++ b/polkadot/node/subsystem-types/src/errors.rs @@ -107,7 +107,7 @@ pub enum SubsystemError { Infallible(#[from] std::convert::Infallible), #[error(transparent)] - Prometheus(#[from] substrate_prometheus_endpoint::PrometheusError), + Prometheus(#[from] prometheus_endpoint::PrometheusError), #[error(transparent)] Jaeger(#[from] JaegerError), diff --git a/polkadot/node/subsystem-util/Cargo.toml b/polkadot/node/subsystem-util/Cargo.toml index 9259ca94f073..b7fb75b94b2c 100644 --- a/polkadot/node/subsystem-util/Cargo.toml +++ b/polkadot/node/subsystem-util/Cargo.toml @@ -14,7 +14,7 @@ async-trait = "0.1.79" futures = "0.3.30" futures-channel = "0.3.23" itertools = "0.11" -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } parking_lot = "0.12.1" pin-project = "1.0.9" rand = "0.8.5" @@ -24,7 +24,7 @@ gum = { package = "tracing-gum", path = "../gum" } derive_more = "0.99.17" schnellru = "0.2.1" -erasure-coding = { package = "polkadot-erasure-coding", path = "../../erasure-coding" } +polkadot-erasure-coding = { path = "../../erasure-coding" } polkadot-node-subsystem = { path = "../subsystem" } polkadot-node-subsystem-types = { path = "../subsystem-types" } polkadot-node-jaeger = { path = "../jaeger" } diff --git a/polkadot/node/subsystem-util/src/availability_chunks.rs b/polkadot/node/subsystem-util/src/availability_chunks.rs index 45168e4512e1..651dd3633cfc 100644 --- a/polkadot/node/subsystem-util/src/availability_chunks.rs +++ b/polkadot/node/subsystem-util/src/availability_chunks.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use erasure_coding::systematic_recovery_threshold; +use polkadot_erasure_coding::systematic_recovery_threshold; use polkadot_primitives::{node_features, ChunkIndex, CoreIndex, NodeFeatures, ValidatorIndex}; /// Compute the per-validator availability chunk index. @@ -26,7 +26,7 @@ pub fn availability_chunk_index( n_validators: usize, core_index: CoreIndex, validator_index: ValidatorIndex, -) -> Result { +) -> Result { if let Some(features) = maybe_node_features { if let Some(&true) = features .get(usize::from(node_features::FeatureIndex::AvailabilityChunkMapping as u8)) @@ -51,7 +51,7 @@ pub fn availability_chunk_indices( maybe_node_features: Option<&NodeFeatures>, n_validators: usize, core_index: CoreIndex, -) -> Result, erasure_coding::Error> { +) -> Result, polkadot_erasure_coding::Error> { let identity = (0..n_validators).map(|index| ChunkIndex(index as u32)); if let Some(features) = maybe_node_features { if let Some(&true) = features diff --git a/polkadot/node/subsystem-util/src/lib.rs b/polkadot/node/subsystem-util/src/lib.rs index d371b699b9eb..92f2cd189054 100644 --- a/polkadot/node/subsystem-util/src/lib.rs +++ b/polkadot/node/subsystem-util/src/lib.rs @@ -37,8 +37,8 @@ use polkadot_node_subsystem::{ pub use polkadot_node_metrics::{metrics, Metronome}; +use codec::Encode; use futures::channel::{mpsc, oneshot}; -use parity_scale_codec::Encode; use polkadot_primitives::{ async_backing::BackingState, slashing, AsyncBackingParams, AuthorityDiscoveryId, diff --git a/polkadot/node/subsystem-util/src/runtime/mod.rs b/polkadot/node/subsystem-util/src/runtime/mod.rs index 214c58a8e88f..2c9ec8db3778 100644 --- a/polkadot/node/subsystem-util/src/runtime/mod.rs +++ b/polkadot/node/subsystem-util/src/runtime/mod.rs @@ -18,7 +18,7 @@ use schnellru::{ByLength, LruMap}; -use parity_scale_codec::Encode; +use codec::Encode; use sp_application_crypto::AppCrypto; use sp_core::crypto::ByteArray; use sp_keystore::{Keystore, KeystorePtr}; diff --git a/polkadot/node/test/client/Cargo.toml b/polkadot/node/test/client/Cargo.toml index 55d4d81d1c21..0b49866ee2ae 100644 --- a/polkadot/node/test/client/Cargo.toml +++ b/polkadot/node/test/client/Cargo.toml @@ -10,7 +10,7 @@ license.workspace = true workspace = true [dependencies] -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } # Polkadot dependencies polkadot-test-runtime = { path = "../../../runtime/test-runtime" } diff --git a/polkadot/node/test/client/src/block_builder.rs b/polkadot/node/test/client/src/block_builder.rs index 57e6008917af..71bcdaffac4e 100644 --- a/polkadot/node/test/client/src/block_builder.rs +++ b/polkadot/node/test/client/src/block_builder.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use crate::Client; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_primitives::{Block, InherentData as ParachainsInherentData}; use polkadot_test_runtime::UncheckedExtrinsic; use polkadot_test_service::GetLastTimestamp; diff --git a/polkadot/node/test/service/Cargo.toml b/polkadot/node/test/service/Cargo.toml index 48a206f23c66..3fc6d060870b 100644 --- a/polkadot/node/test/service/Cargo.toml +++ b/polkadot/node/test/service/Cargo.toml @@ -34,13 +34,13 @@ polkadot-runtime-parachains = { path = "../../../runtime/parachains" } # Substrate dependencies sp-authority-discovery = { path = "../../../../substrate/primitives/authority-discovery" } sc-authority-discovery = { path = "../../../../substrate/client/authority-discovery" } -babe = { package = "sc-consensus-babe", path = "../../../../substrate/client/consensus/babe" } -babe-primitives = { package = "sp-consensus-babe", path = "../../../../substrate/primitives/consensus/babe" } -consensus_common = { package = "sp-consensus", path = "../../../../substrate/primitives/consensus/common" } +sc-consensus-babe = { path = "../../../../substrate/client/consensus/babe" } +sp-consensus-babe = { path = "../../../../substrate/primitives/consensus/babe" } +sp-consensus = { path = "../../../../substrate/primitives/consensus/common" } frame-system = { path = "../../../../substrate/frame/system" } -grandpa = { package = "sc-consensus-grandpa", path = "../../../../substrate/client/consensus/grandpa" } -grandpa_primitives = { package = "sp-consensus-grandpa", path = "../../../../substrate/primitives/consensus/grandpa" } -inherents = { package = "sp-inherents", path = "../../../../substrate/primitives/inherents" } +sc-consensus-grandpa = { path = "../../../../substrate/client/consensus/grandpa" } +sp-consensus-grandpa = { path = "../../../../substrate/primitives/consensus/grandpa" } +sp-inherents = { path = "../../../../substrate/primitives/inherents" } pallet-staking = { path = "../../../../substrate/frame/staking" } pallet-balances = { path = "../../../../substrate/frame/balances" } pallet-transaction-payment = { path = "../../../../substrate/frame/transaction-payment" } diff --git a/polkadot/node/test/service/src/chain_spec.rs b/polkadot/node/test/service/src/chain_spec.rs index e6a1229caf86..bd53fd843c69 100644 --- a/polkadot/node/test/service/src/chain_spec.rs +++ b/polkadot/node/test/service/src/chain_spec.rs @@ -16,8 +16,6 @@ //! Chain specifications for the test runtime. -use babe_primitives::AuthorityId as BabeId; -use grandpa::AuthorityId as GrandpaId; use pallet_staking::Forcing; use polkadot_primitives::{ vstaging::SchedulerParams, AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE, @@ -25,7 +23,9 @@ use polkadot_primitives::{ use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions}; use polkadot_test_runtime::BABE_GENESIS_EPOCH_CONFIG; use sc_chain_spec::{ChainSpec, ChainType}; +use sc_consensus_grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; use sp_core::sr25519; use sp_runtime::Perbill; use test_runtime_constants::currency::DOTS; diff --git a/polkadot/node/zombienet-backchannel/Cargo.toml b/polkadot/node/zombienet-backchannel/Cargo.toml index a0233bb46e51..31662ccfc464 100644 --- a/polkadot/node/zombienet-backchannel/Cargo.toml +++ b/polkadot/node/zombienet-backchannel/Cargo.toml @@ -17,7 +17,7 @@ url = "2.3.1" tokio-tungstenite = "0.20.1" futures-util = "0.3.30" lazy_static = "1.4.0" -parity-scale-codec = { version = "3.6.12", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["derive"] } reqwest = { version = "0.11", features = ["rustls-tls"], default-features = false } thiserror = { workspace = true } gum = { package = "tracing-gum", path = "../gum" } diff --git a/polkadot/node/zombienet-backchannel/src/lib.rs b/polkadot/node/zombienet-backchannel/src/lib.rs index fa9218d2d350..9068b03399ca 100644 --- a/polkadot/node/zombienet-backchannel/src/lib.rs +++ b/polkadot/node/zombienet-backchannel/src/lib.rs @@ -19,9 +19,9 @@ //! values in the test specifications, through a bidirectional message passing //! implemented as a `backchannel`. +use codec; use futures_util::{SinkExt, StreamExt}; use lazy_static::lazy_static; -use parity_scale_codec as codec; use serde::{Deserialize, Serialize}; use std::{env, sync::Mutex}; use tokio::sync::broadcast; diff --git a/polkadot/parachain/Cargo.toml b/polkadot/parachain/Cargo.toml index 1344baac64b6..11e8e3ce6d84 100644 --- a/polkadot/parachain/Cargo.toml +++ b/polkadot/parachain/Cargo.toml @@ -13,7 +13,7 @@ workspace = true # note: special care is taken to avoid inclusion of `sp-io` externals when compiling # this crate for WASM. This is critical to avoid forcing all parachain WASM into implementing # various unnecessary Substrate-specific endpoints. -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive", "serde"] } sp-std = { path = "../../substrate/primitives/std", default-features = false } sp-runtime = { path = "../../substrate/primitives/runtime", default-features = false, features = ["serde"] } @@ -31,7 +31,7 @@ default = ["std"] wasm-api = [] std = [ "bounded-collections/std", - "parity-scale-codec/std", + "codec/std", "polkadot-core-primitives/std", "scale-info/std", "serde/std", diff --git a/polkadot/parachain/src/primitives.rs b/polkadot/parachain/src/primitives.rs index 276438436372..d92bbee8d28d 100644 --- a/polkadot/parachain/src/primitives.rs +++ b/polkadot/parachain/src/primitives.rs @@ -20,7 +20,7 @@ use sp_std::vec::Vec; use bounded_collections::{BoundedVec, ConstU32}; -use parity_scale_codec::{CompactAs, Decode, Encode, MaxEncodedLen}; +use codec::{CompactAs, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; use sp_core::{bytes, RuntimeDebug, TypeId}; diff --git a/polkadot/parachain/src/wasm_api.rs b/polkadot/parachain/src/wasm_api.rs index 981d276af75c..f0c832666284 100644 --- a/polkadot/parachain/src/wasm_api.rs +++ b/polkadot/parachain/src/wasm_api.rs @@ -24,7 +24,7 @@ pub unsafe fn load_params(params: *const u8, len: usize) -> crate::primitives::ValidationParams { let mut slice = sp_std::slice::from_raw_parts(params, len); - parity_scale_codec::Decode::decode(&mut slice).expect("Invalid input data") + codec::Decode::decode(&mut slice).expect("Invalid input data") } /// Allocate the validation result in memory, getting the return-pointer back. diff --git a/polkadot/parachain/test-parachains/Cargo.toml b/polkadot/parachain/test-parachains/Cargo.toml index 22f3d2942e0c..c58b11a11b01 100644 --- a/polkadot/parachain/test-parachains/Cargo.toml +++ b/polkadot/parachain/test-parachains/Cargo.toml @@ -12,14 +12,14 @@ workspace = true [dependencies] tiny-keccak = { version = "2.0.2", features = ["keccak"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } -adder = { package = "test-parachain-adder", path = "adder" } -halt = { package = "test-parachain-halt", path = "halt" } +test-parachain-adder = { path = "adder" } +test-parachain-halt = { path = "halt" } [dev-dependencies] sp-core = { path = "../../../substrate/primitives/core" } [features] default = ["std"] -std = ["adder/std", "halt/std", "parity-scale-codec/std"] +std = ["codec/std", "test-parachain-adder/std", "test-parachain-halt/std"] diff --git a/polkadot/parachain/test-parachains/adder/Cargo.toml b/polkadot/parachain/test-parachains/adder/Cargo.toml index 273fa93a50f4..e0bbe177eedc 100644 --- a/polkadot/parachain/test-parachains/adder/Cargo.toml +++ b/polkadot/parachain/test-parachains/adder/Cargo.toml @@ -12,8 +12,8 @@ publish = false workspace = true [dependencies] -parachain = { package = "polkadot-parachain-primitives", path = "../..", default-features = false, features = ["wasm-api"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +polkadot-parachain-primitives = { path = "../..", default-features = false, features = ["wasm-api"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sp-std = { path = "../../../../substrate/primitives/std", default-features = false } tiny-keccak = { version = "2.0.2", features = ["keccak"] } dlmalloc = { version = "0.2.4", features = ["global"] } @@ -26,4 +26,4 @@ substrate-wasm-builder = { path = "../../../../substrate/utils/wasm-builder" } [features] default = ["std"] -std = ["parachain/std", "parity-scale-codec/std", "sp-io/std", "sp-std/std"] +std = ["codec/std", "polkadot-parachain-primitives/std", "sp-io/std", "sp-std/std"] diff --git a/polkadot/parachain/test-parachains/adder/collator/Cargo.toml b/polkadot/parachain/test-parachains/adder/collator/Cargo.toml index f9aaab74debd..996735e8c8bf 100644 --- a/polkadot/parachain/test-parachains/adder/collator/Cargo.toml +++ b/polkadot/parachain/test-parachains/adder/collator/Cargo.toml @@ -15,7 +15,7 @@ name = "adder-collator" path = "src/main.rs" [dependencies] -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } clap = { version = "4.5.3", features = ["derive"] } futures = "0.3.30" futures-timer = "3.0.2" diff --git a/polkadot/parachain/test-parachains/adder/collator/src/lib.rs b/polkadot/parachain/test-parachains/adder/collator/src/lib.rs index c2ba93f389b0..daeb8bc915dd 100644 --- a/polkadot/parachain/test-parachains/adder/collator/src/lib.rs +++ b/polkadot/parachain/test-parachains/adder/collator/src/lib.rs @@ -16,9 +16,9 @@ //! Collator for the adder test parachain. +use codec::{Decode, Encode}; use futures::channel::oneshot; use futures_timer::Delay; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::{ Collation, CollationResult, CollationSecondedSignal, CollatorFn, MaybeCompressedPoV, PoV, Statement, diff --git a/polkadot/parachain/test-parachains/adder/src/lib.rs b/polkadot/parachain/test-parachains/adder/src/lib.rs index 4cf1ba8ac971..28914f02511d 100644 --- a/polkadot/parachain/test-parachains/adder/src/lib.rs +++ b/polkadot/parachain/test-parachains/adder/src/lib.rs @@ -18,7 +18,7 @@ #![no_std] -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use tiny_keccak::{Hasher as _, Keccak}; #[cfg(not(feature = "std"))] diff --git a/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs b/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs index 048330437cd7..7dba7a964d3b 100644 --- a/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs +++ b/polkadot/parachain/test-parachains/adder/src/wasm_validation.rs @@ -17,14 +17,14 @@ //! WASM validation for adder parachain. use crate::{BlockData, HeadData}; +use codec::{Decode, Encode}; use core::panic; -use parachain::primitives::{HeadData as GenericHeadData, ValidationResult}; -use parity_scale_codec::{Decode, Encode}; +use polkadot_parachain_primitives::primitives::{HeadData as GenericHeadData, ValidationResult}; use sp_std::vec::Vec; #[no_mangle] pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 { - let params = unsafe { parachain::load_params(params, len) }; + let params = unsafe { polkadot_parachain_primitives::load_params(params, len) }; let parent_head = HeadData::decode(&mut ¶ms.parent_head.0[..]).expect("invalid parent head format."); @@ -34,7 +34,7 @@ pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 { let parent_hash = crate::keccak256(¶ms.parent_head.0[..]); let new_head = crate::execute(parent_hash, parent_head, &block_data).expect("Executes block"); - parachain::write_result(&ValidationResult { + polkadot_parachain_primitives::write_result(&ValidationResult { head_data: GenericHeadData(new_head.encode()), new_validation_code: None, upward_messages: sp_std::vec::Vec::new().try_into().expect("empty vec fits into bounds"), diff --git a/polkadot/parachain/test-parachains/undying/Cargo.toml b/polkadot/parachain/test-parachains/undying/Cargo.toml index f2067a2c3b9b..4d3d2abaeafe 100644 --- a/polkadot/parachain/test-parachains/undying/Cargo.toml +++ b/polkadot/parachain/test-parachains/undying/Cargo.toml @@ -12,8 +12,8 @@ license.workspace = true workspace = true [dependencies] -parachain = { package = "polkadot-parachain-primitives", path = "../..", default-features = false, features = ["wasm-api"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +polkadot-parachain-primitives = { path = "../..", default-features = false, features = ["wasm-api"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sp-std = { path = "../../../../substrate/primitives/std", default-features = false } tiny-keccak = { version = "2.0.2", features = ["keccak"] } dlmalloc = { version = "0.2.4", features = ["global"] } @@ -28,9 +28,9 @@ substrate-wasm-builder = { path = "../../../../substrate/utils/wasm-builder" } [features] default = ["std"] std = [ + "codec/std", "log/std", - "parachain/std", - "parity-scale-codec/std", + "polkadot-parachain-primitives/std", "sp-io/std", "sp-std/std", ] diff --git a/polkadot/parachain/test-parachains/undying/collator/Cargo.toml b/polkadot/parachain/test-parachains/undying/collator/Cargo.toml index 08d1e74d8798..288549c2c268 100644 --- a/polkadot/parachain/test-parachains/undying/collator/Cargo.toml +++ b/polkadot/parachain/test-parachains/undying/collator/Cargo.toml @@ -15,7 +15,7 @@ name = "undying-collator" path = "src/main.rs" [dependencies] -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } clap = { version = "4.5.3", features = ["derive"] } futures = "0.3.30" futures-timer = "3.0.2" diff --git a/polkadot/parachain/test-parachains/undying/collator/src/lib.rs b/polkadot/parachain/test-parachains/undying/collator/src/lib.rs index 3c869233182f..920099f4499d 100644 --- a/polkadot/parachain/test-parachains/undying/collator/src/lib.rs +++ b/polkadot/parachain/test-parachains/undying/collator/src/lib.rs @@ -16,9 +16,9 @@ //! Collator for the `Undying` test parachain. +use codec::{Decode, Encode}; use futures::channel::oneshot; use futures_timer::Delay; -use parity_scale_codec::{Decode, Encode}; use polkadot_node_primitives::{ maybe_compress_pov, Collation, CollationResult, CollationSecondedSignal, CollatorFn, MaybeCompressedPoV, PoV, Statement, diff --git a/polkadot/parachain/test-parachains/undying/src/lib.rs b/polkadot/parachain/test-parachains/undying/src/lib.rs index abd88726b7fc..dc056e64fa23 100644 --- a/polkadot/parachain/test-parachains/undying/src/lib.rs +++ b/polkadot/parachain/test-parachains/undying/src/lib.rs @@ -18,7 +18,7 @@ #![no_std] -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use sp_std::vec::Vec; use tiny_keccak::{Hasher as _, Keccak}; diff --git a/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs b/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs index de4a1d7e2329..23fac43a3c73 100644 --- a/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs +++ b/polkadot/parachain/test-parachains/undying/src/wasm_validation.rs @@ -17,12 +17,12 @@ //! WASM validation for the `Undying` parachain. use crate::{BlockData, HeadData}; -use parachain::primitives::{HeadData as GenericHeadData, ValidationResult}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; +use polkadot_parachain_primitives::primitives::{HeadData as GenericHeadData, ValidationResult}; #[no_mangle] pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 { - let params = unsafe { parachain::load_params(params, len) }; + let params = unsafe { polkadot_parachain_primitives::load_params(params, len) }; let parent_head = HeadData::decode(&mut ¶ms.parent_head.0[..]).expect("invalid parent head format."); @@ -34,7 +34,7 @@ pub extern "C" fn validate_block(params: *const u8, len: usize) -> u64 { let (new_head, _) = crate::execute(parent_hash, parent_head, block_data).expect("Executes block"); - parachain::write_result(&ValidationResult { + polkadot_parachain_primitives::write_result(&ValidationResult { head_data: GenericHeadData(new_head.encode()), new_validation_code: None, upward_messages: sp_std::vec::Vec::new().try_into().expect("empty vec fits within bounds"), diff --git a/polkadot/primitives/Cargo.toml b/polkadot/primitives/Cargo.toml index 603d08b8fee5..d6df077b88b7 100644 --- a/polkadot/primitives/Cargo.toml +++ b/polkadot/primitives/Cargo.toml @@ -12,15 +12,15 @@ workspace = true [dependencies] bitvec = { version = "1.0.0", default-features = false, features = ["alloc", "serde"] } hex-literal = "0.4.1" -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["bit-vec", "derive"] } scale-info = { version = "2.11.1", default-features = false, features = ["bit-vec", "derive", "serde"] } log = { workspace = true, default-features = false } serde = { features = ["alloc", "derive"], workspace = true } -application-crypto = { package = "sp-application-crypto", path = "../../substrate/primitives/application-crypto", default-features = false, features = ["serde"] } -inherents = { package = "sp-inherents", path = "../../substrate/primitives/inherents", default-features = false } -primitives = { package = "sp-core", path = "../../substrate/primitives/core", default-features = false } -runtime_primitives = { package = "sp-runtime", path = "../../substrate/primitives/runtime", default-features = false } +sp-application-crypto = { path = "../../substrate/primitives/application-crypto", default-features = false, features = ["serde"] } +sp-inherents = { path = "../../substrate/primitives/inherents", default-features = false } +sp-core = { path = "../../substrate/primitives/core", default-features = false } +sp-runtime = { path = "../../substrate/primitives/runtime", default-features = false } sp-api = { path = "../../substrate/primitives/api", default-features = false } sp-arithmetic = { path = "../../substrate/primitives/arithmetic", default-features = false, features = ["serde"] } sp-authority-discovery = { path = "../../substrate/primitives/authority-discovery", default-features = false, features = ["serde"] } @@ -36,29 +36,29 @@ polkadot-parachain-primitives = { path = "../parachain", default-features = fals [features] default = ["std"] std = [ - "application-crypto/std", "bitvec/std", - "inherents/std", + "codec/std", "log/std", - "parity-scale-codec/std", "polkadot-core-primitives/std", "polkadot-parachain-primitives/std", - "primitives/std", - "runtime_primitives/std", "scale-info/std", "serde/std", "sp-api/std", + "sp-application-crypto/std", "sp-arithmetic/std", "sp-authority-discovery/std", "sp-consensus-slots/std", + "sp-core/std", + "sp-inherents/std", "sp-io/std", "sp-keystore", "sp-keystore?/std", + "sp-runtime/std", "sp-staking/std", "sp-std/std", ] runtime-benchmarks = [ "polkadot-parachain-primitives/runtime-benchmarks", - "runtime_primitives/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", ] diff --git a/polkadot/primitives/src/v7/async_backing.rs b/polkadot/primitives/src/v7/async_backing.rs index 1abe87b6dec4..a82d843d28bf 100644 --- a/polkadot/primitives/src/v7/async_backing.rs +++ b/polkadot/primitives/src/v7/async_backing.rs @@ -18,9 +18,9 @@ use super::*; -use parity_scale_codec::{Decode, Encode}; -use primitives::RuntimeDebug; +use codec::{Decode, Encode}; use scale_info::TypeInfo; +use sp_core::RuntimeDebug; /// Candidate's acceptance limitations for asynchronous backing per relay parent. #[derive( diff --git a/polkadot/primitives/src/v7/executor_params.rs b/polkadot/primitives/src/v7/executor_params.rs index 918a7f17a7e3..e58cf3e76cc2 100644 --- a/polkadot/primitives/src/v7/executor_params.rs +++ b/polkadot/primitives/src/v7/executor_params.rs @@ -22,7 +22,7 @@ //! done in `polkadot-node-core-pvf`. use crate::{BlakeTwo256, HashT as _, PvfExecKind, PvfPrepKind}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use polkadot_core_primitives::Hash; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; diff --git a/polkadot/primitives/src/v7/metrics.rs b/polkadot/primitives/src/v7/metrics.rs index 97f7678e4373..1a29471c5450 100644 --- a/polkadot/primitives/src/v7/metrics.rs +++ b/polkadot/primitives/src/v7/metrics.rs @@ -16,7 +16,7 @@ //! Runtime metric primitives. -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use sp_std::prelude::*; /// Runtime metric operations. diff --git a/polkadot/primitives/src/v7/mod.rs b/polkadot/primitives/src/v7/mod.rs index fb8406aece69..6b7985847a10 100644 --- a/polkadot/primitives/src/v7/mod.rs +++ b/polkadot/primitives/src/v7/mod.rs @@ -17,7 +17,7 @@ //! `V7` Primitives. use bitvec::{field::BitField, slice::BitSlice, vec::BitVec}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_std::{ marker::PhantomData, @@ -26,13 +26,13 @@ use sp_std::{ vec::IntoIter, }; -use application_crypto::KeyTypeId; -use inherents::InherentIdentifier; -use primitives::RuntimeDebug; -use runtime_primitives::traits::{AppVerify, Header as HeaderT}; +use sp_application_crypto::KeyTypeId; use sp_arithmetic::traits::{BaseArithmetic, Saturating}; +use sp_core::RuntimeDebug; +use sp_inherents::InherentIdentifier; +use sp_runtime::traits::{AppVerify, Header as HeaderT}; -pub use runtime_primitives::traits::{BlakeTwo256, Hash as HashT}; +pub use sp_runtime::traits::{BlakeTwo256, Hash as HashT}; // Export some core primitives. pub use polkadot_core_primitives::v2::{ @@ -77,7 +77,7 @@ pub const COLLATOR_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"coll"); const LOG_TARGET: &str = "runtime::primitives"; mod collator_app { - use application_crypto::{app_crypto, sr25519}; + use sp_application_crypto::{app_crypto, sr25519}; app_crypto!(sr25519, super::COLLATOR_KEY_TYPE_ID); } @@ -95,7 +95,7 @@ pub type CollatorSignature = collator_app::Signature; pub const PARACHAIN_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"para"); mod validator_app { - use application_crypto::{app_crypto, sr25519}; + use sp_application_crypto::{app_crypto, sr25519}; app_crypto!(sr25519, super::PARACHAIN_KEY_TYPE_ID); } @@ -158,7 +158,7 @@ impl TypeIndex for ValidatorIndex { } } -application_crypto::with_pair! { +sp_application_crypto::with_pair! { /// A Parachain validator keypair. pub type ValidatorPair = validator_app::Pair; } @@ -172,8 +172,8 @@ pub type ValidatorSignature = validator_app::Signature; /// A declarations of storage keys where an external observer can find some interesting data. pub mod well_known_keys { use super::{HrmpChannelId, Id, WellKnownKey}; + use codec::Encode as _; use hex_literal::hex; - use parity_scale_codec::Encode as _; use sp_io::hashing::twox_64; use sp_std::prelude::*; @@ -443,7 +443,7 @@ pub const LEGACY_MIN_BACKING_VOTES: u32 = 2; // The public key of a keypair used by a validator for determining assignments /// to approve included parachain candidates. mod assignment_app { - use application_crypto::{app_crypto, sr25519}; + use sp_application_crypto::{app_crypto, sr25519}; app_crypto!(sr25519, super::ASSIGNMENT_KEY_TYPE_ID); } @@ -451,7 +451,7 @@ mod assignment_app { /// to approve included parachain candidates. pub type AssignmentId = assignment_app::Public; -application_crypto::with_pair! { +sp_application_crypto::with_pair! { /// The full keypair used by a validator for determining assignments to approve included /// parachain candidates. pub type AssignmentPair = assignment_app::Pair; @@ -1361,7 +1361,7 @@ pub enum UpgradeGoAhead { } /// Consensus engine id for polkadot v1 consensus engine. -pub const POLKADOT_ENGINE_ID: runtime_primitives::ConsensusEngineId = *b"POL1"; +pub const POLKADOT_ENGINE_ID: sp_runtime::ConsensusEngineId = *b"POL1"; /// A consensus log item for polkadot validation. To be used with [`POLKADOT_ENGINE_ID`]. #[derive(Decode, Encode, Clone, PartialEq, Eq)] @@ -1391,18 +1391,18 @@ pub enum ConsensusLog { impl ConsensusLog { /// Attempt to convert a reference to a generic digest item into a consensus log. pub fn from_digest_item( - digest_item: &runtime_primitives::DigestItem, - ) -> Result, parity_scale_codec::Error> { + digest_item: &sp_runtime::DigestItem, + ) -> Result, codec::Error> { match digest_item { - runtime_primitives::DigestItem::Consensus(id, encoded) if id == &POLKADOT_ENGINE_ID => + sp_runtime::DigestItem::Consensus(id, encoded) if id == &POLKADOT_ENGINE_ID => Ok(Some(Self::decode(&mut &encoded[..])?)), _ => Ok(None), } } } -impl From for runtime_primitives::DigestItem { - fn from(c: ConsensusLog) -> runtime_primitives::DigestItem { +impl From for sp_runtime::DigestItem { + fn from(c: ConsensusLog) -> sp_runtime::DigestItem { Self::Consensus(POLKADOT_ENGINE_ID, c.encode()) } } @@ -1752,25 +1752,23 @@ impl From for CompactStatementInner { } } -impl parity_scale_codec::Encode for CompactStatement { +impl codec::Encode for CompactStatement { fn size_hint(&self) -> usize { // magic + discriminant + payload 4 + 1 + 32 } - fn encode_to(&self, dest: &mut T) { + fn encode_to(&self, dest: &mut T) { dest.write(&BACKING_STATEMENT_MAGIC); CompactStatementInner::from(self.clone()).encode_to(dest) } } -impl parity_scale_codec::Decode for CompactStatement { - fn decode( - input: &mut I, - ) -> Result { +impl codec::Decode for CompactStatement { + fn decode(input: &mut I) -> Result { let maybe_magic = <[u8; 4]>::decode(input)?; if maybe_magic != BACKING_STATEMENT_MAGIC { - return Err(parity_scale_codec::Error::from("invalid magic string")) + return Err(codec::Error::from("invalid magic string")) } Ok(match CompactStatementInner::decode(input)? { @@ -1987,7 +1985,7 @@ impl WellKnownKey { /// Gets the value or `None` if it does not exist or decoding failed. pub fn get(&self) -> Option { sp_io::storage::get(&self.key) - .and_then(|raw| parity_scale_codec::DecodeAll::decode_all(&mut raw.as_ref()).ok()) + .and_then(|raw| codec::DecodeAll::decode_all(&mut raw.as_ref()).ok()) } } @@ -2051,7 +2049,7 @@ pub mod node_features { mod tests { use super::*; use bitvec::bitvec; - use primitives::sr25519; + use sp_core::sr25519; pub fn dummy_committed_candidate_receipt() -> CommittedCandidateReceipt { let zeros = Hash::zero(); diff --git a/polkadot/primitives/src/v7/signed.rs b/polkadot/primitives/src/v7/signed.rs index 96646d54cbba..62e4df238503 100644 --- a/polkadot/primitives/src/v7/signed.rs +++ b/polkadot/primitives/src/v7/signed.rs @@ -14,17 +14,17 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use scale_info::TypeInfo; #[cfg(feature = "std")] -use application_crypto::AppCrypto; +use sp_application_crypto::AppCrypto; #[cfg(feature = "std")] use sp_keystore::{Error as KeystoreError, KeystorePtr}; use sp_std::prelude::Vec; -use primitives::RuntimeDebug; -use runtime_primitives::traits::AppVerify; +use sp_core::RuntimeDebug; +use sp_runtime::traits::AppVerify; use super::{SigningContext, ValidatorId, ValidatorIndex, ValidatorSignature}; @@ -312,7 +312,7 @@ impl, RealPayload: Encode> UncheckedSigned, validator_index: ValidatorIndex, ) -> Self { - use application_crypto::RuntimeAppPublic; + use sp_application_crypto::RuntimeAppPublic; let data = Self::payload_data(&payload, context); let signature = public.sign(&data).unwrap(); @@ -343,7 +343,7 @@ impl From> /// This helper trait ensures that we can encode `Statement` as `CompactStatement`, /// and anything as itself. /// -/// This resembles `parity_scale_codec::EncodeLike`, but it's distinct: +/// This resembles `codec::EncodeLike`, but it's distinct: /// `EncodeLike` is a marker trait which asserts at the typesystem level that /// one type's encoding is a valid encoding for another type. It doesn't /// perform any type conversion when encoding. diff --git a/polkadot/primitives/src/v7/slashing.rs b/polkadot/primitives/src/v7/slashing.rs index bcd7d0c2fc44..ea06e960b5bc 100644 --- a/polkadot/primitives/src/v7/slashing.rs +++ b/polkadot/primitives/src/v7/slashing.rs @@ -17,7 +17,7 @@ //! Primitives types used for dispute slashing. use crate::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; diff --git a/polkadot/primitives/src/vstaging/mod.rs b/polkadot/primitives/src/vstaging/mod.rs index 1af73993f640..fecad783f7cb 100644 --- a/polkadot/primitives/src/vstaging/mod.rs +++ b/polkadot/primitives/src/vstaging/mod.rs @@ -20,10 +20,10 @@ use crate::v7::*; use sp_std::prelude::*; -use parity_scale_codec::{Decode, Encode}; -use primitives::RuntimeDebug; +use codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_arithmetic::Perbill; +use sp_core::RuntimeDebug; /// Scheduler configuration parameters. All coretime/ondemand parameters are here. #[derive( diff --git a/polkadot/rpc/Cargo.toml b/polkadot/rpc/Cargo.toml index 1900b595d671..cceb4dc5a93b 100644 --- a/polkadot/rpc/Cargo.toml +++ b/polkadot/rpc/Cargo.toml @@ -32,8 +32,8 @@ sc-consensus-epochs = { path = "../../substrate/client/consensus/epochs" } sc-consensus-grandpa = { path = "../../substrate/client/consensus/grandpa" } sc-consensus-grandpa-rpc = { path = "../../substrate/client/consensus/grandpa/rpc" } sc-sync-state-rpc = { path = "../../substrate/client/sync-state-rpc" } -txpool-api = { package = "sc-transaction-pool-api", path = "../../substrate/client/transaction-pool/api" } -frame-rpc-system = { package = "substrate-frame-rpc-system", path = "../../substrate/utils/frame/rpc/system" } +sc-transaction-pool-api = { path = "../../substrate/client/transaction-pool/api" } +substrate-frame-rpc-system = { path = "../../substrate/utils/frame/rpc/system" } mmr-rpc = { path = "../../substrate/client/merkle-mountain-range/rpc" } pallet-transaction-payment-rpc = { path = "../../substrate/frame/transaction-payment/rpc" } sp-block-builder = { path = "../../substrate/primitives/block-builder" } diff --git a/polkadot/rpc/src/lib.rs b/polkadot/rpc/src/lib.rs index 2daa246102fc..7d678ada5ff5 100644 --- a/polkadot/rpc/src/lib.rs +++ b/polkadot/rpc/src/lib.rs @@ -28,6 +28,7 @@ use sc_consensus_beefy::communication::notification::{ }; use sc_consensus_grandpa::FinalityProofProvider; pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; +use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_application_crypto::RuntimeAppPublic; use sp_block_builder::BlockBuilder; @@ -36,7 +37,6 @@ use sp_consensus::SelectChain; use sp_consensus_babe::BabeApi; use sp_consensus_beefy::AuthorityIdBound; use sp_keystore::KeystorePtr; -use txpool_api::TransactionPool; /// A type representing all RPC extensions. pub type RpcExtension = RpcModule<()>; @@ -107,7 +107,7 @@ where + Send + Sync + 'static, - C::Api: frame_rpc_system::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: mmr_rpc::MmrRuntimeApi::Hash, BlockNumber>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BabeApi, @@ -119,7 +119,6 @@ where AuthorityId: AuthorityIdBound, ::Signature: Send + Sync, { - use frame_rpc_system::{System, SystemApiServer}; use mmr_rpc::{Mmr, MmrApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_babe_rpc::{Babe, BabeApiServer}; @@ -127,6 +126,7 @@ where use sc_consensus_grandpa_rpc::{Grandpa, GrandpaApiServer}; use sc_rpc_spec_v2::chain_spec::{ChainSpec, ChainSpecApiServer}; use sc_sync_state_rpc::{SyncState, SyncStateApiServer}; + use substrate_frame_rpc_system::{System, SystemApiServer}; use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut io = RpcModule::new(()); diff --git a/polkadot/runtime/common/Cargo.toml b/polkadot/runtime/common/Cargo.toml index 3a6414881768..da89bd2251ac 100644 --- a/polkadot/runtime/common/Cargo.toml +++ b/polkadot/runtime/common/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] impl-trait-for-tuples = "0.2.2" bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } log = { workspace = true } rustc-hex = { version = "2.1.0", default-features = false } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } @@ -21,7 +21,7 @@ serde_derive = { workspace = true } static_assertions = "1.1.0" sp-api = { path = "../../../substrate/primitives/api", default-features = false } -inherents = { package = "sp-inherents", path = "../../../substrate/primitives/inherents", default-features = false } +sp-inherents = { path = "../../../substrate/primitives/inherents", default-features = false } sp-std = { package = "sp-std", path = "../../../substrate/primitives/std", default-features = false } sp-io = { path = "../../../substrate/primitives/io", default-features = false } sp-runtime = { path = "../../../substrate/primitives/runtime", default-features = false, features = ["serde"] } @@ -51,9 +51,9 @@ frame-election-provider-support = { path = "../../../substrate/frame/election-pr frame-benchmarking = { path = "../../../substrate/frame/benchmarking", default-features = false, optional = true } pallet-babe = { path = "../../../substrate/frame/babe", default-features = false, optional = true } -primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } +polkadot-primitives = { path = "../../primitives", default-features = false } libsecp256k1 = { version = "0.7.0", default-features = false } -runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } +polkadot-runtime-parachains = { path = "../parachains", default-features = false } slot-range-helper = { path = "slot_range_helper", default-features = false } xcm = { package = "staging-xcm", path = "../../xcm", default-features = false } @@ -69,18 +69,18 @@ sp-keystore = { path = "../../../substrate/primitives/keystore" } sp-keyring = { path = "../../../substrate/primitives/keyring" } serde_json = { workspace = true, default-features = true } libsecp256k1 = "0.7.0" -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" } [features] default = ["std"] no_std = [] std = [ "bitvec/std", + "codec/std", "frame-benchmarking?/std", "frame-election-provider-support/std", "frame-support/std", "frame-system/std", - "inherents/std", "libsecp256k1/std", "log/std", "pallet-asset-rate?/std", @@ -97,15 +97,15 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-vesting/std", - "parity-scale-codec/std", - "primitives/std", - "runtime-parachains/std", + "polkadot-primitives/std", + "polkadot-runtime-parachains/std", "rustc-hex/std", "scale-info/std", "serde/std", "slot-range-helper/std", "sp-api/std", "sp-core/std", + "sp-inherents/std", "sp-io/std", "sp-npos-elections/std", "sp-runtime/std", @@ -134,8 +134,8 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", - "primitives/runtime-benchmarks", - "runtime-parachains/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -160,6 +160,6 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-treasury/try-runtime", "pallet-vesting/try-runtime", - "runtime-parachains/try-runtime", + "polkadot-runtime-parachains/try-runtime", "sp-runtime/try-runtime", ] diff --git a/polkadot/runtime/common/slot_range_helper/Cargo.toml b/polkadot/runtime/common/slot_range_helper/Cargo.toml index 314e101ad221..47e8fea24002 100644 --- a/polkadot/runtime/common/slot_range_helper/Cargo.toml +++ b/polkadot/runtime/common/slot_range_helper/Cargo.toml @@ -12,10 +12,10 @@ workspace = true [dependencies] paste = "1.0" enumn = "0.1.12" -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sp-std = { package = "sp-std", path = "../../../../substrate/primitives/std", default-features = false } sp-runtime = { path = "../../../../substrate/primitives/runtime", default-features = false } [features] default = ["std"] -std = ["parity-scale-codec/std", "sp-runtime/std", "sp-std/std"] +std = ["codec/std", "sp-runtime/std", "sp-std/std"] diff --git a/polkadot/runtime/common/slot_range_helper/src/lib.rs b/polkadot/runtime/common/slot_range_helper/src/lib.rs index bbe5b61ae1f3..f907390bc91b 100644 --- a/polkadot/runtime/common/slot_range_helper/src/lib.rs +++ b/polkadot/runtime/common/slot_range_helper/src/lib.rs @@ -18,8 +18,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +pub use codec::{Decode, Encode}; pub use enumn::N; -pub use parity_scale_codec::{Decode, Encode}; pub use paste; pub use sp_runtime::traits::CheckedSub; pub use sp_std::{ops::Add, result}; diff --git a/polkadot/runtime/common/src/assigned_slots/benchmarking.rs b/polkadot/runtime/common/src/assigned_slots/benchmarking.rs index 61638fe6cabf..882bfa051c83 100644 --- a/polkadot/runtime/common/src/assigned_slots/benchmarking.rs +++ b/polkadot/runtime/common/src/assigned_slots/benchmarking.rs @@ -22,7 +22,7 @@ use super::*; use frame_benchmarking::v2::*; use frame_support::assert_ok; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; -use primitives::Id as ParaId; +use polkadot_primitives::Id as ParaId; use sp_runtime::traits::Bounded; type CurrencyOf = <::Leaser as Leaser>>::Currency; diff --git a/polkadot/runtime/common/src/assigned_slots/mod.rs b/polkadot/runtime/common/src/assigned_slots/mod.rs index 92a8e46f5f9c..368708f25640 100644 --- a/polkadot/runtime/common/src/assigned_slots/mod.rs +++ b/polkadot/runtime/common/src/assigned_slots/mod.rs @@ -30,12 +30,12 @@ use crate::{ slots::{self, Pallet as Slots, WeightInfo as SlotsWeightInfo}, traits::{LeaseError, Leaser, Registrar}, }; +use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{pallet_prelude::*, traits::Currency}; use frame_system::pallet_prelude::*; pub use pallet::*; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::Id as ParaId; -use runtime_parachains::{ +use polkadot_primitives::Id as ParaId; +use polkadot_runtime_parachains::{ configuration, paras::{self}, }; @@ -428,7 +428,8 @@ pub mod pallet { // Force downgrade to on-demand parachain (if needed) before end of lease period if is_parachain { - if let Err(err) = runtime_parachains::schedule_parachain_downgrade::(id) { + if let Err(err) = polkadot_runtime_parachains::schedule_parachain_downgrade::(id) + { // Treat failed downgrade as warning .. slot lease has been cleared, // so the parachain will be downgraded anyway by the slots pallet // at the end of the lease period . @@ -630,12 +631,12 @@ mod tests { use super::*; use crate::{assigned_slots, mock::TestRegistrar, slots}; - use ::test_helpers::{dummy_head_data, dummy_validation_code}; use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types}; use frame_system::EnsureRoot; use pallet_balances; - use primitives::BlockNumber; - use runtime_parachains::{ + use polkadot_primitives::BlockNumber; + use polkadot_primitives_test_helpers::{dummy_head_data, dummy_validation_code}; + use polkadot_runtime_parachains::{ configuration as parachains_configuration, paras as parachains_paras, shared as parachains_shared, }; diff --git a/polkadot/runtime/common/src/auctions.rs b/polkadot/runtime/common/src/auctions.rs index e7b7c081ae4e..199b18fba51d 100644 --- a/polkadot/runtime/common/src/auctions.rs +++ b/polkadot/runtime/common/src/auctions.rs @@ -22,6 +22,7 @@ use crate::{ slot_range::SlotRange, traits::{AuctionStatus, Auctioneer, LeaseError, Leaser, Registrar}, }; +use codec::Decode; use frame_support::{ dispatch::DispatchResult, ensure, @@ -30,8 +31,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; -use parity_scale_codec::Decode; -use primitives::Id as ParaId; +use polkadot_primitives::Id as ParaId; use sp_runtime::traits::{CheckedSub, One, Saturating, Zero}; use sp_std::{mem::swap, prelude::*}; @@ -671,7 +671,6 @@ impl Pallet { mod tests { use super::*; use crate::{auctions, mock::TestRegistrar}; - use ::test_helpers::{dummy_hash, dummy_head_data, dummy_validation_code}; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, derive_impl, ord_parameter_types, parameter_types, @@ -679,7 +678,8 @@ mod tests { }; use frame_system::{EnsureRoot, EnsureSignedBy}; use pallet_balances; - use primitives::{BlockNumber, Id as ParaId}; + use polkadot_primitives::{BlockNumber, Id as ParaId}; + use polkadot_primitives_test_helpers::{dummy_hash, dummy_head_data, dummy_validation_code}; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, @@ -1728,7 +1728,7 @@ mod benchmarking { traits::{EnsureOrigin, OnInitialize}, }; use frame_system::RawOrigin; - use runtime_parachains::paras; + use polkadot_runtime_parachains::paras; use sp_runtime::{traits::Bounded, SaturatedConversion}; use frame_benchmarking::{account, benchmarks, whitelisted_caller, BenchmarkError}; diff --git a/polkadot/runtime/common/src/claims.rs b/polkadot/runtime/common/src/claims.rs index 8407c7f0dda9..54208e7fd135 100644 --- a/polkadot/runtime/common/src/claims.rs +++ b/polkadot/runtime/common/src/claims.rs @@ -16,6 +16,7 @@ //! Pallet to process claims from Ethereum addresses. +use codec::{Decode, Encode}; use frame_support::{ ensure, traits::{Currency, Get, IsSubType, VestingSchedule}, @@ -23,8 +24,7 @@ use frame_support::{ DefaultNoBound, }; pub use pallet::*; -use parity_scale_codec::{Decode, Encode}; -use primitives::ValidityError; +use polkadot_primitives::ValidityError; use scale_info::TypeInfo; use serde::{self, Deserialize, Deserializer, Serialize, Serializer}; use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256}; @@ -699,7 +699,7 @@ mod tests { use hex_literal::hex; use secp_utils::*; - use parity_scale_codec::Encode; + use codec::Encode; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use crate::claims; diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index 0aecbcd531c4..1dbba363de56 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -55,6 +55,7 @@ use crate::{ slot_range::SlotRange, traits::{Auctioneer, Registrar}, }; +use codec::{Decode, Encode}; use frame_support::{ ensure, pallet_prelude::{DispatchResult, Weight}, @@ -68,8 +69,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; -use parity_scale_codec::{Decode, Encode}; -use primitives::Id as ParaId; +use polkadot_primitives::Id as ParaId; use scale_info::TypeInfo; use sp_runtime::{ traits::{ @@ -862,7 +862,7 @@ mod tests { assert_noop, assert_ok, derive_impl, parameter_types, traits::{ConstU32, OnFinalize, OnInitialize}, }; - use primitives::Id as ParaId; + use polkadot_primitives::Id as ParaId; use sp_core::H256; use std::{cell::RefCell, collections::BTreeMap, sync::Arc}; // The testing primitives are very useful for avoiding having to work with signatures @@ -872,7 +872,7 @@ mod tests { mock::TestRegistrar, traits::{AuctionStatus, OnSwap}, }; - use ::test_helpers::{dummy_head_data, dummy_validation_code}; + use polkadot_primitives_test_helpers::{dummy_head_data, dummy_validation_code}; use sp_keystore::{testing::MemoryKeystore, KeystoreExt}; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput}, @@ -1979,7 +1979,7 @@ mod benchmarking { use super::{Pallet as Crowdloan, *}; use frame_support::{assert_ok, traits::OnInitialize}; use frame_system::RawOrigin; - use runtime_parachains::paras; + use polkadot_runtime_parachains::paras; use sp_core::crypto::UncheckedFrom; use sp_runtime::traits::{Bounded, CheckedSub}; use sp_std::prelude::*; diff --git a/polkadot/runtime/common/src/identity_migrator.rs b/polkadot/runtime/common/src/identity_migrator.rs index bf334a63e958..7d02e24b5368 100644 --- a/polkadot/runtime/common/src/identity_migrator.rs +++ b/polkadot/runtime/common/src/identity_migrator.rs @@ -172,10 +172,10 @@ impl OnReapIdentity for () { #[benchmarks] mod benchmarks { use super::*; + use codec::Encode; use frame_support::traits::EnsureOrigin; use frame_system::RawOrigin; use pallet_identity::{Data, IdentityInformationProvider, Judgement, Pallet as Identity}; - use parity_scale_codec::Encode; use sp_runtime::{ traits::{Bounded, Hash, StaticLookup}, Saturating, diff --git a/polkadot/runtime/common/src/impls.rs b/polkadot/runtime/common/src/impls.rs index a92a05219cf8..ac2288c906a5 100644 --- a/polkadot/runtime/common/src/impls.rs +++ b/polkadot/runtime/common/src/impls.rs @@ -16,14 +16,14 @@ //! Auxiliary `struct`/`enum`s for polkadot runtime. +use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::traits::{ fungible::{Balanced, Credit}, tokens::imbalance::ResolveTo, Contains, ContainsPair, Imbalance, OnUnbalanced, }; use pallet_treasury::TreasuryAccountId; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::Balance; +use polkadot_primitives::Balance; use sp_runtime::{traits::TryConvert, Perquintill, RuntimeDebug}; use xcm::VersionedLocation; @@ -32,8 +32,8 @@ pub struct ToAuthor(sp_std::marker::PhantomData); impl OnUnbalanced>> for ToAuthor where R: pallet_balances::Config + pallet_authorship::Config, - ::AccountId: From, - ::AccountId: Into, + ::AccountId: From, + ::AccountId: Into, { fn on_nonzero_unbalanced( amount: Credit<::AccountId, pallet_balances::Pallet>, @@ -48,8 +48,8 @@ pub struct DealWithFees(sp_std::marker::PhantomData); impl OnUnbalanced>> for DealWithFees where R: pallet_balances::Config + pallet_authorship::Config + pallet_treasury::Config, - ::AccountId: From, - ::AccountId: Into, + ::AccountId: From, + ::AccountId: Into, { fn on_unbalanceds( mut fees_then_tips: impl Iterator>>, @@ -255,7 +255,7 @@ mod tests { PalletId, }; use frame_system::limits; - use primitives::AccountId; + use polkadot_primitives::AccountId; use sp_core::{ConstU64, H256}; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, diff --git a/polkadot/runtime/common/src/integration_tests.rs b/polkadot/runtime/common/src/integration_tests.rs index 2122e75f3e2d..e77035b3f6b4 100644 --- a/polkadot/runtime/common/src/integration_tests.rs +++ b/polkadot/runtime/common/src/integration_tests.rs @@ -24,6 +24,7 @@ use crate::{ slots, traits::{AuctionStatus, Auctioneer, Leaser, Registrar as RegistrarT}, }; +use codec::Encode; use frame_support::{ assert_noop, assert_ok, derive_impl, parameter_types, traits::{ConstU32, Currency, OnFinalize, OnInitialize}, @@ -33,12 +34,11 @@ use frame_support::{ use frame_support_test::TestRandomness; use frame_system::EnsureRoot; use pallet_identity::{self, legacy::IdentityInfo}; -use parity_scale_codec::Encode; -use primitives::{ +use polkadot_primitives::{ BlockNumber, HeadData, Id as ParaId, SessionIndex, ValidationCode, LOWEST_PUBLIC_ID, MAX_CODE_SIZE, }; -use runtime_parachains::{ +use polkadot_runtime_parachains::{ configuration, dmp, origin, paras, shared, Origin as ParaOrigin, ParaLifecycle, }; use sp_core::H256; diff --git a/polkadot/runtime/common/src/lib.rs b/polkadot/runtime/common/src/lib.rs index 60cc684149b4..6e50384f68c9 100644 --- a/polkadot/runtime/common/src/lib.rs +++ b/polkadot/runtime/common/src/lib.rs @@ -47,7 +47,7 @@ use frame_support::{ weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, }; use frame_system::limits; -use primitives::{AssignmentId, Balance, BlockNumber, ValidatorId}; +use polkadot_primitives::{AssignmentId, Balance, BlockNumber, ValidatorId}; use sp_runtime::{FixedPointNumber, Perbill, Perquintill}; use static_assertions::const_assert; @@ -123,7 +123,7 @@ macro_rules! impl_runtime_weights { use frame_support::{dispatch::DispatchClass, weights::Weight}; use frame_system::limits; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; - pub use runtime_common::{ + pub use polkadot_runtime_common::{ impl_elections_weights, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, }; @@ -165,7 +165,7 @@ macro_rules! impl_runtime_weights { /// /// This must only be used as long as the balance type is `u128`. pub type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote; -static_assertions::assert_eq_size!(primitives::Balance, u128); +static_assertions::assert_eq_size!(polkadot_primitives::Balance, u128); /// A placeholder since there is currently no provided session key handler for parachain validator /// keys. diff --git a/polkadot/runtime/common/src/mock.rs b/polkadot/runtime/common/src/mock.rs index c9e3a8c39f12..6534110cc210 100644 --- a/polkadot/runtime/common/src/mock.rs +++ b/polkadot/runtime/common/src/mock.rs @@ -17,11 +17,13 @@ //! Mocking utilities for testing. use crate::traits::Registrar; +use codec::{Decode, Encode}; use frame_support::{dispatch::DispatchResult, weights::Weight}; use frame_system::pallet_prelude::BlockNumberFor; -use parity_scale_codec::{Decode, Encode}; -use primitives::{HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode}; -use runtime_parachains::paras; +use polkadot_primitives::{ + HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode, +}; +use polkadot_runtime_parachains::paras; use sp_keyring::Sr25519Keyring; use sp_runtime::{traits::SaturatedConversion, DispatchError, Permill}; use std::{cell::RefCell, collections::HashMap}; @@ -239,7 +241,9 @@ impl frame_support::traits::EstimateNextSessionRotation for TestNextSession } } -pub fn validators_public_keys(validators: &[Sr25519Keyring]) -> Vec { +pub fn validators_public_keys( + validators: &[Sr25519Keyring], +) -> Vec { validators.iter().map(|v| v.public().into()).collect() } @@ -248,7 +252,7 @@ pub fn conclude_pvf_checking( validators: &[Sr25519Keyring], session_index: SessionIndex, ) { - let num_required = primitives::supermajority_threshold(validators.len()); + let num_required = polkadot_primitives::supermajority_threshold(validators.len()); validators.iter().enumerate().take(num_required).for_each(|(idx, key)| { let validator_index = idx as u32; let statement = PvfCheckStatement { diff --git a/polkadot/runtime/common/src/paras_registrar/mod.rs b/polkadot/runtime/common/src/paras_registrar/mod.rs index c90802a40129..9bbb152f855f 100644 --- a/polkadot/runtime/common/src/paras_registrar/mod.rs +++ b/polkadot/runtime/common/src/paras_registrar/mod.rs @@ -26,8 +26,10 @@ use frame_support::{ traits::{Currency, Get, ReservableCurrency}, }; use frame_system::{self, ensure_root, ensure_signed}; -use primitives::{HeadData, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID, MIN_CODE_SIZE}; -use runtime_parachains::{ +use polkadot_primitives::{ + HeadData, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID, MIN_CODE_SIZE, +}; +use polkadot_runtime_parachains::{ configuration, ensure_parachain, paras::{self, ParaGenesisArgs, UpgradeStrategy}, Origin, ParaLifecycle, @@ -35,9 +37,9 @@ use runtime_parachains::{ use sp_std::{prelude::*, result}; use crate::traits::{OnSwap, Registrar}; +use codec::{Decode, Encode}; pub use pallet::*; -use parity_scale_codec::{Decode, Encode}; -use runtime_parachains::paras::{OnNewHead, ParaKind}; +use polkadot_runtime_parachains::paras::{OnNewHead, ParaKind}; use scale_info::TypeInfo; use sp_runtime::{ traits::{CheckedSub, Saturating}, @@ -425,7 +427,7 @@ pub mod pallet { new_code: ValidationCode, ) -> DispatchResult { Self::ensure_root_para_or_owner(origin, para)?; - runtime_parachains::schedule_code_upgrade::( + polkadot_runtime_parachains::schedule_code_upgrade::( para, new_code, UpgradeStrategy::ApplyAtExpectedBlock, @@ -445,7 +447,7 @@ pub mod pallet { new_head: HeadData, ) -> DispatchResult { Self::ensure_root_para_or_owner(origin, para)?; - runtime_parachains::set_current_head::(para, new_head); + polkadot_runtime_parachains::set_current_head::(para, new_head); Ok(()) } } @@ -510,7 +512,7 @@ impl Registrar for Pallet { paras::Pallet::::lifecycle(id) == Some(ParaLifecycle::Parathread), Error::::NotParathread ); - runtime_parachains::schedule_parathread_upgrade::(id) + polkadot_runtime_parachains::schedule_parathread_upgrade::(id) .map_err(|_| Error::::CannotUpgrade)?; Ok(()) @@ -523,7 +525,7 @@ impl Registrar for Pallet { paras::Pallet::::lifecycle(id) == Some(ParaLifecycle::Parachain), Error::::NotParachain ); - runtime_parachains::schedule_parachain_downgrade::(id) + polkadot_runtime_parachains::schedule_parachain_downgrade::(id) .map_err(|_| Error::::CannotDowngrade)?; Ok(()) } @@ -545,7 +547,7 @@ impl Registrar for Pallet { #[cfg(any(feature = "runtime-benchmarks", test))] fn execute_pending_transitions() { - use runtime_parachains::shared; + use polkadot_runtime_parachains::shared; shared::Pallet::::set_session_index(shared::Pallet::::scheduled_session()); paras::Pallet::::test_on_new_session(); } @@ -634,7 +636,7 @@ impl Pallet { Paras::::insert(id, info); // We check above that para has no lifecycle, so this should not fail. - let res = runtime_parachains::schedule_para_initialize::(id, genesis); + let res = polkadot_runtime_parachains::schedule_para_initialize::(id, genesis); debug_assert!(res.is_ok()); Self::deposit_event(Event::::Registered { para_id: id, manager: who }); Ok(()) @@ -647,7 +649,7 @@ impl Pallet { Some(ParaLifecycle::Parathread) | None => {}, _ => return Err(Error::::NotParathread.into()), } - runtime_parachains::schedule_para_cleanup::(id) + polkadot_runtime_parachains::schedule_para_cleanup::(id) .map_err(|_| Error::::CannotDeregister)?; if let Some(info) = Paras::::take(&id) { @@ -686,9 +688,9 @@ impl Pallet { /// Swap a lease holding parachain and parathread (on-demand parachain), which involves /// scheduling an appropriate lifecycle update. fn do_thread_and_chain_swap(to_downgrade: ParaId, to_upgrade: ParaId) { - let res1 = runtime_parachains::schedule_parachain_downgrade::(to_downgrade); + let res1 = polkadot_runtime_parachains::schedule_parachain_downgrade::(to_downgrade); debug_assert!(res1.is_ok()); - let res2 = runtime_parachains::schedule_parathread_upgrade::(to_upgrade); + let res2 = polkadot_runtime_parachains::schedule_parathread_upgrade::(to_upgrade); debug_assert!(res2.is_ok()); T::OnSwap::on_swap(to_upgrade, to_downgrade); } @@ -723,8 +725,8 @@ mod tests { }; use frame_system::limits; use pallet_balances::Error as BalancesError; - use primitives::{Balance, BlockNumber, SessionIndex, MAX_CODE_SIZE}; - use runtime_parachains::{configuration, origin, shared}; + use polkadot_primitives::{Balance, BlockNumber, SessionIndex, MAX_CODE_SIZE}; + use polkadot_runtime_parachains::{configuration, origin, shared}; use sp_core::H256; use sp_io::TestExternalities; use sp_keyring::Sr25519Keyring; @@ -941,7 +943,7 @@ mod tests { } fn para_origin(id: ParaId) -> RuntimeOrigin { - runtime_parachains::Origin::Parachain(id).into() + polkadot_runtime_parachains::Origin::Parachain(id).into() } fn max_code_size() -> u32 { @@ -1527,8 +1529,8 @@ mod benchmarking { use crate::traits::Registrar as RegistrarT; use frame_support::assert_ok; use frame_system::RawOrigin; - use primitives::{MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MIN_CODE_SIZE}; - use runtime_parachains::{paras, shared, Origin as ParaOrigin}; + use polkadot_primitives::{MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MIN_CODE_SIZE}; + use polkadot_runtime_parachains::{paras, shared, Origin as ParaOrigin}; use sp_runtime::traits::Bounded; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; @@ -1554,7 +1556,7 @@ mod benchmarking { genesis_head, validation_code.clone() )); - assert_ok!(runtime_parachains::paras::Pallet::::add_trusted_validation_code( + assert_ok!(polkadot_runtime_parachains::paras::Pallet::::add_trusted_validation_code( frame_system::Origin::::Root.into(), validation_code, )); @@ -1595,7 +1597,7 @@ mod benchmarking { verify { assert_last_event::(Event::::Registered{ para_id: para, manager: caller }.into()); assert_eq!(paras::Pallet::::lifecycle(para), Some(ParaLifecycle::Onboarding)); - assert_ok!(runtime_parachains::paras::Pallet::::add_trusted_validation_code( + assert_ok!(polkadot_runtime_parachains::paras::Pallet::::add_trusted_validation_code( frame_system::Origin::::Root.into(), validation_code, )); @@ -1613,7 +1615,7 @@ mod benchmarking { verify { assert_last_event::(Event::::Registered { para_id: para, manager }.into()); assert_eq!(paras::Pallet::::lifecycle(para), Some(ParaLifecycle::Onboarding)); - assert_ok!(runtime_parachains::paras::Pallet::::add_trusted_validation_code( + assert_ok!(polkadot_runtime_parachains::paras::Pallet::::add_trusted_validation_code( frame_system::Origin::::Root.into(), validation_code, )); diff --git a/polkadot/runtime/common/src/paras_sudo_wrapper.rs b/polkadot/runtime/common/src/paras_sudo_wrapper.rs index b56dc96af436..3ff8d4ac08e1 100644 --- a/polkadot/runtime/common/src/paras_sudo_wrapper.rs +++ b/polkadot/runtime/common/src/paras_sudo_wrapper.rs @@ -16,12 +16,12 @@ //! A simple wrapper allowing `Sudo` to call into `paras` routines. +use codec::Encode; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; pub use pallet::*; -use parity_scale_codec::Encode; -use primitives::Id as ParaId; -use runtime_parachains::{ +use polkadot_primitives::Id as ParaId; +use polkadot_runtime_parachains::{ configuration, dmp, hrmp, paras::{self, AssignCoretime, ParaGenesisArgs}, ParaLifecycle, @@ -80,7 +80,7 @@ pub mod pallet { genesis: ParaGenesisArgs, ) -> DispatchResult { ensure_root(origin)?; - runtime_parachains::schedule_para_initialize::(id, genesis) + polkadot_runtime_parachains::schedule_para_initialize::(id, genesis) .map_err(|_| Error::::ParaAlreadyExists)?; T::AssignCoretime::assign_coretime(id)?; @@ -93,7 +93,7 @@ pub mod pallet { #[pallet::weight((1_000, DispatchClass::Operational))] pub fn sudo_schedule_para_cleanup(origin: OriginFor, id: ParaId) -> DispatchResult { ensure_root(origin)?; - runtime_parachains::schedule_para_cleanup::(id) + polkadot_runtime_parachains::schedule_para_cleanup::(id) .map_err(|_| Error::::CouldntCleanup)?; Ok(()) } @@ -111,7 +111,7 @@ pub mod pallet { paras::Pallet::::lifecycle(id) == Some(ParaLifecycle::Parathread), Error::::NotParathread, ); - runtime_parachains::schedule_parathread_upgrade::(id) + polkadot_runtime_parachains::schedule_parathread_upgrade::(id) .map_err(|_| Error::::CannotUpgrade)?; Ok(()) } @@ -129,7 +129,7 @@ pub mod pallet { paras::Pallet::::lifecycle(id) == Some(ParaLifecycle::Parachain), Error::::NotParachain, ); - runtime_parachains::schedule_parachain_downgrade::(id) + polkadot_runtime_parachains::schedule_parachain_downgrade::(id) .map_err(|_| Error::::CannotDowngrade)?; Ok(()) } diff --git a/polkadot/runtime/common/src/purchase.rs b/polkadot/runtime/common/src/purchase.rs index 3920a2c68c55..5ae6b422618e 100644 --- a/polkadot/runtime/common/src/purchase.rs +++ b/polkadot/runtime/common/src/purchase.rs @@ -16,13 +16,13 @@ //! Pallet to process purchase of DOTs. +use codec::{Decode, Encode}; use frame_support::{ pallet_prelude::*, traits::{Currency, EnsureOrigin, ExistenceRequirement, Get, VestingSchedule}, }; use frame_system::pallet_prelude::*; pub use pallet::*; -use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::sr25519; use sp_runtime::{ diff --git a/polkadot/runtime/common/src/slots/mod.rs b/polkadot/runtime/common/src/slots/mod.rs index 9da345beea39..900e04eaff18 100644 --- a/polkadot/runtime/common/src/slots/mod.rs +++ b/polkadot/runtime/common/src/slots/mod.rs @@ -32,7 +32,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; pub use pallet::*; -use primitives::Id as ParaId; +use polkadot_primitives::Id as ParaId; use sp_runtime::traits::{CheckedConversion, CheckedSub, Saturating, Zero}; use sp_std::prelude::*; @@ -503,11 +503,11 @@ mod tests { use super::*; use crate::{mock::TestRegistrar, slots}; - use ::test_helpers::{dummy_head_data, dummy_validation_code}; use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types}; use frame_system::EnsureRoot; use pallet_balances; - use primitives::BlockNumber; + use polkadot_primitives::BlockNumber; + use polkadot_primitives_test_helpers::{dummy_head_data, dummy_validation_code}; use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, @@ -985,7 +985,7 @@ mod benchmarking { use super::*; use frame_support::assert_ok; use frame_system::RawOrigin; - use runtime_parachains::paras; + use polkadot_runtime_parachains::paras; use sp_runtime::traits::{Bounded, One}; use frame_benchmarking::{account, benchmarks, whitelisted_caller, BenchmarkError}; diff --git a/polkadot/runtime/common/src/traits.rs b/polkadot/runtime/common/src/traits.rs index 8f75bf5c2fd8..2ed1fb8af9be 100644 --- a/polkadot/runtime/common/src/traits.rs +++ b/polkadot/runtime/common/src/traits.rs @@ -20,7 +20,7 @@ use frame_support::{ dispatch::DispatchResult, traits::{Currency, ReservableCurrency}, }; -use primitives::{HeadData, Id as ParaId, ValidationCode}; +use polkadot_primitives::{HeadData, Id as ParaId, ValidationCode}; use sp_std::vec::*; /// Parachain registration API. diff --git a/polkadot/runtime/common/src/xcm_sender.rs b/polkadot/runtime/common/src/xcm_sender.rs index cbec1a8ca103..5858a0ac3ca7 100644 --- a/polkadot/runtime/common/src/xcm_sender.rs +++ b/polkadot/runtime/common/src/xcm_sender.rs @@ -16,11 +16,11 @@ //! XCM sender for relay chain. +use codec::{Decode, Encode}; use frame_support::traits::Get; use frame_system::pallet_prelude::BlockNumberFor; -use parity_scale_codec::{Decode, Encode}; -use primitives::Id as ParaId; -use runtime_parachains::{ +use polkadot_primitives::Id as ParaId; +use polkadot_runtime_parachains::{ configuration::{self, HostConfiguration}, dmp, FeeTracker, }; @@ -259,7 +259,7 @@ mod tests { use super::*; use crate::integration_tests::new_test_ext; use frame_support::{assert_ok, parameter_types}; - use runtime_parachains::FeeTracker; + use polkadot_runtime_parachains::FeeTracker; use sp_runtime::FixedU128; use xcm::MAX_XCM_DECODE_DEPTH; diff --git a/polkadot/runtime/metrics/Cargo.toml b/polkadot/runtime/metrics/Cargo.toml index 76c1d134fa18..342c5a885033 100644 --- a/polkadot/runtime/metrics/Cargo.toml +++ b/polkadot/runtime/metrics/Cargo.toml @@ -12,8 +12,8 @@ workspace = true [dependencies] sp-std = { package = "sp-std", path = "../../../substrate/primitives/std", default-features = false } sp-tracing = { path = "../../../substrate/primitives/tracing", default-features = false } -parity-scale-codec = { version = "3.6.12", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false } +polkadot-primitives = { path = "../../primitives", default-features = false } frame-benchmarking = { path = "../../../substrate/frame/benchmarking", default-features = false, optional = true } bs58 = { version = "0.5.0", default-features = false, features = ["alloc"] } @@ -22,9 +22,9 @@ bs58 = { version = "0.5.0", default-features = false, features = ["alloc"] } default = ["std"] std = [ "bs58/std", + "codec/std", "frame-benchmarking?/std", - "parity-scale-codec/std", - "primitives/std", + "polkadot-primitives/std", "sp-std/std", "sp-tracing/std", ] diff --git a/polkadot/runtime/metrics/src/with_runtime_metrics.rs b/polkadot/runtime/metrics/src/with_runtime_metrics.rs index 562aa9ca162b..1339df9ff687 100644 --- a/polkadot/runtime/metrics/src/with_runtime_metrics.rs +++ b/polkadot/runtime/metrics/src/with_runtime_metrics.rs @@ -22,8 +22,8 @@ const TRACING_TARGET: &'static str = "metrics"; -use parity_scale_codec::Encode; -use primitives::{ +use codec::Encode; +use polkadot_primitives::{ metric_definitions::{CounterDefinition, CounterVecDefinition, HistogramDefinition}, RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate, }; diff --git a/polkadot/runtime/metrics/src/without_runtime_metrics.rs b/polkadot/runtime/metrics/src/without_runtime_metrics.rs index 41d9c24635ae..555cdf4751c8 100644 --- a/polkadot/runtime/metrics/src/without_runtime_metrics.rs +++ b/polkadot/runtime/metrics/src/without_runtime_metrics.rs @@ -18,7 +18,7 @@ //! provide a dummy implementation for the native runtime to avoid cluttering the runtime code //! with `#[cfg(feature = "runtime-metrics")]`. -use primitives::metric_definitions::{ +use polkadot_primitives::metric_definitions::{ CounterDefinition, CounterVecDefinition, HistogramDefinition, }; diff --git a/polkadot/runtime/parachains/Cargo.toml b/polkadot/runtime/parachains/Cargo.toml index d00a19c6ddb8..250fee65beef 100644 --- a/polkadot/runtime/parachains/Cargo.toml +++ b/polkadot/runtime/parachains/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] impl-trait-for-tuples = "0.2.2" bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } log = { workspace = true } rustc-hex = { version = "2.1.0", default-features = false } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } @@ -21,7 +21,7 @@ derive_more = "0.99.17" bitflags = "1.3.2" sp-api = { path = "../../../substrate/primitives/api", default-features = false } -inherents = { package = "sp-inherents", path = "../../../substrate/primitives/inherents", default-features = false } +sp-inherents = { path = "../../../substrate/primitives/inherents", default-features = false } sp-std = { package = "sp-std", path = "../../../substrate/primitives/std", default-features = false } sp-io = { path = "../../../substrate/primitives/io", default-features = false } sp-runtime = { path = "../../../substrate/primitives/runtime", default-features = false, features = ["serde"] } @@ -49,7 +49,7 @@ frame-system = { path = "../../../substrate/frame/system", default-features = fa xcm = { package = "staging-xcm", path = "../../xcm", default-features = false } xcm-executor = { package = "staging-xcm-executor", path = "../../xcm/xcm-executor", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } +polkadot-primitives = { path = "../../primitives", default-features = false } rand = { version = "0.8.5", default-features = false } rand_chacha = { version = "0.3.1", default-features = false } @@ -61,10 +61,10 @@ polkadot-core-primitives = { path = "../../core-primitives", default-features = [dev-dependencies] futures = "0.3.30" hex-literal = "0.4.1" -keyring = { package = "sp-keyring", path = "../../../substrate/primitives/keyring" } +sp-keyring = { path = "../../../substrate/primitives/keyring" } frame-support-test = { path = "../../../substrate/frame/support/test" } sc-keystore = { path = "../../../substrate/client/keystore" } -test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers" } +polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" } sp-tracing = { path = "../../../substrate/primitives/tracing" } sp-crypto-hashing = { path = "../../../substrate/primitives/crypto/hashing" } thousands = "0.2.0" @@ -77,10 +77,10 @@ default = ["std"] no_std = [] std = [ "bitvec/std", + "codec/std", "frame-benchmarking?/std", "frame-support/std", "frame-system/std", - "inherents/std", "log/std", "pallet-authority-discovery/std", "pallet-authorship/std", @@ -92,11 +92,10 @@ std = [ "pallet-staking/std", "pallet-timestamp/std", "pallet-vesting/std", - "parity-scale-codec/std", "polkadot-core-primitives/std", "polkadot-parachain-primitives/std", + "polkadot-primitives/std", "polkadot-runtime-metrics/std", - "primitives/std", "rand/std", "rand_chacha/std", "rustc-hex/std", @@ -106,6 +105,7 @@ std = [ "sp-application-crypto?/std", "sp-arithmetic/std", "sp-core/std", + "sp-inherents/std", "sp-io/std", "sp-keystore", "sp-keystore?/std", @@ -128,7 +128,7 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", - "primitives/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", "sp-application-crypto", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", diff --git a/polkadot/runtime/parachains/src/assigner_coretime/mock_helpers.rs b/polkadot/runtime/parachains/src/assigner_coretime/mock_helpers.rs index e2ba0b4f7ea5..6c63e062c4b9 100644 --- a/polkadot/runtime/parachains/src/assigner_coretime/mock_helpers.rs +++ b/polkadot/runtime/parachains/src/assigner_coretime/mock_helpers.rs @@ -26,7 +26,7 @@ use crate::{ }; use sp_runtime::Perbill; -use primitives::{Balance, HeadData, ValidationCode}; +use polkadot_primitives::{Balance, HeadData, ValidationCode}; fn default_genesis_config() -> MockGenesisConfig { MockGenesisConfig { @@ -44,7 +44,7 @@ pub struct GenesisConfigBuilder { pub on_demand_fee_variability: Perbill, pub on_demand_max_queue_size: u32, pub on_demand_target_queue_utilization: Perbill, - pub onboarded_on_demand_chains: Vec, + pub onboarded_on_demand_chains: Vec, } impl Default for GenesisConfigBuilder { diff --git a/polkadot/runtime/parachains/src/assigner_coretime/mod.rs b/polkadot/runtime/parachains/src/assigner_coretime/mod.rs index 1e821dd86846..e68ac2664b89 100644 --- a/polkadot/runtime/parachains/src/assigner_coretime/mod.rs +++ b/polkadot/runtime/parachains/src/assigner_coretime/mod.rs @@ -37,7 +37,7 @@ use crate::{ use frame_support::{defensive, pallet_prelude::*}; use frame_system::pallet_prelude::*; use pallet_broker::CoreAssignment; -use primitives::CoreIndex; +use polkadot_primitives::CoreIndex; use sp_runtime::traits::{One, Saturating}; use sp_std::prelude::*; @@ -317,7 +317,7 @@ impl AssignmentProvider> for Pallet { } #[cfg(any(feature = "runtime-benchmarks", test))] - fn get_mock_assignment(_: CoreIndex, para_id: primitives::Id) -> Assignment { + fn get_mock_assignment(_: CoreIndex, para_id: polkadot_primitives::Id) -> Assignment { // Given that we are not tracking anything in `Bulk` assignments, it is safe to always // return a bulk assignment. Assignment::Bulk(para_id) diff --git a/polkadot/runtime/parachains/src/assigner_coretime/tests.rs b/polkadot/runtime/parachains/src/assigner_coretime/tests.rs index 5d42a9d0c8ee..41cf21e267e4 100644 --- a/polkadot/runtime/parachains/src/assigner_coretime/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_coretime/tests.rs @@ -28,7 +28,7 @@ use crate::{ }; use frame_support::{assert_noop, assert_ok, pallet_prelude::*, traits::Currency}; use pallet_broker::TaskId; -use primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode}; +use polkadot_primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode}; use sp_std::collections::btree_map::BTreeMap; fn schedule_blank_para(id: ParaId, parakind: ParaKind) { diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs b/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs index 779d6f04e396..ba6951a14692 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/benchmarking.rs @@ -29,7 +29,7 @@ use frame_benchmarking::v2::*; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; -use primitives::{ +use polkadot_primitives::{ HeadData, Id as ParaId, SessionIndex, ValidationCode, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs b/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs index 50e5e1daf41a..314be11adbeb 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/migration.rs @@ -143,7 +143,7 @@ pub type MigrateV0ToV1 = VersionedMigration< mod tests { use super::{v0, v1, UncheckedOnRuntimeUpgrade, Weight}; use crate::mock::{new_test_ext, MockGenesisConfig, OnDemandAssigner, Test}; - use primitives::Id as ParaId; + use polkadot_primitives::Id as ParaId; #[test] fn migration_to_v1_preserves_queue_ordering() { diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/mock_helpers.rs b/polkadot/runtime/parachains/src/assigner_on_demand/mock_helpers.rs index f8d1a894f0e4..d2a7a221587d 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/mock_helpers.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/mock_helpers.rs @@ -25,7 +25,7 @@ use crate::{ paras::{ParaGenesisArgs, ParaKind}, }; -use primitives::{Balance, HeadData, ValidationCode}; +use polkadot_primitives::{Balance, HeadData, ValidationCode}; fn default_genesis_config() -> MockGenesisConfig { MockGenesisConfig { diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs b/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs index 795759b3b39e..043a36d99c49 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/mod.rs @@ -53,7 +53,7 @@ use frame_support::{ }, }; use frame_system::pallet_prelude::*; -use primitives::{CoreIndex, Id as ParaId, ON_DEMAND_MAX_QUEUE_MAX_SIZE}; +use polkadot_primitives::{CoreIndex, Id as ParaId, ON_DEMAND_MAX_QUEUE_MAX_SIZE}; use sp_runtime::{ traits::{One, SaturatedConversion}, FixedPointNumber, FixedPointOperand, FixedU128, Perbill, Saturating, diff --git a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs index 982efe77b939..8ac6ab77beee 100644 --- a/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_on_demand/tests.rs @@ -27,7 +27,7 @@ use crate::{ }; use frame_support::{assert_noop, assert_ok, error::BadOrigin}; use pallet_balances::Error as BalancesError; -use primitives::{BlockNumber, SessionIndex, ValidationCode}; +use polkadot_primitives::{BlockNumber, SessionIndex, ValidationCode}; use sp_std::collections::btree_map::BTreeMap; fn schedule_blank_para(id: ParaId, parakind: ParaKind) { diff --git a/polkadot/runtime/parachains/src/assigner_parachains.rs b/polkadot/runtime/parachains/src/assigner_parachains.rs index e79facd1fef0..3c735b999cf2 100644 --- a/polkadot/runtime/parachains/src/assigner_parachains.rs +++ b/polkadot/runtime/parachains/src/assigner_parachains.rs @@ -23,7 +23,7 @@ mod mock_helpers; mod tests; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::CoreIndex; +use polkadot_primitives::CoreIndex; use crate::{ configuration, paras, @@ -59,7 +59,7 @@ impl AssignmentProvider> for Pallet { fn push_back_assignment(_: Assignment) {} #[cfg(any(feature = "runtime-benchmarks", test))] - fn get_mock_assignment(_: CoreIndex, para_id: primitives::Id) -> Assignment { + fn get_mock_assignment(_: CoreIndex, para_id: polkadot_primitives::Id) -> Assignment { Assignment::Bulk(para_id) } diff --git a/polkadot/runtime/parachains/src/assigner_parachains/mock_helpers.rs b/polkadot/runtime/parachains/src/assigner_parachains/mock_helpers.rs index a46e114daeaf..d984fd9232c3 100644 --- a/polkadot/runtime/parachains/src/assigner_parachains/mock_helpers.rs +++ b/polkadot/runtime/parachains/src/assigner_parachains/mock_helpers.rs @@ -21,7 +21,7 @@ use crate::{ paras::{ParaGenesisArgs, ParaKind}, }; -use primitives::{Balance, HeadData, ValidationCode}; +use polkadot_primitives::{Balance, HeadData, ValidationCode}; use sp_runtime::Perbill; fn default_genesis_config() -> MockGenesisConfig { @@ -40,7 +40,7 @@ pub struct GenesisConfigBuilder { pub on_demand_fee_variability: Perbill, pub on_demand_max_queue_size: u32, pub on_demand_target_queue_utilization: Perbill, - pub onboarded_on_demand_chains: Vec, + pub onboarded_on_demand_chains: Vec, } impl Default for GenesisConfigBuilder { diff --git a/polkadot/runtime/parachains/src/assigner_parachains/tests.rs b/polkadot/runtime/parachains/src/assigner_parachains/tests.rs index a110686aaeb0..ebd24e89162a 100644 --- a/polkadot/runtime/parachains/src/assigner_parachains/tests.rs +++ b/polkadot/runtime/parachains/src/assigner_parachains/tests.rs @@ -24,7 +24,7 @@ use crate::{ paras::{ParaGenesisArgs, ParaKind}, }; use frame_support::{assert_ok, pallet_prelude::*}; -use primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode}; +use polkadot_primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode}; use sp_std::collections::btree_map::BTreeMap; fn schedule_blank_para(id: ParaId, parakind: ParaKind) { diff --git a/polkadot/runtime/parachains/src/builder.rs b/polkadot/runtime/parachains/src/builder.rs index d1e2bc392feb..5ed5a2b527c0 100644 --- a/polkadot/runtime/parachains/src/builder.rs +++ b/polkadot/runtime/parachains/src/builder.rs @@ -24,7 +24,7 @@ use crate::{ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; -use primitives::{ +use polkadot_primitives::{ collator_signature_payload, node_features::FeatureIndex, AvailabilityBitfield, BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CollatorId, CollatorSignature, CommittedCandidateReceipt, CompactStatement, CoreIndex, DisputeStatement, DisputeStatementSet, diff --git a/polkadot/runtime/parachains/src/configuration.rs b/polkadot/runtime/parachains/src/configuration.rs index 34923897f02b..10ecaa16a846 100644 --- a/polkadot/runtime/parachains/src/configuration.rs +++ b/polkadot/runtime/parachains/src/configuration.rs @@ -19,13 +19,13 @@ //! Configuration can change only at session boundaries and is buffered until then. use crate::{inclusion::MAX_UPWARD_MESSAGE_SIZE_BOUND, shared}; +use codec::{Decode, Encode}; use frame_support::{pallet_prelude::*, DefaultNoBound}; use frame_system::pallet_prelude::*; -use parity_scale_codec::{Decode, Encode}; use polkadot_parachain_primitives::primitives::{ MAX_HORIZONTAL_MESSAGE_NUM, MAX_UPWARD_MESSAGE_NUM, }; -use primitives::{ +use polkadot_primitives::{ ApprovalVotingParams, AsyncBackingParams, Balance, ExecutorParamError, ExecutorParams, NodeFeatures, SessionIndex, LEGACY_MIN_BACKING_VOTES, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE, ON_DEMAND_MAX_QUEUE_MAX_SIZE, @@ -42,7 +42,7 @@ mod benchmarking; pub mod migration; pub use pallet::*; -use primitives::vstaging::SchedulerParams; +use polkadot_primitives::vstaging::SchedulerParams; const LOG_TARGET: &str = "runtime::configuration"; @@ -1276,7 +1276,7 @@ pub mod pallet { fn integrity_test() { assert_eq!( &ActiveConfig::::hashed_key(), - primitives::well_known_keys::ACTIVE_CONFIG, + polkadot_primitives::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!", ); diff --git a/polkadot/runtime/parachains/src/configuration/benchmarking.rs b/polkadot/runtime/parachains/src/configuration/benchmarking.rs index 882b5aab096a..adc7f31a7b29 100644 --- a/polkadot/runtime/parachains/src/configuration/benchmarking.rs +++ b/polkadot/runtime/parachains/src/configuration/benchmarking.rs @@ -17,7 +17,7 @@ use crate::configuration::*; use frame_benchmarking::{benchmarks, BenchmarkError, BenchmarkResult}; use frame_system::RawOrigin; -use primitives::{ExecutorParam, ExecutorParams, PvfExecKind, PvfPrepKind}; +use polkadot_primitives::{ExecutorParam, ExecutorParams, PvfExecKind, PvfPrepKind}; use sp_runtime::traits::One; benchmarks! { diff --git a/polkadot/runtime/parachains/src/configuration/migration/v10.rs b/polkadot/runtime/parachains/src/configuration/migration/v10.rs index fa72c357d7da..c53f58faaf03 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v10.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v10.rs @@ -23,7 +23,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{ +use polkadot_primitives::{ AsyncBackingParams, Balance, ExecutorParams, NodeFeatures, SessionIndex, LEGACY_MIN_BACKING_VOTES, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; @@ -275,7 +275,7 @@ fn migrate_to_v10() -> Weight { mod tests { use super::*; use crate::mock::{new_test_ext, Test}; - use primitives::LEGACY_MIN_BACKING_VOTES; + use polkadot_primitives::LEGACY_MIN_BACKING_VOTES; #[test] fn v10_deserialized_from_actual_data() { @@ -304,7 +304,8 @@ mod tests { ]; let v10 = - V10HostConfiguration::::decode(&mut &raw_config[..]).unwrap(); + V10HostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); // We check only a sample of the values here. If we missed any fields or messed up data // types that would skew all the fields coming after. @@ -333,7 +334,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 v9 = V9HostConfiguration:: { + let v9 = V9HostConfiguration:: { needed_approvals: 69, paras_availability_period: 55, hrmp_recipient_deposit: 1337, @@ -368,7 +369,7 @@ mod tests { // pallet's storage. #[test] fn test_migrate_to_v10_no_pending() { - let v9 = V9HostConfiguration::::default(); + let v9 = V9HostConfiguration::::default(); new_test_ext(Default::default()).execute_with(|| { // Implant the v9 version in the state. diff --git a/polkadot/runtime/parachains/src/configuration/migration/v11.rs b/polkadot/runtime/parachains/src/configuration/migration/v11.rs index 65656e8d7c06..4d1bfc26196c 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v11.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v11.rs @@ -24,7 +24,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{ +use polkadot_primitives::{ ApprovalVotingParams, AsyncBackingParams, ExecutorParams, NodeFeatures, SessionIndex, LEGACY_MIN_BACKING_VOTES, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; @@ -289,7 +289,7 @@ approval_voting_params : ApprovalVotingParams { #[cfg(test)] mod tests { - use primitives::LEGACY_MIN_BACKING_VOTES; + use polkadot_primitives::LEGACY_MIN_BACKING_VOTES; use super::*; use crate::mock::{new_test_ext, Test}; @@ -321,7 +321,8 @@ mod tests { ]; let v11 = - V11HostConfiguration::::decode(&mut &raw_config[..]).unwrap(); + V11HostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); // We check only a sample of the values here. If we missed any fields or messed up data // types that would skew all the fields coming after. @@ -348,7 +349,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 v10 = V10HostConfiguration:: { + let v10 = V10HostConfiguration:: { needed_approvals: 69, paras_availability_period: 55, hrmp_recipient_deposit: 1337, @@ -424,7 +425,7 @@ mod tests { // pallet's storage. #[test] fn test_migrate_to_v11_no_pending() { - let v10 = V10HostConfiguration::::default(); + let v10 = V10HostConfiguration::::default(); new_test_ext(Default::default()).execute_with(|| { // Implant the v10 version in the state. diff --git a/polkadot/runtime/parachains/src/configuration/migration/v12.rs b/polkadot/runtime/parachains/src/configuration/migration/v12.rs index 69bacc83d044..126597ed8454 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v12.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v12.rs @@ -23,7 +23,7 @@ use frame_support::{ traits::{Defensive, UncheckedOnRuntimeUpgrade}, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::vstaging::SchedulerParams; +use polkadot_primitives::vstaging::SchedulerParams; use sp_core::Get; use sp_staking::SessionIndex; use sp_std::vec::Vec; @@ -181,7 +181,7 @@ fn migrate_to_v12() -> Weight { #[cfg(test)] mod tests { - use primitives::LEGACY_MIN_BACKING_VOTES; + use polkadot_primitives::LEGACY_MIN_BACKING_VOTES; use sp_arithmetic::Perbill; use super::*; @@ -214,7 +214,8 @@ mod tests { ]; let v12 = - V12HostConfiguration::::decode(&mut &raw_config[..]).unwrap(); + V12HostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); // We check only a sample of the values here. If we missed any fields or messed up data // types that would skew all the fields coming after. @@ -251,7 +252,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 v11 = V11HostConfiguration:: { + let v11 = V11HostConfiguration:: { needed_approvals: 69, paras_availability_period: 55, hrmp_recipient_deposit: 1337, @@ -334,7 +335,7 @@ mod tests { // pallet's storage. #[test] fn test_migrate_to_v12_no_pending() { - let v11 = V11HostConfiguration::::default(); + let v11 = V11HostConfiguration::::default(); new_test_ext(Default::default()).execute_with(|| { // Implant the v10 version in the state. diff --git a/polkadot/runtime/parachains/src/configuration/migration/v6.rs b/polkadot/runtime/parachains/src/configuration/migration/v6.rs index 19031a90bab4..bec41d3ea0dc 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v6.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v6.rs @@ -21,11 +21,11 @@ use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::BlockNumberFor; use sp_std::vec::Vec; -use primitives::{AsyncBackingParams, Balance, ExecutorParams, SessionIndex}; +use polkadot_primitives::{AsyncBackingParams, Balance, ExecutorParams, SessionIndex}; #[cfg(feature = "try-runtime")] use sp_std::prelude::*; -#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, Clone)] +#[derive(codec::Encode, codec::Decode, Debug, Clone)] pub struct V6HostConfiguration { pub max_code_size: u32, pub max_head_data_size: u32, diff --git a/polkadot/runtime/parachains/src/configuration/migration/v7.rs b/polkadot/runtime/parachains/src/configuration/migration/v7.rs index 1754b78e0a1d..8fe4087cf9b1 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v7.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v7.rs @@ -23,14 +23,14 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{AsyncBackingParams, Balance, ExecutorParams, SessionIndex}; +use polkadot_primitives::{AsyncBackingParams, Balance, ExecutorParams, SessionIndex}; use sp_std::vec::Vec; use frame_support::traits::OnRuntimeUpgrade; use super::v6::V6HostConfiguration; -#[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug, Clone)] +#[derive(codec::Encode, codec::Decode, Debug, Clone)] pub struct V7HostConfiguration { pub max_code_size: u32, pub max_head_data_size: u32, @@ -289,7 +289,8 @@ mod tests { let raw_config = hex_literal::hex!["00003000005000005555150000008000fbff0100000200000a000000c80000006400000000000000000000000000500000c800000a0000000000000000c0220fca950300000000000000000000c0220fca9503000000000000000000e8030000009001000a0000000000000000900100008070000000000000000000000a000000050000000500000001000000010500000001c80000000600000058020000020000002800000000000000020000000100000001020000000f000000"]; let v6 = - V6HostConfiguration::::decode(&mut &raw_config[..]).unwrap(); + V6HostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); // We check only a sample of the values here. If we missed any fields or messed up data // types that would skew all the fields coming after. @@ -312,7 +313,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 v6 = V6HostConfiguration:: { + let v6 = V6HostConfiguration:: { needed_approvals: 69, thread_availability_period: 55, hrmp_recipient_deposit: 1337, @@ -390,7 +391,7 @@ mod tests { // pallet's storage. #[test] fn test_migrate_to_v7_no_pending() { - let v6 = V6HostConfiguration::::default(); + let v6 = V6HostConfiguration::::default(); new_test_ext(Default::default()).execute_with(|| { // Implant the v6 version in the state. diff --git a/polkadot/runtime/parachains/src/configuration/migration/v8.rs b/polkadot/runtime/parachains/src/configuration/migration/v8.rs index 537dfa9abd77..0aa7f550b102 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v8.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v8.rs @@ -23,7 +23,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{ +use polkadot_primitives::{ AsyncBackingParams, Balance, ExecutorParams, SessionIndex, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; use sp_runtime::Perbill; @@ -304,7 +304,8 @@ mod tests { ]; let v8 = - V8HostConfiguration::::decode(&mut &raw_config[..]).unwrap(); + V8HostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); // We check only a sample of the values here. If we missed any fields or messed up data // types that would skew all the fields coming after. @@ -329,7 +330,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 v7 = V7HostConfiguration:: { + let v7 = V7HostConfiguration:: { needed_approvals: 69, thread_availability_period: 55, hrmp_recipient_deposit: 1337, @@ -403,7 +404,7 @@ mod tests { // pallet's storage. #[test] fn test_migrate_to_v8_no_pending() { - let v7 = V7HostConfiguration::::default(); + let v7 = V7HostConfiguration::::default(); new_test_ext(Default::default()).execute_with(|| { // Implant the v6 version in the state. diff --git a/polkadot/runtime/parachains/src/configuration/migration/v9.rs b/polkadot/runtime/parachains/src/configuration/migration/v9.rs index ca4bbd9dacef..6afdd3cec29e 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v9.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v9.rs @@ -23,7 +23,7 @@ use frame_support::{ weights::Weight, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{ +use polkadot_primitives::{ AsyncBackingParams, Balance, ExecutorParams, SessionIndex, LEGACY_MIN_BACKING_VOTES, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, }; @@ -308,7 +308,8 @@ mod tests { ]; let v9 = - V9HostConfiguration::::decode(&mut &raw_config[..]).unwrap(); + V9HostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); // We check only a sample of the values here. If we missed any fields or messed up data // types that would skew all the fields coming after. @@ -334,7 +335,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 v8 = V8HostConfiguration:: { + let v8 = V8HostConfiguration:: { needed_approvals: 69, paras_availability_period: 55, hrmp_recipient_deposit: 1337, @@ -408,7 +409,7 @@ mod tests { // pallet's storage. #[test] fn test_migrate_to_v9_no_pending() { - let v8 = V8HostConfiguration::::default(); + let v8 = V8HostConfiguration::::default(); new_test_ext(Default::default()).execute_with(|| { // Implant the v8 version in the state. diff --git a/polkadot/runtime/parachains/src/configuration/tests.rs b/polkadot/runtime/parachains/src/configuration/tests.rs index 64bbb8481fc1..dad8b6458e10 100644 --- a/polkadot/runtime/parachains/src/configuration/tests.rs +++ b/polkadot/runtime/parachains/src/configuration/tests.rs @@ -513,7 +513,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::{well_known_keys, AbridgedHostConfiguration}; + use polkadot_primitives::{well_known_keys, AbridgedHostConfiguration}; new_test_ext(Default::default()).execute_with(|| { let mut ground_truth = HostConfiguration::default(); diff --git a/polkadot/runtime/parachains/src/coretime/migration.rs b/polkadot/runtime/parachains/src/coretime/migration.rs index 6c8ddaa8aab3..3f82472da8aa 100644 --- a/polkadot/runtime/parachains/src/coretime/migration.rs +++ b/polkadot/runtime/parachains/src/coretime/migration.rs @@ -27,6 +27,10 @@ mod v_coretime { paras, }; #[cfg(feature = "try-runtime")] + use codec::Decode; + #[cfg(feature = "try-runtime")] + use codec::Encode; + #[cfg(feature = "try-runtime")] use frame_support::ensure; use frame_support::{ traits::{OnRuntimeUpgrade, PalletInfoAccess, StorageVersion}, @@ -34,12 +38,8 @@ mod v_coretime { }; use frame_system::pallet_prelude::BlockNumberFor; use pallet_broker::{CoreAssignment, CoreMask, ScheduleItem}; - #[cfg(feature = "try-runtime")] - use parity_scale_codec::Decode; - #[cfg(feature = "try-runtime")] - use parity_scale_codec::Encode; use polkadot_parachain_primitives::primitives::IsSystem; - use primitives::{CoreIndex, Id as ParaId}; + use polkadot_primitives::{CoreIndex, Id as ParaId}; use sp_arithmetic::traits::SaturatedConversion; use sp_core::Get; use sp_runtime::BoundedVec; diff --git a/polkadot/runtime/parachains/src/coretime/mod.rs b/polkadot/runtime/parachains/src/coretime/mod.rs index 33cbcb98fb29..dedffb733d33 100644 --- a/polkadot/runtime/parachains/src/coretime/mod.rs +++ b/polkadot/runtime/parachains/src/coretime/mod.rs @@ -24,7 +24,7 @@ use frame_support::{pallet_prelude::*, traits::Currency}; use frame_system::pallet_prelude::*; pub use pallet::*; use pallet_broker::{CoreAssignment, CoreIndex as BrokerCoreIndex}; -use primitives::{CoreIndex, Id as ParaId}; +use polkadot_primitives::{CoreIndex, Id as ParaId}; use sp_arithmetic::traits::SaturatedConversion; use xcm::prelude::{ send_xcm, Instruction, Junction, Location, OriginKind, SendXcm, WeightLimit, Xcm, diff --git a/polkadot/runtime/parachains/src/disputes.rs b/polkadot/runtime/parachains/src/disputes.rs index 62e02e67157d..4a0f2390b45d 100644 --- a/polkadot/runtime/parachains/src/disputes.rs +++ b/polkadot/runtime/parachains/src/disputes.rs @@ -20,17 +20,17 @@ use crate::{ configuration, initializer::SessionChangeNotification, metrics::METRICS, session_info, }; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0}; +use codec::{Decode, Encode}; use frame_support::{ensure, weights::Weight}; use frame_system::pallet_prelude::*; -use parity_scale_codec::{Decode, Encode}; -use polkadot_runtime_metrics::get_current_time; -use primitives::{ +use polkadot_primitives::{ byzantine_threshold, supermajority_threshold, ApprovalVote, ApprovalVoteMultipleCandidates, CandidateHash, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CompactStatement, ConsensusLog, DisputeState, DisputeStatement, DisputeStatementSet, ExplicitDisputeStatement, InvalidDisputeStatementKind, MultiDisputeStatementSet, SessionIndex, SigningContext, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature, }; +use polkadot_runtime_metrics::get_current_time; use scale_info::TypeInfo; use sp_runtime::{ traits::{AppVerify, One, Saturating, Zero}, diff --git a/polkadot/runtime/parachains/src/disputes/migration.rs b/polkadot/runtime/parachains/src/disputes/migration.rs index ccd367e41b36..e12edffb51b3 100644 --- a/polkadot/runtime/parachains/src/disputes/migration.rs +++ b/polkadot/runtime/parachains/src/disputes/migration.rs @@ -24,7 +24,7 @@ pub mod v1 { use frame_support::{ pallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade, weights::Weight, }; - use primitives::SessionIndex; + use polkadot_primitives::SessionIndex; use sp_std::prelude::*; #[storage_alias] diff --git a/polkadot/runtime/parachains/src/disputes/slashing.rs b/polkadot/runtime/parachains/src/disputes/slashing.rs index a61d0c899836..b50853ecc696 100644 --- a/polkadot/runtime/parachains/src/disputes/slashing.rs +++ b/polkadot/runtime/parachains/src/disputes/slashing.rs @@ -50,7 +50,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{ +use polkadot_primitives::{ slashing::{DisputeProof, DisputesTimeSlot, PendingSlashes, SlashingOffenceKind}, CandidateHash, SessionIndex, ValidatorId, ValidatorIndex, }; @@ -456,7 +456,8 @@ pub mod pallet { let validator_set_count = key_owner_proof.validator_count() as ValidatorSetCount; // check the membership proof to extract the offender's id - let key = (primitives::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + let key = + (polkadot_primitives::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof) .ok_or(Error::::InvalidKeyOwnershipProof)?; @@ -615,7 +616,7 @@ fn is_known_offence( key_owner_proof: &T::KeyOwnerProof, ) -> Result<(), TransactionValidityError> { // check the membership proof to extract the offender's id - let key = (primitives::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + let key = (polkadot_primitives::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) .ok_or(InvalidTransaction::BadProof)?; diff --git a/polkadot/runtime/parachains/src/disputes/slashing/benchmarking.rs b/polkadot/runtime/parachains/src/disputes/slashing/benchmarking.rs index 42a64725160c..b53f98caeea3 100644 --- a/polkadot/runtime/parachains/src/disputes/slashing/benchmarking.rs +++ b/polkadot/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -17,12 +17,12 @@ use super::*; use crate::{disputes::SlashingHandler, initializer, shared}; +use codec::Decode; use frame_benchmarking::{benchmarks, whitelist_account}; use frame_support::traits::{OnFinalize, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use pallet_staking::testing_utils::create_validators; -use parity_scale_codec::Decode; -use primitives::{Hash, PARACHAIN_KEY_TYPE_ID}; +use polkadot_primitives::{Hash, PARACHAIN_KEY_TYPE_ID}; use sp_runtime::traits::{One, OpaqueKeys, StaticLookup}; use sp_session::MembershipProof; diff --git a/polkadot/runtime/parachains/src/disputes/tests.rs b/polkadot/runtime/parachains/src/disputes/tests.rs index 16b4fa3a9f1a..f505bf4625a6 100644 --- a/polkadot/runtime/parachains/src/disputes/tests.rs +++ b/polkadot/runtime/parachains/src/disputes/tests.rs @@ -29,7 +29,7 @@ use frame_support::{ traits::{OnFinalize, OnInitialize}, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::BlockNumber; +use polkadot_primitives::BlockNumber; use sp_core::{crypto::CryptoType, Pair}; const VOTE_FOR: VoteKind = VoteKind::ExplicitValid; diff --git a/polkadot/runtime/parachains/src/dmp.rs b/polkadot/runtime/parachains/src/dmp.rs index df2f93e19421..c0e1635ba169 100644 --- a/polkadot/runtime/parachains/src/dmp.rs +++ b/polkadot/runtime/parachains/src/dmp.rs @@ -48,7 +48,7 @@ use crate::{ }; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage}; +use polkadot_primitives::{DownwardMessage, Hash, Id as ParaId, InboundDownwardMessage}; use sp_core::MAX_POSSIBLE_ALLOCATION; use sp_runtime::{ traits::{BlakeTwo256, Hash as HashT, SaturatedConversion}, diff --git a/polkadot/runtime/parachains/src/dmp/tests.rs b/polkadot/runtime/parachains/src/dmp/tests.rs index f39d7ae16733..de1515958125 100644 --- a/polkadot/runtime/parachains/src/dmp/tests.rs +++ b/polkadot/runtime/parachains/src/dmp/tests.rs @@ -19,10 +19,10 @@ use crate::{ configuration::ActiveConfig, mock::{new_test_ext, Dmp, MockGenesisConfig, Paras, System, Test}, }; +use codec::Encode; use frame_support::assert_ok; use hex_literal::hex; -use parity_scale_codec::Encode; -use primitives::BlockNumber; +use polkadot_primitives::BlockNumber; pub(crate) fn run_to_block(to: BlockNumber, new_session: Option>) { while System::block_number() < to { @@ -210,7 +210,7 @@ fn queue_downward_message_critical() { #[test] fn verify_dmq_mqc_head_is_externally_accessible() { use hex_literal::hex; - use primitives::well_known_keys; + use polkadot_primitives::well_known_keys; let a = ParaId::from(2020); diff --git a/polkadot/runtime/parachains/src/hrmp.rs b/polkadot/runtime/parachains/src/hrmp.rs index 42a9c23e5aa1..e34e4a03e711 100644 --- a/polkadot/runtime/parachains/src/hrmp.rs +++ b/polkadot/runtime/parachains/src/hrmp.rs @@ -18,11 +18,11 @@ use crate::{ configuration::{self, HostConfiguration}, dmp, ensure_parachain, initializer, paras, }; +use codec::{Decode, Encode}; use frame_support::{pallet_prelude::*, traits::ReservableCurrency, DefaultNoBound}; use frame_system::pallet_prelude::*; -use parity_scale_codec::{Decode, Encode}; use polkadot_parachain_primitives::primitives::{HorizontalMessages, IsSystem}; -use primitives::{ +use polkadot_primitives::{ Balance, Hash, HrmpChannelId, Id as ParaId, InboundHrmpMessage, OutboundHrmpMessage, SessionIndex, }; @@ -1864,7 +1864,7 @@ impl Pallet { /// If the XCM version is unknown, the latest XCM version is used as a best effort. fn wrap_notification( mut notification: impl FnMut() -> xcm::opaque::latest::opaque::Xcm, - ) -> impl FnOnce(ParaId) -> primitives::DownwardMessage { + ) -> impl FnOnce(ParaId) -> polkadot_primitives::DownwardMessage { use xcm::{ opaque::VersionedXcm, prelude::{Junction, Location}, @@ -1892,7 +1892,7 @@ impl Pallet { log_label: &str, config: &HostConfiguration>, dest: ParaId, - notification_bytes_for: impl FnOnce(ParaId) -> primitives::DownwardMessage, + notification_bytes_for: impl FnOnce(ParaId) -> polkadot_primitives::DownwardMessage, ) { // prepare notification let notification_bytes = notification_bytes_for(dest); diff --git a/polkadot/runtime/parachains/src/hrmp/tests.rs b/polkadot/runtime/parachains/src/hrmp/tests.rs index acfaa8f2d290..4fcbc69e98ad 100644 --- a/polkadot/runtime/parachains/src/hrmp/tests.rs +++ b/polkadot/runtime/parachains/src/hrmp/tests.rs @@ -28,7 +28,7 @@ use crate::{ shared, }; use frame_support::{assert_noop, assert_ok, error::BadOrigin}; -use primitives::{BlockNumber, InboundDownwardMessage}; +use polkadot_primitives::{BlockNumber, InboundDownwardMessage}; use std::collections::BTreeMap; pub(crate) fn run_to_block(to: BlockNumber, new_session: Option>) { @@ -660,7 +660,7 @@ fn check_sent_messages() { #[test] fn verify_externally_accessible() { - use primitives::{well_known_keys, AbridgedHrmpChannel}; + use polkadot_primitives::{well_known_keys, AbridgedHrmpChannel}; let para_a = 2020.into(); let para_b = 2021.into(); diff --git a/polkadot/runtime/parachains/src/inclusion/migration.rs b/polkadot/runtime/parachains/src/inclusion/migration.rs index 5f35680ee694..a340d52643e0 100644 --- a/polkadot/runtime/parachains/src/inclusion/migration.rs +++ b/polkadot/runtime/parachains/src/inclusion/migration.rs @@ -16,10 +16,10 @@ pub use v1::MigrateToV1; pub mod v0 { use crate::inclusion::{Config, Pallet}; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; + use codec::{Decode, Encode}; use frame_support::{storage_alias, Twox64Concat}; use frame_system::pallet_prelude::BlockNumberFor; - use parity_scale_codec::{Decode, Encode}; - use primitives::{ + use polkadot_primitives::{ AvailabilityBitfield, CandidateCommitments, CandidateDescriptor, CandidateHash, CoreIndex, GroupIndex, Id as ParaId, ValidatorIndex, }; @@ -77,13 +77,13 @@ mod v1 { use sp_core::Get; use sp_std::{collections::vec_deque::VecDeque, vec::Vec}; + #[cfg(feature = "try-runtime")] + use codec::{Decode, Encode}; #[cfg(feature = "try-runtime")] use frame_support::{ ensure, traits::{GetStorageVersion, StorageVersion}, }; - #[cfg(feature = "try-runtime")] - use parity_scale_codec::{Decode, Encode}; pub struct VersionUncheckedMigrateToV1(sp_std::marker::PhantomData); @@ -217,8 +217,10 @@ mod tests { mock::{new_test_ext, MockGenesisConfig, Test}, }; use frame_support::traits::UncheckedOnRuntimeUpgrade; - use primitives::{AvailabilityBitfield, Id as ParaId}; - use test_helpers::{dummy_candidate_commitments, dummy_candidate_descriptor, dummy_hash}; + use polkadot_primitives::{AvailabilityBitfield, Id as ParaId}; + use polkadot_primitives_test_helpers::{ + dummy_candidate_commitments, dummy_candidate_descriptor, dummy_hash, + }; #[test] fn migrate_to_v1() { diff --git a/polkadot/runtime/parachains/src/inclusion/mod.rs b/polkadot/runtime/parachains/src/inclusion/mod.rs index 0c7274984085..a86941a1a0b8 100644 --- a/polkadot/runtime/parachains/src/inclusion/mod.rs +++ b/polkadot/runtime/parachains/src/inclusion/mod.rs @@ -28,6 +28,7 @@ use crate::{ util::make_persisted_validation_data_with_parent, }; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; +use codec::{Decode, Encode}; use frame_support::{ defensive, pallet_prelude::*, @@ -36,8 +37,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use pallet_message_queue::OnQueueChanged; -use parity_scale_codec::{Decode, Encode}; -use primitives::{ +use polkadot_primitives::{ effective_minimum_backing_votes, supermajority_threshold, well_known_keys, BackedCandidate, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidateReceipt, CommittedCandidateReceipt, CoreIndex, GroupIndex, Hash, HeadData, Id as ParaId, @@ -746,7 +746,7 @@ impl Pallet { backed_candidate.validator_indices_and_core_index(core_index_enabled); // check the signatures in the backing and that it is a majority. - let maybe_amount_validated = primitives::check_candidate_backing( + let maybe_amount_validated = polkadot_primitives::check_candidate_backing( backed_candidate.candidate().hash(), backed_candidate.validity_votes(), validator_indices, @@ -795,7 +795,7 @@ impl Pallet { pub(crate) fn check_validation_outputs_for_runtime_api( para_id: ParaId, relay_parent_number: BlockNumberFor, - validation_outputs: primitives::CandidateCommitments, + validation_outputs: polkadot_primitives::CandidateCommitments, ) -> bool { let prev_context = paras::MostRecentContext::::get(para_id); let check_ctx = CandidateCheckContext::::new(prev_context); @@ -1319,11 +1319,11 @@ impl CandidateCheckContext { para_id: ParaId, relay_parent_number: BlockNumberFor, head_data: &HeadData, - new_validation_code: &Option, + new_validation_code: &Option, processed_downward_messages: u32, - upward_messages: &[primitives::UpwardMessage], + upward_messages: &[polkadot_primitives::UpwardMessage], hrmp_watermark: BlockNumberFor, - horizontal_messages: &[primitives::OutboundHrmpMessage], + horizontal_messages: &[polkadot_primitives::OutboundHrmpMessage], ) -> Result<(), AcceptanceCheckErr> { ensure!( head_data.0.len() <= self.config.max_head_data_size as _, diff --git a/polkadot/runtime/parachains/src/inclusion/tests.rs b/polkadot/runtime/parachains/src/inclusion/tests.rs index c19bc6eb7bfc..18def664f4b2 100644 --- a/polkadot/runtime/parachains/src/inclusion/tests.rs +++ b/polkadot/runtime/parachains/src/inclusion/tests.rs @@ -25,24 +25,26 @@ use crate::{ paras_inherent::DisputedBitfield, shared::AllowedRelayParentsTracker, }; -use primitives::{ +use polkadot_primitives::{ effective_minimum_backing_votes, AvailabilityBitfield, SignedAvailabilityBitfields, UncheckedSignedAvailabilityBitfields, }; use assert_matches::assert_matches; +use codec::DecodeAll; use frame_support::assert_noop; -use keyring::Sr25519Keyring; -use parity_scale_codec::DecodeAll; -use primitives::{ +use polkadot_primitives::{ BlockNumber, CandidateCommitments, CandidateDescriptor, CollatorId, CompactStatement as Statement, Hash, SignedAvailabilityBitfield, SignedStatement, ValidationCode, ValidatorId, ValidityAttestation, PARACHAIN_KEY_TYPE_ID, }; +use polkadot_primitives_test_helpers::{ + dummy_collator, dummy_collator_signature, dummy_validation_code, +}; use sc_keystore::LocalKeystore; +use sp_keyring::Sr25519Keyring; use sp_keystore::{Keystore, KeystorePtr}; use std::sync::Arc; -use test_helpers::{dummy_collator, dummy_collator_signature, dummy_validation_code}; fn default_config() -> HostConfiguration { let mut config = HostConfiguration::default(); @@ -100,7 +102,7 @@ pub(crate) fn collator_sign_candidate( ) { candidate.descriptor.collator = collator.public().into(); - let payload = primitives::collator_signature_payload( + let payload = polkadot_primitives::collator_signature_payload( &candidate.descriptor.relay_parent, &candidate.descriptor.para_id, &candidate.descriptor.persisted_validation_data_hash, @@ -158,7 +160,7 @@ pub(crate) fn back_candidate( let backed = BackedCandidate::new(candidate, validity_votes, validator_indices.clone(), core_index); - let successfully_backed = primitives::check_candidate_backing( + let successfully_backed = polkadot_primitives::check_candidate_backing( backed.candidate().hash(), backed.validity_votes(), validator_indices.as_bitslice(), diff --git a/polkadot/runtime/parachains/src/initializer.rs b/polkadot/runtime/parachains/src/initializer.rs index 511d74421032..fd0f1c3c0651 100644 --- a/polkadot/runtime/parachains/src/initializer.rs +++ b/polkadot/runtime/parachains/src/initializer.rs @@ -25,13 +25,13 @@ use crate::{ disputes::{self, DisputesHandler as _, SlashingHandler as _}, dmp, hrmp, inclusion, paras, scheduler, session_info, shared, }; +use codec::{Decode, Encode}; use frame_support::{ traits::{OneSessionHandler, Randomness}, weights::Weight, }; use frame_system::limits::BlockWeights; -use parity_scale_codec::{Decode, Encode}; -use primitives::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId}; +use polkadot_primitives::{BlockNumber, ConsensusLog, SessionIndex, ValidatorId}; use scale_info::TypeInfo; use sp_std::prelude::*; diff --git a/polkadot/runtime/parachains/src/initializer/benchmarking.rs b/polkadot/runtime/parachains/src/initializer/benchmarking.rs index ece41c726f04..2083c058fd04 100644 --- a/polkadot/runtime/parachains/src/initializer/benchmarking.rs +++ b/polkadot/runtime/parachains/src/initializer/benchmarking.rs @@ -17,7 +17,7 @@ use super::*; use frame_benchmarking::benchmarks; use frame_system::RawOrigin; -use primitives::ConsensusLog; +use polkadot_primitives::ConsensusLog; use sp_runtime::DigestItem; // Random large number for the digest diff --git a/polkadot/runtime/parachains/src/initializer/tests.rs b/polkadot/runtime/parachains/src/initializer/tests.rs index e757e6b9d117..a2bdb36eaa64 100644 --- a/polkadot/runtime/parachains/src/initializer/tests.rs +++ b/polkadot/runtime/parachains/src/initializer/tests.rs @@ -20,8 +20,8 @@ use crate::{ paras::ParaKind, session_info, }; -use primitives::{HeadData, Id as ParaId}; -use test_helpers::dummy_validation_code; +use polkadot_primitives::{HeadData, Id as ParaId}; +use polkadot_primitives_test_helpers::dummy_validation_code; use frame_support::{ assert_ok, diff --git a/polkadot/runtime/parachains/src/lib.rs b/polkadot/runtime/parachains/src/lib.rs index 97d6ab74904d..51110e89416c 100644 --- a/polkadot/runtime/parachains/src/lib.rs +++ b/polkadot/runtime/parachains/src/lib.rs @@ -55,7 +55,7 @@ mod ump_tests; pub use origin::{ensure_parachain, Origin}; pub use paras::{ParaLifecycle, UpgradeStrategy}; -use primitives::{HeadData, Id as ParaId, ValidationCode}; +use polkadot_primitives::{HeadData, Id as ParaId, ValidationCode}; use sp_runtime::{DispatchResult, FixedU128}; /// Trait for tracking message delivery fees on a transport protocol. @@ -86,7 +86,7 @@ pub fn schedule_para_initialize( } /// Schedule a para to be cleaned up at the start of the next session. -pub fn schedule_para_cleanup(id: primitives::Id) -> Result<(), ()> { +pub fn schedule_para_cleanup(id: polkadot_primitives::Id) -> Result<(), ()> { paras::Pallet::::schedule_para_cleanup(id).map_err(|_| ()) } diff --git a/polkadot/runtime/parachains/src/metrics.rs b/polkadot/runtime/parachains/src/metrics.rs index 023bd09f83a8..7a17aafabd12 100644 --- a/polkadot/runtime/parachains/src/metrics.rs +++ b/polkadot/runtime/parachains/src/metrics.rs @@ -16,13 +16,13 @@ //! Runtime declaration of the parachain metrics. -use polkadot_runtime_metrics::{Counter, CounterVec, Histogram}; -use primitives::metric_definitions::{ +use polkadot_primitives::metric_definitions::{ PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS, PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED, PARACHAIN_INHERENT_DATA_WEIGHT, PARACHAIN_VERIFY_DISPUTE_SIGNATURE, }; +use polkadot_runtime_metrics::{Counter, CounterVec, Histogram}; pub struct Metrics { /// Samples inherent data weight. diff --git a/polkadot/runtime/parachains/src/mock.rs b/polkadot/runtime/parachains/src/mock.rs index 75b835b17541..0a0be8432b25 100644 --- a/polkadot/runtime/parachains/src/mock.rs +++ b/polkadot/runtime/parachains/src/mock.rs @@ -27,8 +27,9 @@ use crate::{ session_info, shared, ParaId, }; use frame_support::pallet_prelude::*; -use primitives::CoreIndex; +use polkadot_primitives::CoreIndex; +use codec::Decode; use frame_support::{ assert_ok, derive_impl, parameter_types, traits::{ @@ -38,8 +39,7 @@ use frame_support::{ }; use frame_support_test::TestRandomness; use frame_system::limits; -use parity_scale_codec::Decode; -use primitives::{ +use polkadot_primitives::{ AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Moment, SessionIndex, UpwardMessage, ValidationCode, ValidatorIndex, }; diff --git a/polkadot/runtime/parachains/src/origin.rs b/polkadot/runtime/parachains/src/origin.rs index c83fec1b8923..5202cba232d2 100644 --- a/polkadot/runtime/parachains/src/origin.rs +++ b/polkadot/runtime/parachains/src/origin.rs @@ -16,7 +16,7 @@ //! Declaration of the parachain specific origin and a pallet that hosts it. -use primitives::Id as ParaId; +use polkadot_primitives::Id as ParaId; use sp_runtime::traits::BadOrigin; use sp_std::result; diff --git a/polkadot/runtime/parachains/src/paras/benchmarking.rs b/polkadot/runtime/parachains/src/paras/benchmarking.rs index 437c4091a98b..0f3318612a77 100644 --- a/polkadot/runtime/parachains/src/paras/benchmarking.rs +++ b/polkadot/runtime/parachains/src/paras/benchmarking.rs @@ -18,7 +18,9 @@ use super::*; use crate::configuration::HostConfiguration; use frame_benchmarking::benchmarks; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; -use primitives::{HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; +use polkadot_primitives::{ + HeadData, Id as ParaId, ValidationCode, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, +}; use sp_runtime::traits::{One, Saturating}; mod pvf_check; diff --git a/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs b/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs index 9281332fdada..0bf5fe783a0e 100644 --- a/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs +++ b/polkadot/runtime/parachains/src/paras/benchmarking/pvf_check.rs @@ -19,7 +19,7 @@ use crate::{configuration, paras::*, shared::Pallet as ParasShared}; use frame_support::assert_ok; use frame_system::RawOrigin; -use primitives::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; +use polkadot_primitives::{HeadData, Id as ParaId, ValidationCode, ValidatorId, ValidatorIndex}; use sp_application_crypto::RuntimeAppPublic; // Constants for the benchmarking @@ -204,7 +204,7 @@ where { let validators = shared::ActiveValidatorKeys::::get(); - let accept_threshold = primitives::supermajority_threshold(validators.len()); + let accept_threshold = polkadot_primitives::supermajority_threshold(validators.len()); let required_votes = match vote_outcome { VoteOutcome::Accept => accept_threshold, VoteOutcome::Reject => validators.len() - accept_threshold, diff --git a/polkadot/runtime/parachains/src/paras/mod.rs b/polkadot/runtime/parachains/src/paras/mod.rs index 36a693bcc8e2..8cffcbbbb024 100644 --- a/polkadot/runtime/parachains/src/paras/mod.rs +++ b/polkadot/runtime/parachains/src/paras/mod.rs @@ -114,10 +114,10 @@ use crate::{ shared, }; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; +use codec::{Decode, Encode}; use frame_support::{pallet_prelude::*, traits::EstimateNextSessionRotation, DefaultNoBound}; use frame_system::pallet_prelude::*; -use parity_scale_codec::{Decode, Encode}; -use primitives::{ +use polkadot_primitives::{ ConsensusLog, HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, UpgradeGoAhead, UpgradeRestriction, ValidationCode, ValidationCodeHash, ValidatorSignature, MIN_CODE_SIZE, }; @@ -348,9 +348,7 @@ impl Encode for ParaKind { } impl Decode for ParaKind { - fn decode( - input: &mut I, - ) -> Result { + fn decode(input: &mut I) -> Result { match bool::decode(input) { Ok(true) => Ok(ParaKind::Parachain), Ok(false) => Ok(ParaKind::Parathread), @@ -487,7 +485,7 @@ impl PvfCheckActiveVoteState { /// Returns `None` if the quorum is not reached, or the direction of the decision. fn quorum(&self, n_validators: usize) -> Option { - let accept_threshold = primitives::supermajority_threshold(n_validators); + let accept_threshold = polkadot_primitives::supermajority_threshold(n_validators); // At this threshold, a supermajority is no longer possible, so we reject. let reject_threshold = n_validators - accept_threshold; diff --git a/polkadot/runtime/parachains/src/paras/tests.rs b/polkadot/runtime/parachains/src/paras/tests.rs index 0b458f2f91eb..732b75417387 100644 --- a/polkadot/runtime/parachains/src/paras/tests.rs +++ b/polkadot/runtime/parachains/src/paras/tests.rs @@ -16,12 +16,12 @@ use super::*; use frame_support::{assert_err, assert_ok, assert_storage_noop}; -use keyring::Sr25519Keyring; -use primitives::{vstaging::SchedulerParams, BlockNumber, PARACHAIN_KEY_TYPE_ID}; +use polkadot_primitives::{vstaging::SchedulerParams, BlockNumber, PARACHAIN_KEY_TYPE_ID}; +use polkadot_primitives_test_helpers::{dummy_head_data, dummy_validation_code, validator_pubkeys}; use sc_keystore::LocalKeystore; +use sp_keyring::Sr25519Keyring; use sp_keystore::{Keystore, KeystorePtr}; use std::sync::Arc; -use test_helpers::{dummy_head_data, dummy_validation_code, validator_pubkeys}; use crate::{ configuration::HostConfiguration, @@ -135,7 +135,10 @@ 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<::RuntimeEvent, primitives::Hash>, + frame_system::EventRecord< + ::RuntimeEvent, + polkadot_primitives::Hash, + >, >, } @@ -1810,7 +1813,7 @@ fn add_trusted_validation_code_enacts_existing_pvf_vote() { #[test] fn verify_upgrade_go_ahead_signal_is_externally_accessible() { - use primitives::well_known_keys; + use polkadot_primitives::well_known_keys; let a = ParaId::from(2020); @@ -1826,7 +1829,7 @@ fn verify_upgrade_go_ahead_signal_is_externally_accessible() { #[test] fn verify_upgrade_restriction_signal_is_externally_accessible() { - use primitives::well_known_keys; + use polkadot_primitives::well_known_keys; let a = ParaId::from(2020); @@ -1842,7 +1845,7 @@ fn verify_upgrade_restriction_signal_is_externally_accessible() { #[test] fn verify_para_head_is_externally_accessible() { - use primitives::well_known_keys; + use polkadot_primitives::well_known_keys; let a = ParaId::from(2020); let expected_head_data = HeadData(vec![0, 1, 2, 3]); diff --git a/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs b/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs index e643888ae29a..267a9781a106 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/benchmarking.rs @@ -20,7 +20,7 @@ use frame_benchmarking::{benchmarks, impl_benchmark_test_suite}; use frame_system::RawOrigin; use sp_std::{cmp::min, collections::btree_map::BTreeMap}; -use primitives::v7::GroupIndex; +use polkadot_primitives::v7::GroupIndex; use crate::builder::BenchBuilder; diff --git a/polkadot/runtime/parachains/src/paras_inherent/mod.rs b/polkadot/runtime/parachains/src/paras_inherent/mod.rs index ac4cf5dc8d41..386873aad457 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/mod.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/mod.rs @@ -42,7 +42,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use pallet_babe::{self, ParentBlockRandomness}; -use primitives::{ +use polkadot_primitives::{ effective_minimum_backing_votes, node_features::FeatureIndex, BackedCandidate, CandidateHash, CandidateReceipt, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CoreIndex, DisputeStatementSet, HeadData, InherentData as ParachainsInherentData, diff --git a/polkadot/runtime/parachains/src/paras_inherent/tests.rs b/polkadot/runtime/parachains/src/paras_inherent/tests.rs index 64fbc9c4a4e0..06a544296461 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/tests.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/tests.rs @@ -20,7 +20,7 @@ use crate::{ configuration::{self, HostConfiguration}, mock::MockGenesisConfig, }; -use primitives::vstaging::SchedulerParams; +use polkadot_primitives::vstaging::SchedulerParams; fn default_config() -> MockGenesisConfig { MockGenesisConfig { @@ -57,7 +57,7 @@ mod enter { use core::panic; use frame_support::assert_ok; use frame_system::limits; - use primitives::{vstaging::SchedulerParams, AvailabilityBitfield, UncheckedSigned}; + use polkadot_primitives::{vstaging::SchedulerParams, AvailabilityBitfield, UncheckedSigned}; use sp_runtime::Perbill; use sp_std::collections::btree_map::BTreeMap; @@ -494,7 +494,7 @@ mod enter { #[test] fn test_session_is_tracked_in_on_chain_scraping() { use crate::disputes::run_to_block; - use primitives::{ + use polkadot_primitives::{ DisputeStatement, DisputeStatementSet, ExplicitDisputeStatement, InvalidDisputeStatementKind, ValidDisputeStatementKind, }; @@ -1467,8 +1467,8 @@ mod enter { } } -fn default_header() -> primitives::Header { - primitives::Header { +fn default_header() -> polkadot_primitives::Header { + polkadot_primitives::Header { parent_hash: Default::default(), number: 0, state_root: Default::default(), @@ -1487,7 +1487,7 @@ mod sanitizers { mock::new_test_ext, }; use bitvec::order::Lsb0; - use primitives::{ + use polkadot_primitives::{ AvailabilityBitfield, GroupIndex, Hash, Id as ParaId, SignedAvailabilityBitfield, ValidatorIndex, }; @@ -1495,13 +1495,13 @@ mod sanitizers { use sp_core::crypto::UncheckedFrom; use crate::mock::Test; - use keyring::Sr25519Keyring; - use primitives::PARACHAIN_KEY_TYPE_ID; + use polkadot_primitives::PARACHAIN_KEY_TYPE_ID; use sc_keystore::LocalKeystore; + use sp_keyring::Sr25519Keyring; use sp_keystore::{Keystore, KeystorePtr}; use std::sync::Arc; - fn validator_pubkeys(val_ids: &[keyring::Sr25519Keyring]) -> Vec { + fn validator_pubkeys(val_ids: &[sp_keyring::Sr25519Keyring]) -> Vec { val_ids.iter().map(|v| v.public().into()).collect() } @@ -1518,10 +1518,10 @@ mod sanitizers { let signing_context = SigningContext { parent_hash, session_index }; let validators = vec![ - keyring::Sr25519Keyring::Alice, - keyring::Sr25519Keyring::Bob, - keyring::Sr25519Keyring::Charlie, - keyring::Sr25519Keyring::Dave, + sp_keyring::Sr25519Keyring::Alice, + sp_keyring::Sr25519Keyring::Bob, + sp_keyring::Sr25519Keyring::Charlie, + sp_keyring::Sr25519Keyring::Dave, ]; for validator in validators.iter() { Keystore::sr25519_generate_new( @@ -1744,7 +1744,7 @@ mod sanitizers { scheduler::{common::Assignment, ParasEntry}, util::{make_persisted_validation_data, make_persisted_validation_data_with_parent}, }; - use primitives::ValidationCode; + use polkadot_primitives::ValidationCode; use sp_std::collections::vec_deque::VecDeque; use super::*; @@ -1754,7 +1754,7 @@ mod sanitizers { backed_candidates: Vec, expected_backed_candidates_with_core: BTreeMap>, - scheduled_paras: BTreeMap>, + scheduled_paras: BTreeMap>, } // Generate test data for the candidates and assert that the environment is set as expected @@ -1780,11 +1780,11 @@ mod sanitizers { let signing_context = SigningContext { parent_hash: relay_parent, session_index }; let validators = vec![ - keyring::Sr25519Keyring::Alice, - keyring::Sr25519Keyring::Bob, - keyring::Sr25519Keyring::Charlie, - keyring::Sr25519Keyring::Dave, - keyring::Sr25519Keyring::Eve, + sp_keyring::Sr25519Keyring::Alice, + sp_keyring::Sr25519Keyring::Bob, + sp_keyring::Sr25519Keyring::Charlie, + sp_keyring::Sr25519Keyring::Dave, + sp_keyring::Sr25519Keyring::Eve, ]; for validator in validators.iter() { Keystore::sr25519_generate_new( @@ -1965,14 +1965,14 @@ mod sanitizers { let signing_context = SigningContext { parent_hash: relay_parent, session_index }; let validators = vec![ - keyring::Sr25519Keyring::Alice, - keyring::Sr25519Keyring::Bob, - keyring::Sr25519Keyring::Charlie, - keyring::Sr25519Keyring::Dave, - keyring::Sr25519Keyring::Eve, - keyring::Sr25519Keyring::Ferdie, - keyring::Sr25519Keyring::One, - keyring::Sr25519Keyring::Two, + sp_keyring::Sr25519Keyring::Alice, + sp_keyring::Sr25519Keyring::Bob, + sp_keyring::Sr25519Keyring::Charlie, + sp_keyring::Sr25519Keyring::Dave, + sp_keyring::Sr25519Keyring::Eve, + sp_keyring::Sr25519Keyring::Ferdie, + sp_keyring::Sr25519Keyring::One, + sp_keyring::Sr25519Keyring::Two, ]; for validator in validators.iter() { Keystore::sr25519_generate_new( @@ -2504,15 +2504,15 @@ mod sanitizers { let signing_context = SigningContext { parent_hash: relay_parent, session_index }; let validators = vec![ - keyring::Sr25519Keyring::Alice, - keyring::Sr25519Keyring::Bob, - keyring::Sr25519Keyring::Charlie, - keyring::Sr25519Keyring::Dave, - keyring::Sr25519Keyring::Eve, - keyring::Sr25519Keyring::Ferdie, - keyring::Sr25519Keyring::One, - keyring::Sr25519Keyring::Two, - keyring::Sr25519Keyring::AliceStash, + sp_keyring::Sr25519Keyring::Alice, + sp_keyring::Sr25519Keyring::Bob, + sp_keyring::Sr25519Keyring::Charlie, + sp_keyring::Sr25519Keyring::Dave, + sp_keyring::Sr25519Keyring::Eve, + sp_keyring::Sr25519Keyring::Ferdie, + sp_keyring::Sr25519Keyring::One, + sp_keyring::Sr25519Keyring::Two, + sp_keyring::Sr25519Keyring::AliceStash, ]; for validator in validators.iter() { Keystore::sr25519_generate_new( diff --git a/polkadot/runtime/parachains/src/paras_inherent/weights.rs b/polkadot/runtime/parachains/src/paras_inherent/weights.rs index 0f4e5be572a6..37809396a823 100644 --- a/polkadot/runtime/parachains/src/paras_inherent/weights.rs +++ b/polkadot/runtime/parachains/src/paras_inherent/weights.rs @@ -19,8 +19,8 @@ //! the relay chain, but we do care about the size of the block, by putting the tx in the //! proof_size we can use the already existing weight limiting code to limit the used size as well. -use parity_scale_codec::{Encode, WrapperTypeEncode}; -use primitives::{ +use codec::{Encode, WrapperTypeEncode}; +use polkadot_primitives::{ CheckedMultiDisputeStatementSet, MultiDisputeStatementSet, UncheckedSignedAvailabilityBitfield, UncheckedSignedAvailabilityBitfields, }; diff --git a/polkadot/runtime/parachains/src/reward_points.rs b/polkadot/runtime/parachains/src/reward_points.rs index 3be743a2c551..5f45445b0ba2 100644 --- a/polkadot/runtime/parachains/src/reward_points.rs +++ b/polkadot/runtime/parachains/src/reward_points.rs @@ -23,7 +23,7 @@ use crate::{session_info, shared}; use frame_support::traits::{Defensive, ValidatorSet}; -use primitives::{SessionIndex, ValidatorIndex}; +use polkadot_primitives::{SessionIndex, ValidatorIndex}; use sp_std::collections::btree_set::BTreeSet; /// The amount of era points given by backing a candidate that is included. diff --git a/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs b/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs index 3dca38050a0a..dbb79b86c56c 100644 --- a/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs +++ b/polkadot/runtime/parachains/src/runtime_api_impl/v10.rs @@ -24,7 +24,7 @@ use crate::{ }; use frame_support::traits::{GetStorageVersion, StorageVersion}; use frame_system::pallet_prelude::*; -use primitives::{ +use polkadot_primitives::{ async_backing::{ AsyncBackingParams, BackingState, CandidatePendingAvailability, Constraints, InboundHrmpLimitations, OutboundHrmpChannelLimitations, @@ -149,7 +149,10 @@ pub fn availability_cores() -> Vec { if let Some(para_id) = scheduled.get(&CoreIndex(i as _)).cloned() { - CoreState::Scheduled(primitives::ScheduledCore { para_id, collator: None }) + CoreState::Scheduled(polkadot_primitives::ScheduledCore { + para_id, + collator: None, + }) } else { CoreState::Free } @@ -161,7 +164,7 @@ pub fn availability_cores() -> Vec( ) -> (BlockNumberFor, ::Hash) { - use parity_scale_codec::Decode as _; + use codec::Decode as _; let state_version = frame_system::Pallet::::runtime_version().state_version(); let relay_parent_number = frame_system::Pallet::::block_number(); let relay_parent_storage_root = T::Hash::decode(&mut &sp_io::storage::root(state_version)[..]) @@ -241,7 +244,7 @@ pub fn assumed_validation_data( /// Implementation for the `check_validation_outputs` function of the runtime API. pub fn check_validation_outputs( para_id: ParaId, - outputs: primitives::CandidateCommitments, + outputs: polkadot_primitives::CandidateCommitments, ) -> bool { let relay_parent_number = frame_system::Pallet::::block_number(); inclusion::Pallet::::check_validation_outputs_for_runtime_api( diff --git a/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs b/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs index 32bbdca84a3c..8c239dc207f6 100644 --- a/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs +++ b/polkadot/runtime/parachains/src/runtime_api_impl/vstaging.rs @@ -17,7 +17,7 @@ //! Put implementations of functions from staging APIs here. use crate::{inclusion, initializer, scheduler}; -use primitives::{CommittedCandidateReceipt, CoreIndex, Id as ParaId}; +use polkadot_primitives::{CommittedCandidateReceipt, CoreIndex, Id as ParaId}; use sp_runtime::traits::One; use sp_std::{ collections::{btree_map::BTreeMap, vec_deque::VecDeque}, diff --git a/polkadot/runtime/parachains/src/scheduler.rs b/polkadot/runtime/parachains/src/scheduler.rs index baeec49839df..0442301a32ff 100644 --- a/polkadot/runtime/parachains/src/scheduler.rs +++ b/polkadot/runtime/parachains/src/scheduler.rs @@ -40,7 +40,7 @@ use crate::{configuration, initializer::SessionChangeNotification, paras}; use frame_support::{pallet_prelude::*, traits::Defensive}; use frame_system::pallet_prelude::BlockNumberFor; pub use polkadot_core_primitives::v2::BlockNumber; -use primitives::{ +use polkadot_primitives::{ CoreIndex, GroupIndex, GroupRotationInfo, Id as ParaId, ScheduledCore, ValidatorIndex, }; use sp_runtime::traits::One; diff --git a/polkadot/runtime/parachains/src/scheduler/common.rs b/polkadot/runtime/parachains/src/scheduler/common.rs index 66a4e6d30be0..114cd4b940bc 100644 --- a/polkadot/runtime/parachains/src/scheduler/common.rs +++ b/polkadot/runtime/parachains/src/scheduler/common.rs @@ -22,7 +22,7 @@ use sp_runtime::{ RuntimeDebug, }; -use primitives::{CoreIndex, Id as ParaId}; +use polkadot_primitives::{CoreIndex, Id as ParaId}; /// Assignment (ParaId -> CoreIndex). #[derive(Encode, Decode, TypeInfo, RuntimeDebug, Clone, PartialEq)] diff --git a/polkadot/runtime/parachains/src/scheduler/migration.rs b/polkadot/runtime/parachains/src/scheduler/migration.rs index 5482c8821e58..57f4fd670fbe 100644 --- a/polkadot/runtime/parachains/src/scheduler/migration.rs +++ b/polkadot/runtime/parachains/src/scheduler/migration.rs @@ -34,7 +34,7 @@ struct V0Assignment { /// Old scheduler with explicit parathreads and `Scheduled` storage instead of `ClaimQueue`. mod v0 { use super::*; - use primitives::{CollatorId, Id}; + use polkadot_primitives::{CollatorId, Id}; #[storage_alias] pub(super) type Scheduled = StorageValue, Vec, ValueQuery>; diff --git a/polkadot/runtime/parachains/src/scheduler/tests.rs b/polkadot/runtime/parachains/src/scheduler/tests.rs index 200f49ff2e82..74ad8adf00c4 100644 --- a/polkadot/runtime/parachains/src/scheduler/tests.rs +++ b/polkadot/runtime/parachains/src/scheduler/tests.rs @@ -17,10 +17,10 @@ use super::*; use frame_support::assert_ok; -use keyring::Sr25519Keyring; -use primitives::{ +use polkadot_primitives::{ vstaging::SchedulerParams, BlockNumber, SessionIndex, ValidationCode, ValidatorId, }; +use sp_keyring::Sr25519Keyring; use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use crate::{ diff --git a/polkadot/runtime/parachains/src/session_info.rs b/polkadot/runtime/parachains/src/session_info.rs index 2f7f1ead76ad..ff032f7e34d5 100644 --- a/polkadot/runtime/parachains/src/session_info.rs +++ b/polkadot/runtime/parachains/src/session_info.rs @@ -29,7 +29,9 @@ use frame_support::{ traits::{OneSessionHandler, ValidatorSet, ValidatorSetWithIdentification}, }; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{AssignmentId, AuthorityDiscoveryId, ExecutorParams, SessionIndex, SessionInfo}; +use polkadot_primitives::{ + AssignmentId, AuthorityDiscoveryId, ExecutorParams, SessionIndex, SessionInfo, +}; use sp_std::vec::Vec; pub use pallet::*; diff --git a/polkadot/runtime/parachains/src/session_info/tests.rs b/polkadot/runtime/parachains/src/session_info/tests.rs index 18b9d8f59010..3e81ca498713 100644 --- a/polkadot/runtime/parachains/src/session_info/tests.rs +++ b/polkadot/runtime/parachains/src/session_info/tests.rs @@ -24,8 +24,8 @@ use crate::{ }, util::take_active_subset, }; -use keyring::Sr25519Keyring; -use primitives::{vstaging::SchedulerParams, BlockNumber, ValidatorId, ValidatorIndex}; +use polkadot_primitives::{vstaging::SchedulerParams, BlockNumber, ValidatorId, ValidatorIndex}; +use sp_keyring::Sr25519Keyring; fn run_to_block( to: BlockNumber, diff --git a/polkadot/runtime/parachains/src/shared.rs b/polkadot/runtime/parachains/src/shared.rs index 319b22515889..417de1fa3fb0 100644 --- a/polkadot/runtime/parachains/src/shared.rs +++ b/polkadot/runtime/parachains/src/shared.rs @@ -21,7 +21,7 @@ use frame_support::{pallet_prelude::*, traits::DisabledValidators}; use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{SessionIndex, ValidatorId, ValidatorIndex}; +use polkadot_primitives::{SessionIndex, ValidatorId, ValidatorIndex}; use sp_runtime::traits::AtLeast32BitUnsigned; use sp_std::{ collections::{btree_map::BTreeMap, vec_deque::VecDeque}, diff --git a/polkadot/runtime/parachains/src/shared/tests.rs b/polkadot/runtime/parachains/src/shared/tests.rs index 4ae37463a6d9..e47d1fd9cfe0 100644 --- a/polkadot/runtime/parachains/src/shared/tests.rs +++ b/polkadot/runtime/parachains/src/shared/tests.rs @@ -21,9 +21,9 @@ use crate::{ shared, }; use assert_matches::assert_matches; -use keyring::Sr25519Keyring; -use primitives::Hash; -use test_helpers::validator_pubkeys; +use polkadot_primitives::Hash; +use polkadot_primitives_test_helpers::validator_pubkeys; +use sp_keyring::Sr25519Keyring; #[test] fn tracker_earliest_block_number() { diff --git a/polkadot/runtime/parachains/src/ump_tests.rs b/polkadot/runtime/parachains/src/ump_tests.rs index 43829974b569..4d6da8c9e3c1 100644 --- a/polkadot/runtime/parachains/src/ump_tests.rs +++ b/polkadot/runtime/parachains/src/ump_tests.rs @@ -31,7 +31,7 @@ use frame_support::{ traits::{EnqueueMessage, ExecuteOverweightError, ServiceQueues}, weights::Weight, }; -use primitives::{well_known_keys, Id as ParaId, UpwardMessage}; +use polkadot_primitives::{well_known_keys, Id as ParaId, UpwardMessage}; use sp_crypto_hashing::{blake2_256, twox_64}; use sp_runtime::traits::Bounded; use sp_std::prelude::*; @@ -426,7 +426,7 @@ fn relay_dispatch_queue_size_key_is_correct() { // A "random" para id. let para: ParaId = u32::from_ne_bytes(twox_64(&i.encode())[..4].try_into().unwrap()).into(); - let well_known = primitives::well_known_keys::relay_dispatch_queue_size(para); + let well_known = polkadot_primitives::well_known_keys::relay_dispatch_queue_size(para); let aliased = RelayDispatchQueueSize::hashed_key_for(para); assert_eq!(well_known, aliased, "Old and new key must match"); diff --git a/polkadot/runtime/parachains/src/util.rs b/polkadot/runtime/parachains/src/util.rs index 5aa2d58da3c9..cb2deffd7f65 100644 --- a/polkadot/runtime/parachains/src/util.rs +++ b/polkadot/runtime/parachains/src/util.rs @@ -18,7 +18,7 @@ //! on all modules. use frame_system::pallet_prelude::BlockNumberFor; -use primitives::{HeadData, Id as ParaId, PersistedValidationData, ValidatorIndex}; +use polkadot_primitives::{HeadData, Id as ParaId, PersistedValidationData, ValidatorIndex}; use sp_std::{collections::btree_set::BTreeSet, vec::Vec}; use crate::{configuration, hrmp, paras}; @@ -121,7 +121,7 @@ mod tests { use sp_std::vec::Vec; use crate::util::{split_active_subset, take_active_subset}; - use primitives::ValidatorIndex; + use polkadot_primitives::ValidatorIndex; #[test] fn take_active_subset_is_compatible_with_split_active_subset() { diff --git a/polkadot/runtime/rococo/Cargo.toml b/polkadot/runtime/rococo/Cargo.toml index c78f3e668b9c..d342926d3c5a 100644 --- a/polkadot/runtime/rococo/Cargo.toml +++ b/polkadot/runtime/rococo/Cargo.toml @@ -11,7 +11,7 @@ license.workspace = true workspace = true [dependencies] -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } log = { workspace = true } serde = { workspace = true } @@ -21,16 +21,16 @@ static_assertions = "1.1.0" smallvec = "1.8.0" bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] } -authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../substrate/primitives/authority-discovery", default-features = false } -babe-primitives = { package = "sp-consensus-babe", path = "../../../substrate/primitives/consensus/babe", default-features = false } -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../substrate/primitives/consensus/beefy", default-features = false } -grandpa_primitives = { package = "sp-consensus-grandpa", path = "../../../substrate/primitives/consensus/grandpa", default-features = false } +sp-authority-discovery = { path = "../../../substrate/primitives/authority-discovery", default-features = false } +sp-consensus-babe = { path = "../../../substrate/primitives/consensus/babe", default-features = false } +sp-consensus-beefy = { path = "../../../substrate/primitives/consensus/beefy", default-features = false } +sp-consensus-grandpa = { path = "../../../substrate/primitives/consensus/grandpa", default-features = false } binary-merkle-tree = { path = "../../../substrate/utils/binary-merkle-tree", default-features = false } rococo-runtime-constants = { package = "rococo-runtime-constants", path = "constants", default-features = false } sp-api = { path = "../../../substrate/primitives/api", default-features = false } sp-genesis-builder = { path = "../../../substrate/primitives/genesis-builder", default-features = false } -inherents = { package = "sp-inherents", path = "../../../substrate/primitives/inherents", default-features = false } -offchain-primitives = { package = "sp-offchain", path = "../../../substrate/primitives/offchain", default-features = false } +sp-inherents = { path = "../../../substrate/primitives/inherents", default-features = false } +sp-offchain = { path = "../../../substrate/primitives/offchain", default-features = false } sp-arithmetic = { path = "../../../substrate/primitives/arithmetic", default-features = false } sp-std = { package = "sp-std", path = "../../../substrate/primitives/std", default-features = false } sp-io = { path = "../../../substrate/primitives/io", default-features = false } @@ -41,8 +41,8 @@ sp-core = { path = "../../../substrate/primitives/core", default-features = fals sp-session = { path = "../../../substrate/primitives/session", default-features = false } sp-storage = { path = "../../../substrate/primitives/storage", default-features = false } sp-version = { path = "../../../substrate/primitives/version", default-features = false } -tx-pool-api = { package = "sp-transaction-pool", path = "../../../substrate/primitives/transaction-pool", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../substrate/primitives/block-builder", default-features = false } +sp-transaction-pool = { path = "../../../substrate/primitives/transaction-pool", default-features = false } +sp-block-builder = { path = "../../../substrate/primitives/block-builder", default-features = false } pallet-authority-discovery = { path = "../../../substrate/frame/authority-discovery", default-features = false } pallet-authorship = { path = "../../../substrate/frame/authorship", default-features = false } @@ -100,9 +100,9 @@ frame-try-runtime = { path = "../../../substrate/frame/try-runtime", default-fea frame-system-benchmarking = { path = "../../../substrate/frame/system/benchmarking", default-features = false, optional = true } hex-literal = { version = "0.4.1" } -runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } -runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } +polkadot-runtime-common = { path = "../common", default-features = false } +polkadot-runtime-parachains = { path = "../parachains", default-features = false } +polkadot-primitives = { path = "../../primitives", default-features = false } polkadot-parachain-primitives = { path = "../../parachain", default-features = false } xcm = { package = "staging-xcm", path = "../../xcm", default-features = false } @@ -112,7 +112,7 @@ xcm-fee-payment-runtime-api = { path = "../../xcm/xcm-fee-payment-runtime-api", [dev-dependencies] tiny-keccak = { version = "2.0.2", features = ["keccak"] } -keyring = { package = "sp-keyring", path = "../../../substrate/primitives/keyring" } +sp-keyring = { path = "../../../substrate/primitives/keyring" } remote-externalities = { package = "frame-remote-externalities", path = "../../../substrate/utils/frame/remote-externalities" } sp-trie = { path = "../../../substrate/primitives/trie" } separator = "0.4.1" @@ -127,12 +127,9 @@ substrate-wasm-builder = { path = "../../../substrate/utils/wasm-builder", optio default = ["std"] no_std = [] std = [ - "authority-discovery-primitives/std", - "babe-primitives/std", - "beefy-primitives/std", "binary-merkle-tree/std", "bitvec/std", - "block-builder-api/std", + "codec/std", "frame-benchmarking?/std", "frame-executive/std", "frame-metadata-hash-extension/std", @@ -141,10 +138,7 @@ std = [ "frame-system-rpc-runtime-api/std", "frame-system/std", "frame-try-runtime/std", - "grandpa_primitives/std", - "inherents/std", "log/std", - "offchain-primitives/std", "pallet-asset-rate/std", "pallet-authority-discovery/std", "pallet-authorship/std", @@ -190,31 +184,37 @@ std = [ "pallet-whitelist/std", "pallet-xcm-benchmarks?/std", "pallet-xcm/std", - "parity-scale-codec/std", "polkadot-parachain-primitives/std", - "primitives/std", + "polkadot-primitives/std", + "polkadot-runtime-common/std", + "polkadot-runtime-parachains/std", "rococo-runtime-constants/std", - "runtime-common/std", - "runtime-parachains/std", "scale-info/std", "serde/std", "serde_derive", "serde_json/std", "sp-api/std", "sp-arithmetic/std", + "sp-authority-discovery/std", + "sp-block-builder/std", + "sp-consensus-babe/std", + "sp-consensus-beefy/std", + "sp-consensus-grandpa/std", "sp-core/std", "sp-genesis-builder/std", + "sp-inherents/std", "sp-io/std", "sp-mmr-primitives/std", + "sp-offchain/std", "sp-runtime/std", "sp-session/std", "sp-staking/std", "sp-std/std", "sp-storage/std", "sp-tracing/std", + "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", - "tx-pool-api/std", "xcm-builder/std", "xcm-executor/std", "xcm-fee-payment-runtime-api/std", @@ -263,9 +263,9 @@ runtime-benchmarks = [ "pallet-xcm-benchmarks/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", - "primitives/runtime-benchmarks", - "runtime-common/runtime-benchmarks", - "runtime-parachains/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -321,8 +321,8 @@ try-runtime = [ "pallet-vesting/try-runtime", "pallet-whitelist/try-runtime", "pallet-xcm/try-runtime", - "runtime-common/try-runtime", - "runtime-parachains/try-runtime", + "polkadot-runtime-common/try-runtime", + "polkadot-runtime-parachains/try-runtime", "sp-runtime/try-runtime", ] @@ -332,7 +332,7 @@ metadata-hash = ["substrate-wasm-builder/metadata-hash"] # Set timing constants (e.g. session period) to faster versions to speed up testing. fast-runtime = ["rococo-runtime-constants/fast-runtime"] -runtime-metrics = ["runtime-parachains/runtime-metrics", "sp-io/with-tracing"] +runtime-metrics = ["polkadot-runtime-parachains/runtime-metrics", "sp-io/with-tracing"] # A feature that should be enabled when the runtime should be built for on-chain # deployment. This will disable stuff that shouldn't be part of the on-chain wasm diff --git a/polkadot/runtime/rococo/constants/Cargo.toml b/polkadot/runtime/rococo/constants/Cargo.toml index 3ca3877a7650..2c49488077e6 100644 --- a/polkadot/runtime/rococo/constants/Cargo.toml +++ b/polkadot/runtime/rococo/constants/Cargo.toml @@ -13,8 +13,8 @@ workspace = true smallvec = "1.8.0" frame-support = { path = "../../../../substrate/frame/support", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } -runtime-common = { package = "polkadot-runtime-common", path = "../../common", default-features = false } +polkadot-primitives = { path = "../../../primitives", default-features = false } +polkadot-runtime-common = { path = "../../common", default-features = false } sp-runtime = { path = "../../../../substrate/primitives/runtime", default-features = false } sp-weights = { path = "../../../../substrate/primitives/weights", default-features = false } sp-core = { path = "../../../../substrate/primitives/core", default-features = false } @@ -26,8 +26,8 @@ xcm-builder = { package = "staging-xcm-builder", path = "../../../xcm/xcm-builde default = ["std"] std = [ "frame-support/std", - "primitives/std", - "runtime-common/std", + "polkadot-primitives/std", + "polkadot-runtime-common/std", "sp-core/std", "sp-runtime/std", "sp-weights/std", diff --git a/polkadot/runtime/rococo/constants/src/lib.rs b/polkadot/runtime/rococo/constants/src/lib.rs index 89d5deb86f1a..1dcafdcbc4d9 100644 --- a/polkadot/runtime/rococo/constants/src/lib.rs +++ b/polkadot/runtime/rococo/constants/src/lib.rs @@ -20,7 +20,7 @@ pub mod weights; /// Money matters. pub mod currency { - use primitives::Balance; + use polkadot_primitives::Balance; /// The existential deposit. pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS; @@ -37,9 +37,9 @@ pub mod currency { /// Time and blocks. pub mod time { - use runtime_common::prod_or_fast; + use polkadot_runtime_common::prod_or_fast; - use primitives::{BlockNumber, Moment}; + use polkadot_primitives::{BlockNumber, Moment}; pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -67,7 +67,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::Balance; + use polkadot_primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; @@ -103,7 +103,7 @@ pub mod fee { /// System Parachains. pub mod system_parachain { - use primitives::Id; + use polkadot_primitives::Id; use xcm_builder::IsChildSystemParachain; /// Network's Asset Hub parachain ID. @@ -134,7 +134,7 @@ mod tests { }; use crate::weights::ExtrinsicBaseWeight; use frame_support::weights::WeightToFee as WeightToFeeT; - use runtime_common::MAXIMUM_BLOCK_WEIGHT; + use polkadot_runtime_common::MAXIMUM_BLOCK_WEIGHT; #[test] // Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds. diff --git a/polkadot/runtime/rococo/src/genesis_config_presets.rs b/polkadot/runtime/rococo/src/genesis_config_presets.rs index bac6902383e3..1c70c94ce048 100644 --- a/polkadot/runtime/rococo/src/genesis_config_presets.rs +++ b/polkadot/runtime/rococo/src/genesis_config_presets.rs @@ -17,12 +17,14 @@ //! Genesis configs presets for the Rococo runtime use crate::{SessionKeys, BABE_GENESIS_EPOCH_CONFIG}; -use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; -use babe_primitives::AuthorityId as BabeId; -use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId; -use grandpa_primitives::AuthorityId as GrandpaId; -use primitives::{vstaging::SchedulerParams, AccountId, AccountPublic, AssignmentId, ValidatorId}; +use polkadot_primitives::{ + vstaging::SchedulerParams, AccountId, AccountPublic, AssignmentId, ValidatorId, +}; use rococo_runtime_constants::currency::UNITS as ROC; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId; +use sp_consensus_grandpa::AuthorityId as GrandpaId; use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::IdentifyAccount; #[cfg(not(feature = "std"))] @@ -105,12 +107,13 @@ fn rococo_session_keys( } fn default_parachains_host_configuration( -) -> runtime_parachains::configuration::HostConfiguration { - use primitives::{ +) -> polkadot_runtime_parachains::configuration::HostConfiguration +{ + use polkadot_primitives::{ node_features::FeatureIndex, AsyncBackingParams, MAX_CODE_SIZE, MAX_POV_SIZE, }; - runtime_parachains::configuration::HostConfiguration { + polkadot_runtime_parachains::configuration::HostConfiguration { validation_upgrade_cooldown: 2u32, validation_upgrade_delay: 2, code_retention_period: 1200, @@ -205,7 +208,7 @@ fn rococo_testnet_genesis( }, "sudo": { "key": Some(root_key.clone()) }, "configuration": { - "config": runtime_parachains::configuration::HostConfiguration { + "config": polkadot_runtime_parachains::configuration::HostConfiguration { scheduler_params: SchedulerParams { max_validators_per_core: Some(1), ..default_parachains_host_configuration().scheduler_params @@ -214,7 +217,7 @@ fn rococo_testnet_genesis( }, }, "registrar": { - "nextFreeParaId": primitives::LOWEST_PUBLIC_ID, + "nextFreeParaId": polkadot_primitives::LOWEST_PUBLIC_ID, } }) } @@ -473,7 +476,7 @@ fn rococo_staging_testnet_config_genesis() -> serde_json::Value { "config": default_parachains_host_configuration(), }, "registrar": { - "nextFreeParaId": primitives::LOWEST_PUBLIC_ID, + "nextFreeParaId": polkadot_primitives::LOWEST_PUBLIC_ID, }, }) } diff --git a/polkadot/runtime/rococo/src/impls.rs b/polkadot/runtime/rococo/src/impls.rs index ac7100d78583..7b5c7b1fb4ac 100644 --- a/polkadot/runtime/rococo/src/impls.rs +++ b/polkadot/runtime/rococo/src/impls.rs @@ -15,12 +15,12 @@ // along with Polkadot. If not, see . use crate::xcm_config; +use codec::{Decode, Encode}; use frame_support::pallet_prelude::DispatchResult; use frame_system::RawOrigin; -use parity_scale_codec::{Decode, Encode}; -use primitives::Balance; +use polkadot_primitives::Balance; +use polkadot_runtime_common::identity_migrator::{OnReapIdentity, WeightInfo}; use rococo_runtime_constants::currency::*; -use runtime_common::identity_migrator::{OnReapIdentity, WeightInfo}; use sp_std::{marker::PhantomData, prelude::*}; use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm}; use xcm_executor::traits::TransactAsset; diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index a77c0188a1da..91ca5eb5e31d 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -20,18 +20,13 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit. #![recursion_limit = "512"] -use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; -use beefy_primitives::{ - ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}, - mmr::{BeefyDataProvider, MmrLeafVersion}, -}; +use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ dynamic_params::{dynamic_pallet_params, dynamic_params}, traits::FromContains, }; use pallet_nis::WithMaximumOf; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::{ +use polkadot_primitives::{ slashing, AccountId, AccountIndex, ApprovalVotingParams, Balance, BlockNumber, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, @@ -39,8 +34,7 @@ use primitives::{ SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, PARACHAIN_KEY_TYPE_ID, }; -use rococo_runtime_constants::system_parachain::BROKER_ID; -use runtime_common::{ +use polkadot_runtime_common::{ assigned_slots, auctions, claims, crowdloan, identity_migrator, impl_runtime_weights, impls::{ ContainsParts, LocatableAssetConverter, ToAuthor, VersionedLocatableAsset, @@ -50,7 +44,7 @@ use runtime_common::{ traits::{Leaser, OnSwap}, BlockHashCount, BlockLength, SlowAdjustingFeeUpdate, }; -use runtime_parachains::{ +use polkadot_runtime_parachains::{ assigner_coretime as parachains_assigner_coretime, assigner_on_demand as parachains_assigner_on_demand, configuration as parachains_configuration, configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio, @@ -66,7 +60,13 @@ use runtime_parachains::{ scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, }; +use rococo_runtime_constants::system_parachain::BROKER_ID; use scale_info::TypeInfo; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_beefy::{ + ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}, + mmr::{BeefyDataProvider, MmrLeafVersion}, +}; use sp_genesis_builder::PresetId; use sp_std::{ cmp::Ordering, @@ -170,10 +170,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { }; /// The BABE epoch configuration at genesis. -pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration = - babe_primitives::BabeEpochConfiguration { +pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = + sp_consensus_babe::BabeEpochConfiguration { c: PRIMARY_PROBABILITY, - allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots, + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots, }; /// Native version. @@ -539,7 +539,7 @@ impl pallet_treasury::Config for Runtime { >; type PayoutPeriod = PayoutSpendPeriod; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = runtime_common::impls::benchmarks::TreasuryArguments; + type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments; } parameter_types! { @@ -956,7 +956,7 @@ impl parachains_session_info::Config for Runtime { /// Special `RewardValidators` that does nothing ;) pub struct RewardValidators; -impl runtime_parachains::inclusion::RewardValidators for RewardValidators { +impl polkadot_runtime_parachains::inclusion::RewardValidators for RewardValidators { fn reward_backing(_: impl IntoIterator) {} fn reward_bitfields(_: impl IntoIterator) {} } @@ -1364,7 +1364,7 @@ impl pallet_asset_rate::Config for Runtime { type Currency = Balances; type AssetKind = ::AssetKind; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = runtime_common::impls::benchmarks::AssetRateArguments; + type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments; } // Notify `coretime` pallet when a lease swap occurs @@ -1701,22 +1701,22 @@ mod benches { // Polkadot // NOTE: Make sure to prefix these with `runtime_common::` so // the that path resolves correctly in the generated file. - [runtime_common::assigned_slots, AssignedSlots] - [runtime_common::auctions, Auctions] - [runtime_common::coretime, Coretime] - [runtime_common::crowdloan, Crowdloan] - [runtime_common::claims, Claims] - [runtime_common::identity_migrator, IdentityMigrator] - [runtime_common::slots, Slots] - [runtime_common::paras_registrar, Registrar] - [runtime_parachains::configuration, Configuration] - [runtime_parachains::hrmp, Hrmp] - [runtime_parachains::disputes, ParasDisputes] - [runtime_parachains::inclusion, ParaInclusion] - [runtime_parachains::initializer, Initializer] - [runtime_parachains::paras_inherent, ParaInherent] - [runtime_parachains::paras, Paras] - [runtime_parachains::assigner_on_demand, OnDemandAssignmentProvider] + [polkadot_runtime_common::assigned_slots, AssignedSlots] + [polkadot_runtime_common::auctions, Auctions] + [polkadot_runtime_common::coretime, Coretime] + [polkadot_runtime_common::crowdloan, Crowdloan] + [polkadot_runtime_common::claims, Claims] + [polkadot_runtime_common::identity_migrator, IdentityMigrator] + [polkadot_runtime_common::slots, Slots] + [polkadot_runtime_common::paras_registrar, Registrar] + [polkadot_runtime_parachains::configuration, Configuration] + [polkadot_runtime_parachains::hrmp, Hrmp] + [polkadot_runtime_parachains::disputes, ParasDisputes] + [polkadot_runtime_parachains::inclusion, ParaInclusion] + [polkadot_runtime_parachains::initializer, Initializer] + [polkadot_runtime_parachains::paras_inherent, ParaInherent] + [polkadot_runtime_parachains::paras, Paras] + [polkadot_runtime_parachains::assigner_on_demand, OnDemandAssignmentProvider] // Substrate [pallet_balances, Balances] [pallet_balances, NisCounterpartBalances] @@ -1823,7 +1823,7 @@ sp_api::impl_runtime_apis! { } } - impl block_builder_api::BlockBuilder for Runtime { + impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } @@ -1832,19 +1832,19 @@ sp_api::impl_runtime_apis! { Executive::finalize_block() } - fn inherent_extrinsics(data: inherents::InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } fn check_inherents( block: Block, - data: inherents::InherentData, - ) -> inherents::CheckInherentsResult { + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) } } - impl tx_pool_api::runtime_api::TaggedTransactionQueue for Runtime { + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, @@ -1854,14 +1854,14 @@ sp_api::impl_runtime_apis! { } } - impl offchain_primitives::OffchainWorkerApi for Runtime { + impl sp_offchain::OffchainWorkerApi for Runtime { fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } #[api_version(11)] - impl primitives::runtime_api::ParachainHost for Runtime { + impl polkadot_primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() } @@ -1891,7 +1891,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::CandidateCommitments, + outputs: polkadot_primitives::CandidateCommitments, ) -> bool { parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) } @@ -1948,8 +1948,8 @@ sp_api::impl_runtime_apis! { } fn submit_pvf_check_statement( - stmt: primitives::PvfCheckStatement, - signature: primitives::ValidatorSignature + stmt: polkadot_primitives::PvfCheckStatement, + signature: polkadot_primitives::ValidatorSignature ) { parachains_runtime_api_impl::submit_pvf_check_statement::(stmt, signature) } @@ -1976,7 +1976,7 @@ sp_api::impl_runtime_apis! { fn key_ownership_proof( validator_id: ValidatorId, ) -> Option { - use parity_scale_codec::Encode; + use codec::Encode; Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id)) .map(|p| p.encode()) @@ -1997,11 +1997,11 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::minimum_backing_votes::() } - fn para_backing_state(para_id: ParaId) -> Option { + fn para_backing_state(para_id: ParaId) -> Option { parachains_runtime_api_impl::backing_state::(para_id) } - fn async_backing_params() -> primitives::AsyncBackingParams { + fn async_backing_params() -> polkadot_primitives::AsyncBackingParams { parachains_runtime_api_impl::async_backing_params::() } @@ -2027,22 +2027,22 @@ sp_api::impl_runtime_apis! { } #[api_version(3)] - impl beefy_primitives::BeefyApi for Runtime { + impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() } - fn validator_set() -> Option> { + fn validator_set() -> Option> { Beefy::validator_set() } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: beefy_primitives::DoubleVotingProof< + equivocation_proof: sp_consensus_beefy::DoubleVotingProof< BlockNumber, BeefyId, BeefySignature, >, - key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; @@ -2053,14 +2053,14 @@ sp_api::impl_runtime_apis! { } fn generate_key_ownership_proof( - _set_id: beefy_primitives::ValidatorSetId, + _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, - ) -> Option { - use parity_scale_codec::Encode; + ) -> Option { + use codec::Encode; - Historical::prove((beefy_primitives::KEY_TYPE, authority_id)) + Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id)) .map(|p| p.encode()) - .map(beefy_primitives::OpaqueKeyOwnershipProof::new) + .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } } @@ -2139,7 +2139,7 @@ sp_api::impl_runtime_apis! { _set_id: fg_primitives::SetId, authority_id: fg_primitives::AuthorityId, ) -> Option { - use parity_scale_codec::Encode; + use codec::Encode; Historical::prove((fg_primitives::KEY_TYPE, authority_id)) .map(|p| p.encode()) @@ -2147,10 +2147,10 @@ sp_api::impl_runtime_apis! { } } - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeConfiguration { let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); - babe_primitives::BabeConfiguration { + sp_consensus_babe::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDurationInBlocks::get().into(), c: epoch_config.c, @@ -2160,32 +2160,32 @@ sp_api::impl_runtime_apis! { } } - fn current_epoch_start() -> babe_primitives::Slot { + fn current_epoch_start() -> sp_consensus_babe::Slot { Babe::current_epoch_start() } - fn current_epoch() -> babe_primitives::Epoch { + fn current_epoch() -> sp_consensus_babe::Epoch { Babe::current_epoch() } - fn next_epoch() -> babe_primitives::Epoch { + fn next_epoch() -> sp_consensus_babe::Epoch { Babe::next_epoch() } fn generate_key_ownership_proof( - _slot: babe_primitives::Slot, - authority_id: babe_primitives::AuthorityId, - ) -> Option { - use parity_scale_codec::Encode; + _slot: sp_consensus_babe::Slot, + authority_id: sp_consensus_babe::AuthorityId, + ) -> Option { + use codec::Encode; - Historical::prove((babe_primitives::KEY_TYPE, authority_id)) + Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) .map(|p| p.encode()) - .map(babe_primitives::OpaqueKeyOwnershipProof::new) + .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: babe_primitives::EquivocationProof<::Header>, - key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, + equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, + key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; @@ -2196,7 +2196,7 @@ sp_api::impl_runtime_apis! { } } - impl authority_discovery_primitives::AuthorityDiscoveryApi for Runtime { + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { fn authorities() -> Vec { parachains_runtime_api_impl::relevant_authority_ids::() } @@ -2239,11 +2239,11 @@ sp_api::impl_runtime_apis! { } impl pallet_beefy_mmr::BeefyMmrApi for RuntimeApi { - fn authority_set_proof() -> beefy_primitives::mmr::BeefyAuthoritySet { + fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet { MmrLeaf::authority_set_proof() } - fn next_authority_set_proof() -> beefy_primitives::mmr::BeefyNextAuthoritySet { + fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet { MmrLeaf::next_authority_set_proof() } } @@ -2319,14 +2319,14 @@ sp_api::impl_runtime_apis! { impl frame_benchmarking::baseline::Config for Runtime {} impl pallet_xcm::benchmarking::Config for Runtime { type DeliveryHelper = ( - runtime_common::xcm_sender::ToParachainDeliveryHelper< + polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, AssetHubParaId, (), >, - runtime_common::xcm_sender::ToParachainDeliveryHelper< + polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, @@ -2385,7 +2385,7 @@ sp_api::impl_runtime_apis! { impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = XcmConfig; type AccountIdConverter = LocationConverter; - type DeliveryHelper = runtime_common::xcm_sender::ToParachainDeliveryHelper< + type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, diff --git a/polkadot/runtime/rococo/src/weights/runtime_common_assigned_slots.rs b/polkadot/runtime/rococo/src/weights/runtime_common_assigned_slots.rs index a6beeded4286..2aaf282c59d5 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_common_assigned_slots.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_common_assigned_slots.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::assigned_slots`. pub struct WeightInfo(PhantomData); -impl runtime_common::assigned_slots::WeightInfo for WeightInfo { +impl polkadot_runtime_common::assigned_slots::WeightInfo for WeightInfo { /// Storage: `Registrar::Paras` (r:1 w:1) /// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Paras::ParaLifecycles` (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_common_auctions.rs b/polkadot/runtime/rococo/src/weights/runtime_common_auctions.rs index 3cd7c7a47e90..897dc1c1752a 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_common_auctions.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_common_auctions.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::auctions`. pub struct WeightInfo(PhantomData); -impl runtime_common::auctions::WeightInfo for WeightInfo { +impl polkadot_runtime_common::auctions::WeightInfo for WeightInfo { /// Storage: Auctions AuctionInfo (r:1 w:1) /// Proof: Auctions AuctionInfo (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) /// Storage: Auctions AuctionCounter (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_common_claims.rs b/polkadot/runtime/rococo/src/weights/runtime_common_claims.rs index 52e0dd24afa0..8fbc798dbd46 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_common_claims.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_common_claims.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::claims`. pub struct WeightInfo(PhantomData); -impl runtime_common::claims::WeightInfo for WeightInfo { +impl polkadot_runtime_common::claims::WeightInfo for WeightInfo { /// Storage: Claims Claims (r:1 w:1) /// Proof Skipped: Claims Claims (max_values: None, max_size: None, mode: Measured) /// Storage: Claims Signing (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_common_crowdloan.rs b/polkadot/runtime/rococo/src/weights/runtime_common_crowdloan.rs index 0e7420cba2e6..b75ff8d42e7e 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_common_crowdloan.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_common_crowdloan.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::crowdloan`. pub struct WeightInfo(PhantomData); -impl runtime_common::crowdloan::WeightInfo for WeightInfo { +impl polkadot_runtime_common::crowdloan::WeightInfo for WeightInfo { /// Storage: Crowdloan Funds (r:1 w:1) /// Proof Skipped: Crowdloan Funds (max_values: None, max_size: None, mode: Measured) /// Storage: Registrar Paras (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_common_identity_migrator.rs b/polkadot/runtime/rococo/src/weights/runtime_common_identity_migrator.rs index cec357453b67..4ea6f6796801 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_common_identity_migrator.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_common_identity_migrator.rs @@ -42,7 +42,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::identity_migrator`. pub struct WeightInfo(PhantomData); -impl runtime_common::identity_migrator::WeightInfo for WeightInfo { +impl polkadot_runtime_common::identity_migrator::WeightInfo for WeightInfo { /// Storage: `Identity::IdentityOf` (r:1 w:1) /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(7538), added: 10013, mode: `MaxEncodedLen`) /// Storage: `Identity::SubsOf` (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_common_paras_registrar.rs b/polkadot/runtime/rococo/src/weights/runtime_common_paras_registrar.rs index 0a56562a1a95..0ce09d1be2a4 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_common_paras_registrar.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_common_paras_registrar.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::paras_registrar`. pub struct WeightInfo(PhantomData); -impl runtime_common::paras_registrar::WeightInfo for WeightInfo { +impl polkadot_runtime_common::paras_registrar::WeightInfo for WeightInfo { /// Storage: Registrar NextFreeParaId (r:1 w:1) /// Proof Skipped: Registrar NextFreeParaId (max_values: Some(1), max_size: None, mode: Measured) /// Storage: Registrar Paras (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_common_slots.rs b/polkadot/runtime/rococo/src/weights/runtime_common_slots.rs index 23ab1ed3ee0e..8c601aa8486f 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_common_slots.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_common_slots.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::slots`. pub struct WeightInfo(PhantomData); -impl runtime_common::slots::WeightInfo for WeightInfo { +impl polkadot_runtime_common::slots::WeightInfo for WeightInfo { /// Storage: Slots Leases (r:1 w:1) /// Proof Skipped: Slots Leases (max_values: None, max_size: None, mode: Measured) /// Storage: System Account (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_assigner_on_demand.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_assigner_on_demand.rs index dba9e7904c79..9f275e7b8cdc 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_assigner_on_demand.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_assigner_on_demand.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::assigner_on_demand`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::assigner_on_demand::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::assigner_on_demand::WeightInfo for WeightInfo { /// Storage: `OnDemandAssignmentProvider::QueueStatus` (r:1 w:1) /// Proof: `OnDemandAssignmentProvider::QueueStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `OnDemandAssignmentProvider::ParaIdAffinity` (r:1 w:0) diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_configuration.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_configuration.rs index ca0575cb1b64..5592a85c90fa 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_configuration.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_configuration.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::configuration`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::configuration::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::configuration::WeightInfo for WeightInfo { /// Storage: `Configuration::PendingConfigs` (r:1 w:1) /// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0) diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_coretime.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_coretime.rs index d9f2d45207b9..0ad32996c495 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_coretime.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_coretime.rs @@ -45,11 +45,11 @@ use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -use runtime_parachains::configuration::{self, WeightInfo as ConfigWeightInfo}; +use polkadot_runtime_parachains::configuration::{self, WeightInfo as ConfigWeightInfo}; /// Weight functions for `runtime_common::coretime`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::coretime::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::coretime::WeightInfo for WeightInfo { fn request_core_count() -> Weight { ::WeightInfo::set_config_with_u32() } diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_disputes.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_disputes.rs index 63a8c3addc7d..a20515502b19 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_disputes.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_disputes.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::disputes`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::disputes::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::disputes::WeightInfo for WeightInfo { /// Storage: ParasDisputes Frozen (r:0 w:1) /// Proof Skipped: ParasDisputes Frozen (max_values: Some(1), max_size: None, mode: Measured) fn force_unfreeze() -> Weight { diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_hrmp.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_hrmp.rs index 572ecc7d4110..3c9def0b37e5 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_hrmp.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_hrmp.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::hrmp`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::hrmp::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::hrmp::WeightInfo for WeightInfo { /// Storage: `Paras::ParaLifecycles` (r:1 w:0) /// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_inclusion.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_inclusion.rs index a121ad774cef..da1b7a0dad9a 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_inclusion.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_inclusion.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::inclusion`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::inclusion::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::inclusion::WeightInfo for WeightInfo { /// Storage: MessageQueue BookStateFor (r:1 w:1) /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(55), added: 2530, mode: MaxEncodedLen) /// Storage: MessageQueue Pages (r:1 w:999) diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_initializer.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_initializer.rs index 5c627507dfb6..6065c32b1741 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_initializer.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_initializer.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::initializer`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::initializer::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::initializer::WeightInfo for WeightInfo { /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `d` is `[0, 65536]`. diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_paras.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_paras.rs index dfd95006dc7d..2dcabb7c36bb 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_paras.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -46,7 +46,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::paras`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::paras::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::paras::WeightInfo for WeightInfo { /// Storage: Paras CurrentCodeHash (r:1 w:1) /// Proof Skipped: Paras CurrentCodeHash (max_values: None, max_size: None, mode: Measured) /// Storage: Paras CodeByHashRefs (r:1 w:1) diff --git a/polkadot/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs b/polkadot/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs index c250c86665be..c00966fb8048 100644 --- a/polkadot/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs +++ b/polkadot/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::paras_inherent`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::paras_inherent::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::paras_inherent::WeightInfo for WeightInfo { /// Storage: `ParaInherent::Included` (r:1 w:1) /// Proof: `ParaInherent::Included` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `System::ParentHash` (r:1 w:0) diff --git a/polkadot/runtime/rococo/src/xcm_config.rs b/polkadot/runtime/rococo/src/xcm_config.rs index decbc795143f..96416821e4c8 100644 --- a/polkadot/runtime/rococo/src/xcm_config.rs +++ b/polkadot/runtime/rococo/src/xcm_config.rs @@ -29,11 +29,11 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; -use rococo_runtime_constants::{currency::CENTS, system_parachain::*}; -use runtime_common::{ +use polkadot_runtime_common::{ xcm_sender::{ChildParachainRouter, ExponentialPrice}, ToAuthor, }; +use rococo_runtime_constants::{currency::CENTS, system_parachain::*}; use sp_core::ConstU32; use xcm::latest::prelude::*; use xcm_builder::{ diff --git a/polkadot/runtime/test-runtime/Cargo.toml b/polkadot/runtime/test-runtime/Cargo.toml index 596cc974c825..c4d78b1081a6 100644 --- a/polkadot/runtime/test-runtime/Cargo.toml +++ b/polkadot/runtime/test-runtime/Cargo.toml @@ -11,17 +11,17 @@ license.workspace = true workspace = true [dependencies] -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } log = { workspace = true } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } serde = { workspace = true } -authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../substrate/primitives/authority-discovery", default-features = false } -babe-primitives = { package = "sp-consensus-babe", path = "../../../substrate/primitives/consensus/babe", default-features = false } -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../substrate/primitives/consensus/beefy", default-features = false } +sp-authority-discovery = { path = "../../../substrate/primitives/authority-discovery", default-features = false } +sp-consensus-babe = { path = "../../../substrate/primitives/consensus/babe", default-features = false } +sp-consensus-beefy = { path = "../../../substrate/primitives/consensus/beefy", default-features = false } sp-api = { path = "../../../substrate/primitives/api", default-features = false } -inherents = { package = "sp-inherents", path = "../../../substrate/primitives/inherents", default-features = false } -offchain-primitives = { package = "sp-offchain", path = "../../../substrate/primitives/offchain", default-features = false } +sp-inherents = { path = "../../../substrate/primitives/inherents", default-features = false } +sp-offchain = { path = "../../../substrate/primitives/offchain", default-features = false } sp-std = { path = "../../../substrate/primitives/std", default-features = false } sp-io = { path = "../../../substrate/primitives/io", default-features = false } sp-runtime = { path = "../../../substrate/primitives/runtime", default-features = false } @@ -32,8 +32,8 @@ sp-mmr-primitives = { path = "../../../substrate/primitives/merkle-mountain-rang sp-session = { path = "../../../substrate/primitives/session", default-features = false } sp-version = { path = "../../../substrate/primitives/version", default-features = false } frame-election-provider-support = { path = "../../../substrate/frame/election-provider-support", default-features = false } -tx-pool-api = { package = "sp-transaction-pool", path = "../../../substrate/primitives/transaction-pool", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../substrate/primitives/block-builder", default-features = false } +sp-transaction-pool = { path = "../../../substrate/primitives/transaction-pool", default-features = false } +sp-block-builder = { path = "../../../substrate/primitives/block-builder", default-features = false } pallet-authority-discovery = { path = "../../../substrate/frame/authority-discovery", default-features = false } pallet-authorship = { path = "../../../substrate/frame/authorship", default-features = false } @@ -56,8 +56,8 @@ pallet-timestamp = { path = "../../../substrate/frame/timestamp", default-featur pallet-sudo = { path = "../../../substrate/frame/sudo", default-features = false } pallet-vesting = { path = "../../../substrate/frame/vesting", default-features = false } -runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } +polkadot-runtime-common = { path = "../common", default-features = false } +polkadot-primitives = { path = "../../primitives", default-features = false } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } polkadot-runtime-parachains = { path = "../parachains", default-features = false } xcm-builder = { package = "staging-xcm-builder", path = "../../xcm/xcm-builder", default-features = false } @@ -67,7 +67,7 @@ xcm = { package = "staging-xcm", path = "../../xcm", default-features = false } [dev-dependencies] hex-literal = "0.4.1" tiny-keccak = { version = "2.0.2", features = ["keccak"] } -keyring = { package = "sp-keyring", path = "../../../substrate/primitives/keyring" } +sp-keyring = { path = "../../../substrate/primitives/keyring" } sp-trie = { path = "../../../substrate/primitives/trie" } serde_json = { workspace = true, default-features = true } @@ -84,18 +84,13 @@ runtime-metrics = [ ] std = [ - "authority-discovery-primitives/std", - "babe-primitives/std", - "beefy-primitives/std", - "block-builder-api/std", + "codec/std", "frame-election-provider-support/std", "frame-executive/std", "frame-support/std", "frame-system-rpc-runtime-api/std", "frame-system/std", - "inherents/std", "log/std", - "offchain-primitives/std", "pallet-authority-discovery/std", "pallet-authorship/std", "pallet-babe/std", @@ -111,24 +106,29 @@ std = [ "pallet-transaction-payment/std", "pallet-vesting/std", "pallet-xcm/std", - "parity-scale-codec/std", + "polkadot-primitives/std", + "polkadot-runtime-common/std", "polkadot-runtime-parachains/std", - "primitives/std", - "runtime-common/std", "scale-info/std", "serde/std", "sp-api/std", + "sp-authority-discovery/std", + "sp-block-builder/std", + "sp-consensus-babe/std", + "sp-consensus-beefy/std", "sp-core/std", "sp-genesis-builder/std", + "sp-inherents/std", "sp-io/std", "sp-mmr-primitives/std", + "sp-offchain/std", "sp-runtime/std", "sp-session/std", "sp-staking/std", "sp-std/std", + "sp-transaction-pool/std", "sp-version/std", "test-runtime-constants/std", - "tx-pool-api/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", @@ -148,9 +148,9 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", - "primitives/runtime-benchmarks", - "runtime-common/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", "xcm-builder/runtime-benchmarks", diff --git a/polkadot/runtime/test-runtime/constants/Cargo.toml b/polkadot/runtime/test-runtime/constants/Cargo.toml index 5b8a4d7a051a..ed10ece54f67 100644 --- a/polkadot/runtime/test-runtime/constants/Cargo.toml +++ b/polkadot/runtime/test-runtime/constants/Cargo.toml @@ -13,13 +13,13 @@ workspace = true smallvec = "1.8.0" frame-support = { path = "../../../../substrate/frame/support", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } +polkadot-primitives = { path = "../../../primitives", default-features = false } sp-runtime = { path = "../../../../substrate/primitives/runtime", default-features = false } [features] default = ["std"] std = [ "frame-support/std", - "primitives/std", + "polkadot-primitives/std", "sp-runtime/std", ] diff --git a/polkadot/runtime/test-runtime/constants/src/lib.rs b/polkadot/runtime/test-runtime/constants/src/lib.rs index 2422762ca38e..0d16909b2990 100644 --- a/polkadot/runtime/test-runtime/constants/src/lib.rs +++ b/polkadot/runtime/test-runtime/constants/src/lib.rs @@ -20,7 +20,7 @@ pub mod weights; /// Money matters. pub mod currency { - use primitives::Balance; + use polkadot_primitives::Balance; pub const DOTS: Balance = 1_000_000_000_000; pub const DOLLARS: Balance = DOTS; @@ -30,7 +30,7 @@ pub mod currency { /// Time and blocks. pub mod time { - use primitives::{BlockNumber, Moment}; + use polkadot_primitives::{BlockNumber, Moment}; // Testnet pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -55,7 +55,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::Balance; + use polkadot_primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index 9eb0fcca6678..8178639946f8 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -20,8 +20,8 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] +use codec::Encode; use pallet_transaction_payment::FungibleAdapter; -use parity_scale_codec::Encode; use sp_std::{ collections::{btree_map::BTreeMap, vec_deque::VecDeque}, prelude::*, @@ -41,8 +41,6 @@ use polkadot_runtime_parachains::{ shared as parachains_shared, }; -use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; -use beefy_primitives::ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}; use frame_election_provider_support::{ bounds::{ElectionBounds, ElectionBoundsBuilder}, onchain, SequentialPhragmen, @@ -56,8 +54,7 @@ use frame_support::{ use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId}; use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; -use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; -use primitives::{ +use polkadot_primitives::{ slashing, AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash as HashT, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, @@ -65,10 +62,13 @@ use primitives::{ SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, PARACHAIN_KEY_TYPE_ID, }; -use runtime_common::{ +use polkadot_runtime_common::{ claims, impl_runtime_weights, paras_sudo_wrapper, BlockHashCount, BlockLength, SlowAdjustingFeeUpdate, }; +use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_beefy::ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}; use sp_core::{ConstU32, OpaqueMetadata}; use sp_mmr_primitives as mmr; use sp_runtime::{ @@ -121,10 +121,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { }; /// The BABE epoch configuration at genesis. -pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration = - babe_primitives::BabeEpochConfiguration { +pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = + sp_consensus_babe::BabeEpochConfiguration { c: PRIMARY_PROBABILITY, - allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots, + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots, }; /// Native version. @@ -324,7 +324,8 @@ parameter_types! { pub struct OnChainSeqPhragmen; impl onchain::Config for OnChainSeqPhragmen { type System = Runtime; - type Solver = SequentialPhragmen; + type Solver = + SequentialPhragmen; type DataProvider = Staking; type WeightInfo = (); type Bounds = ElectionBoundsOnChain; @@ -338,7 +339,7 @@ impl pallet_staking::Config for Runtime { type Currency = Balances; type CurrencyBalance = Balance; type UnixTime = Timestamp; - type CurrencyToVote = runtime_common::CurrencyToVote; + type CurrencyToVote = polkadot_runtime_common::CurrencyToVote; type RewardRemainder = (); type RuntimeEvent = RuntimeEvent; type Slash = (); @@ -361,7 +362,7 @@ impl pallet_staking::Config for Runtime { type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type MaxControllersInDeprecationBatch = ConstU32<5900>; type HistoryDepth = frame_support::traits::ConstU32<84>; - type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; + type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig; type EventListeners = (); type WeightInfo = (); type DisablingStrategy = pallet_staking::UpToLimitDisablingStrategy; @@ -796,7 +797,7 @@ sp_api::impl_runtime_apis! { } } - impl block_builder_api::BlockBuilder for Runtime { + impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } @@ -805,19 +806,19 @@ sp_api::impl_runtime_apis! { Executive::finalize_block() } - fn inherent_extrinsics(data: inherents::InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } fn check_inherents( block: Block, - data: inherents::InherentData, - ) -> inherents::CheckInherentsResult { + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) } } - impl tx_pool_api::runtime_api::TaggedTransactionQueue for Runtime { + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, @@ -827,20 +828,20 @@ sp_api::impl_runtime_apis! { } } - impl offchain_primitives::OffchainWorkerApi for Runtime { + impl sp_offchain::OffchainWorkerApi for Runtime { fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } - impl authority_discovery_primitives::AuthorityDiscoveryApi for Runtime { + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { fn authorities() -> Vec { runtime_impl::relevant_authority_ids::() } } #[api_version(11)] - impl primitives::runtime_api::ParachainHost for Runtime { + impl polkadot_primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { runtime_impl::validators::() } @@ -871,7 +872,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::CandidateCommitments, + outputs: polkadot_primitives::CandidateCommitments, ) -> bool { runtime_impl::check_validation_outputs::(para_id, outputs) } @@ -924,8 +925,8 @@ sp_api::impl_runtime_apis! { } fn submit_pvf_check_statement( - stmt: primitives::PvfCheckStatement, - signature: primitives::ValidatorSignature, + stmt: polkadot_primitives::PvfCheckStatement, + signature: polkadot_primitives::ValidatorSignature, ) { runtime_impl::submit_pvf_check_statement::(stmt, signature) } @@ -952,7 +953,7 @@ sp_api::impl_runtime_apis! { fn key_ownership_proof( validator_id: ValidatorId, ) -> Option { - use parity_scale_codec::Encode; + use codec::Encode; Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id)) .map(|p| p.encode()) @@ -973,15 +974,15 @@ sp_api::impl_runtime_apis! { runtime_impl::minimum_backing_votes::() } - fn para_backing_state(para_id: ParaId) -> Option { + fn para_backing_state(para_id: ParaId) -> Option { runtime_impl::backing_state::(para_id) } - fn async_backing_params() -> primitives::AsyncBackingParams { + fn async_backing_params() -> polkadot_primitives::AsyncBackingParams { runtime_impl::async_backing_params::() } - fn approval_voting_params() -> primitives::ApprovalVotingParams { + fn approval_voting_params() -> polkadot_primitives::ApprovalVotingParams { runtime_impl::approval_voting_params::() } @@ -989,7 +990,7 @@ sp_api::impl_runtime_apis! { runtime_impl::disabled_validators::() } - fn node_features() -> primitives::NodeFeatures { + fn node_features() -> polkadot_primitives::NodeFeatures { runtime_impl::node_features::() } @@ -1002,32 +1003,32 @@ sp_api::impl_runtime_apis! { } } - impl beefy_primitives::BeefyApi for Runtime { + impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { // dummy implementation due to lack of BEEFY pallet. None } - fn validator_set() -> Option> { + fn validator_set() -> Option> { // dummy implementation due to lack of BEEFY pallet. None } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: beefy_primitives::DoubleVotingProof< + _equivocation_proof: sp_consensus_beefy::DoubleVotingProof< BlockNumber, BeefyId, BeefySignature, >, - _key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof, + _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, ) -> Option<()> { None } fn generate_key_ownership_proof( - _set_id: beefy_primitives::ValidatorSetId, + _set_id: sp_consensus_beefy::ValidatorSetId, _authority_id: BeefyId, - ) -> Option { + ) -> Option { None } } @@ -1090,10 +1091,10 @@ sp_api::impl_runtime_apis! { } } - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeConfiguration { let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); - babe_primitives::BabeConfiguration { + sp_consensus_babe::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), c: epoch_config.c, @@ -1103,28 +1104,28 @@ sp_api::impl_runtime_apis! { } } - fn current_epoch_start() -> babe_primitives::Slot { + fn current_epoch_start() -> sp_consensus_babe::Slot { Babe::current_epoch_start() } - fn current_epoch() -> babe_primitives::Epoch { + fn current_epoch() -> sp_consensus_babe::Epoch { Babe::current_epoch() } - fn next_epoch() -> babe_primitives::Epoch { + fn next_epoch() -> sp_consensus_babe::Epoch { Babe::next_epoch() } fn generate_key_ownership_proof( - _slot: babe_primitives::Slot, - _authority_id: babe_primitives::AuthorityId, - ) -> Option { + _slot: sp_consensus_babe::Slot, + _authority_id: sp_consensus_babe::AuthorityId, + ) -> Option { None } fn submit_report_equivocation_unsigned_extrinsic( - _equivocation_proof: babe_primitives::EquivocationProof<::Header>, - _key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, + _equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, + _key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, ) -> Option<()> { None } diff --git a/polkadot/runtime/test-runtime/src/xcm_config.rs b/polkadot/runtime/test-runtime/src/xcm_config.rs index fc3d0dc42a3b..b1d86ff9a85e 100644 --- a/polkadot/runtime/test-runtime/src/xcm_config.rs +++ b/polkadot/runtime/test-runtime/src/xcm_config.rs @@ -20,8 +20,8 @@ use frame_support::{ weights::Weight, }; use frame_system::EnsureRoot; +use polkadot_runtime_common::xcm_sender::{ChildParachainRouter, PriceForMessageDelivery}; use polkadot_runtime_parachains::FeeTracker; -use runtime_common::xcm_sender::{ChildParachainRouter, PriceForMessageDelivery}; use xcm::latest::prelude::*; use xcm_builder::{ AllowUnpaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, diff --git a/polkadot/runtime/westend/Cargo.toml b/polkadot/runtime/westend/Cargo.toml index 56623272be82..ccb8a02b981c 100644 --- a/polkadot/runtime/westend/Cargo.toml +++ b/polkadot/runtime/westend/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } log = { workspace = true } rustc-hex = { version = "2.1.0", default-features = false } @@ -20,12 +20,12 @@ serde = { workspace = true } serde_derive = { optional = true, workspace = true } smallvec = "1.8.0" -authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../substrate/primitives/authority-discovery", default-features = false } -babe-primitives = { package = "sp-consensus-babe", path = "../../../substrate/primitives/consensus/babe", default-features = false } -beefy-primitives = { package = "sp-consensus-beefy", path = "../../../substrate/primitives/consensus/beefy", default-features = false } +sp-authority-discovery = { path = "../../../substrate/primitives/authority-discovery", default-features = false } +sp-consensus-babe = { path = "../../../substrate/primitives/consensus/babe", default-features = false } +sp-consensus-beefy = { path = "../../../substrate/primitives/consensus/beefy", default-features = false } binary-merkle-tree = { path = "../../../substrate/utils/binary-merkle-tree", default-features = false } -inherents = { package = "sp-inherents", path = "../../../substrate/primitives/inherents", default-features = false } -offchain-primitives = { package = "sp-offchain", path = "../../../substrate/primitives/offchain", default-features = false } +sp-inherents = { path = "../../../substrate/primitives/inherents", default-features = false } +sp-offchain = { path = "../../../substrate/primitives/offchain", default-features = false } sp-api = { path = "../../../substrate/primitives/api", default-features = false } sp-application-crypto = { path = "../../../substrate/primitives/application-crypto", default-features = false } sp-arithmetic = { path = "../../../substrate/primitives/arithmetic", default-features = false } @@ -39,8 +39,8 @@ sp-core = { path = "../../../substrate/primitives/core", default-features = fals sp-session = { path = "../../../substrate/primitives/session", default-features = false } sp-storage = { path = "../../../substrate/primitives/storage", default-features = false } sp-version = { path = "../../../substrate/primitives/version", default-features = false } -tx-pool-api = { package = "sp-transaction-pool", path = "../../../substrate/primitives/transaction-pool", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../substrate/primitives/block-builder", default-features = false } +sp-transaction-pool = { path = "../../../substrate/primitives/transaction-pool", default-features = false } +sp-block-builder = { path = "../../../substrate/primitives/block-builder", default-features = false } sp-npos-elections = { path = "../../../substrate/primitives/npos-elections", default-features = false } frame-election-provider-support = { path = "../../../substrate/frame/election-provider-support", default-features = false } @@ -107,10 +107,10 @@ pallet-offences-benchmarking = { path = "../../../substrate/frame/offences/bench pallet-session-benchmarking = { path = "../../../substrate/frame/session/benchmarking", default-features = false, optional = true } hex-literal = { version = "0.4.1", optional = true } -runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } +polkadot-runtime-common = { path = "../common", default-features = false } +polkadot-primitives = { path = "../../primitives", default-features = false } polkadot-parachain-primitives = { path = "../../parachain", default-features = false } -runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } +polkadot-runtime-parachains = { path = "../parachains", default-features = false } xcm = { package = "staging-xcm", path = "../../xcm", default-features = false } xcm-executor = { package = "staging-xcm-executor", path = "../../xcm/xcm-executor", default-features = false } @@ -120,7 +120,7 @@ xcm-fee-payment-runtime-api = { path = "../../xcm/xcm-fee-payment-runtime-api", [dev-dependencies] hex-literal = "0.4.1" tiny-keccak = { version = "2.0.2", features = ["keccak"] } -keyring = { package = "sp-keyring", path = "../../../substrate/primitives/keyring" } +sp-keyring = { path = "../../../substrate/primitives/keyring" } serde_json = { workspace = true, default-features = true } remote-externalities = { package = "frame-remote-externalities", path = "../../../substrate/utils/frame/remote-externalities" } tokio = { version = "1.24.2", features = ["macros"] } @@ -134,12 +134,9 @@ default = ["std"] no_std = [] only-staking = [] std = [ - "authority-discovery-primitives/std", - "babe-primitives/std", - "beefy-primitives/std", "binary-merkle-tree/std", "bitvec/std", - "block-builder-api/std", + "codec/std", "frame-benchmarking?/std", "frame-election-provider-support/std", "frame-executive/std", @@ -149,9 +146,7 @@ std = [ "frame-system-rpc-runtime-api/std", "frame-system/std", "frame-try-runtime/std", - "inherents/std", "log/std", - "offchain-primitives/std", "pallet-asset-rate/std", "pallet-authority-discovery/std", "pallet-authorship/std", @@ -202,11 +197,10 @@ std = [ "pallet-whitelist/std", "pallet-xcm-benchmarks?/std", "pallet-xcm/std", - "parity-scale-codec/std", "polkadot-parachain-primitives/std", - "primitives/std", - "runtime-common/std", - "runtime-parachains/std", + "polkadot-primitives/std", + "polkadot-runtime-common/std", + "polkadot-runtime-parachains/std", "rustc-hex/std", "scale-info/std", "serde/std", @@ -214,19 +208,25 @@ std = [ "sp-api/std", "sp-application-crypto/std", "sp-arithmetic/std", + "sp-authority-discovery/std", + "sp-block-builder/std", + "sp-consensus-babe/std", + "sp-consensus-beefy/std", "sp-core/std", "sp-genesis-builder/std", + "sp-inherents/std", "sp-io/std", "sp-mmr-primitives/std", "sp-npos-elections/std", + "sp-offchain/std", "sp-runtime/std", "sp-session/std", "sp-staking/std", "sp-std/std", "sp-storage/std", "sp-tracing/std", + "sp-transaction-pool/std", "sp-version/std", - "tx-pool-api/std", "westend-runtime-constants/std", "xcm-builder/std", "xcm-executor/std", @@ -281,9 +281,9 @@ runtime-benchmarks = [ "pallet-xcm-benchmarks/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", - "primitives/runtime-benchmarks", - "runtime-common/runtime-benchmarks", - "runtime-parachains/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -339,8 +339,8 @@ try-runtime = [ "pallet-vesting/try-runtime", "pallet-whitelist/try-runtime", "pallet-xcm/try-runtime", - "runtime-common/try-runtime", - "runtime-parachains/try-runtime", + "polkadot-runtime-common/try-runtime", + "polkadot-runtime-parachains/try-runtime", "sp-runtime/try-runtime", ] @@ -350,7 +350,7 @@ metadata-hash = ["substrate-wasm-builder/metadata-hash"] # Set timing constants (e.g. session period) to faster versions to speed up testing. fast-runtime = [] -runtime-metrics = ["runtime-parachains/runtime-metrics", "sp-io/with-tracing"] +runtime-metrics = ["polkadot-runtime-parachains/runtime-metrics", "sp-io/with-tracing"] # A feature that should be enabled when the runtime should be built for on-chain # deployment. This will disable stuff that shouldn't be part of the on-chain wasm diff --git a/polkadot/runtime/westend/constants/Cargo.toml b/polkadot/runtime/westend/constants/Cargo.toml index 81df8f4f024d..d50b168fac52 100644 --- a/polkadot/runtime/westend/constants/Cargo.toml +++ b/polkadot/runtime/westend/constants/Cargo.toml @@ -13,8 +13,8 @@ workspace = true smallvec = "1.8.0" frame-support = { path = "../../../../substrate/frame/support", default-features = false } -primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } -runtime-common = { package = "polkadot-runtime-common", path = "../../common", default-features = false } +polkadot-primitives = { path = "../../../primitives", default-features = false } +polkadot-runtime-common = { path = "../../common", default-features = false } sp-runtime = { path = "../../../../substrate/primitives/runtime", default-features = false } sp-weights = { path = "../../../../substrate/primitives/weights", default-features = false } sp-core = { path = "../../../../substrate/primitives/core", default-features = false } @@ -26,8 +26,8 @@ xcm-builder = { package = "staging-xcm-builder", path = "../../../xcm/xcm-builde default = ["std"] std = [ "frame-support/std", - "primitives/std", - "runtime-common/std", + "polkadot-primitives/std", + "polkadot-runtime-common/std", "sp-core/std", "sp-runtime/std", "sp-weights/std", diff --git a/polkadot/runtime/westend/constants/src/lib.rs b/polkadot/runtime/westend/constants/src/lib.rs index 1a4c1f311061..58048272e791 100644 --- a/polkadot/runtime/westend/constants/src/lib.rs +++ b/polkadot/runtime/westend/constants/src/lib.rs @@ -20,7 +20,7 @@ pub mod weights; /// Money matters. pub mod currency { - use primitives::Balance; + use polkadot_primitives::Balance; /// The existential deposit. pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS; @@ -37,8 +37,8 @@ pub mod currency { /// Time and blocks. pub mod time { - use primitives::{BlockNumber, Moment}; - use runtime_common::prod_or_fast; + use polkadot_primitives::{BlockNumber, Moment}; + use polkadot_runtime_common::prod_or_fast; pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; @@ -62,7 +62,7 @@ pub mod fee { use frame_support::weights::{ WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; - use primitives::Balance; + use polkadot_primitives::Balance; use smallvec::smallvec; pub use sp_runtime::Perbill; @@ -98,7 +98,7 @@ pub mod fee { /// System Parachains. pub mod system_parachain { - use primitives::Id; + use polkadot_primitives::Id; use xcm_builder::IsChildSystemParachain; /// Network's Asset Hub parachain ID. @@ -144,7 +144,7 @@ mod tests { }; use crate::weights::ExtrinsicBaseWeight; use frame_support::weights::WeightToFee as WeightToFeeT; - use runtime_common::MAXIMUM_BLOCK_WEIGHT; + use polkadot_runtime_common::MAXIMUM_BLOCK_WEIGHT; #[test] // Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds. diff --git a/polkadot/runtime/westend/src/impls.rs b/polkadot/runtime/westend/src/impls.rs index 71e6b696a20a..d7ca677a7620 100644 --- a/polkadot/runtime/westend/src/impls.rs +++ b/polkadot/runtime/westend/src/impls.rs @@ -15,11 +15,11 @@ // along with Polkadot. If not, see . use crate::xcm_config; +use codec::{Decode, Encode}; use frame_support::pallet_prelude::DispatchResult; use frame_system::RawOrigin; -use parity_scale_codec::{Decode, Encode}; -use primitives::Balance; -use runtime_common::identity_migrator::{OnReapIdentity, WeightInfo}; +use polkadot_primitives::Balance; +use polkadot_runtime_common::identity_migrator::{OnReapIdentity, WeightInfo}; use sp_std::{marker::PhantomData, prelude::*}; use westend_runtime_constants::currency::*; use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm}; diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 71ff1255907b..78dcd3448a6a 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -20,11 +20,7 @@ // `#[frame_support::runtime]!` does a lot of recursion and requires us to increase the limit. #![recursion_limit = "512"] -use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; -use beefy_primitives::{ - ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}, - mmr::{BeefyDataProvider, MmrLeafVersion}, -}; +use codec::{Decode, Encode, MaxEncodedLen}; use frame_election_provider_support::{bounds::ElectionBoundsBuilder, onchain, SequentialPhragmen}; use frame_support::{ derive_impl, @@ -43,8 +39,7 @@ use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId}; use pallet_identity::legacy::IdentityInfo; use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo}; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::{ +use polkadot_primitives::{ slashing, AccountId, AccountIndex, ApprovalVotingParams, Balance, BlockNumber, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, @@ -52,7 +47,7 @@ use primitives::{ ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, PARACHAIN_KEY_TYPE_ID, }; -use runtime_common::{ +use polkadot_runtime_common::{ assigned_slots, auctions, crowdloan, elections::OnChainAccuracy, identity_migrator, impl_runtime_weights, @@ -65,7 +60,7 @@ use runtime_common::{ BalanceToU256, BlockHashCount, BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate, U256ToBalance, }; -use runtime_parachains::{ +use polkadot_runtime_parachains::{ assigner_coretime as parachains_assigner_coretime, assigner_on_demand as parachains_assigner_on_demand, configuration as parachains_configuration, configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio, @@ -82,6 +77,11 @@ use runtime_parachains::{ shared as parachains_shared, }; use scale_info::TypeInfo; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_beefy::{ + ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature}, + mmr::{BeefyDataProvider, MmrLeafVersion}, +}; use sp_core::{ConstU8, OpaqueMetadata, RuntimeDebug, H256}; use sp_runtime::{ create_runtime_str, @@ -162,10 +162,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { }; /// The BABE epoch configuration at genesis. -pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration = - babe_primitives::BabeEpochConfiguration { +pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = + sp_consensus_babe::BabeEpochConfiguration { c: PRIMARY_PROBABILITY, - allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots, + allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryVRFSlots, }; /// Native version. @@ -570,7 +570,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { pallet_election_provider_multi_phase::SolutionAccuracyOf, (), >; - type BenchmarkingConfig = runtime_common::elections::BenchmarkConfig; + type BenchmarkingConfig = polkadot_runtime_common::elections::BenchmarkConfig; type ForceOrigin = EnsureRoot; type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo; type MaxWinners = MaxActiveValidators; @@ -643,7 +643,7 @@ impl pallet_staking::Config for Runtime { type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; type HistoryDepth = frame_support::traits::ConstU32<84>; type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch; - type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; + type BenchmarkingConfig = polkadot_runtime_common::StakingBenchmarkingConfig; type EventListeners = (NominationPools, DelegatedStaking); type WeightInfo = weights::pallet_staking::WeightInfo; type DisablingStrategy = pallet_staking::UpToLimitDisablingStrategy; @@ -724,7 +724,7 @@ impl pallet_treasury::Config for Runtime { >; type PayoutPeriod = PayoutSpendPeriod; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = runtime_common::impls::benchmarks::TreasuryArguments; + type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::TreasuryArguments; } impl pallet_offences::Config for Runtime { @@ -1403,7 +1403,7 @@ impl pallet_asset_rate::Config for Runtime { type Currency = Balances; type AssetKind = ::AssetKind; #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = runtime_common::impls::benchmarks::AssetRateArguments; + type BenchmarkHelper = polkadot_runtime_common::impls::benchmarks::AssetRateArguments; } // Notify `coretime` pallet when a lease swap occurs @@ -1708,22 +1708,22 @@ mod benches { // Polkadot // NOTE: Make sure to prefix these with `runtime_common::` so // the that path resolves correctly in the generated file. - [runtime_common::assigned_slots, AssignedSlots] - [runtime_common::auctions, Auctions] - [runtime_common::crowdloan, Crowdloan] - [runtime_common::identity_migrator, IdentityMigrator] - [runtime_common::paras_registrar, Registrar] - [runtime_common::slots, Slots] - [runtime_parachains::configuration, Configuration] - [runtime_parachains::disputes, ParasDisputes] - [runtime_parachains::disputes::slashing, ParasSlashing] - [runtime_parachains::hrmp, Hrmp] - [runtime_parachains::inclusion, ParaInclusion] - [runtime_parachains::initializer, Initializer] - [runtime_parachains::paras, Paras] - [runtime_parachains::paras_inherent, ParaInherent] - [runtime_parachains::assigner_on_demand, OnDemandAssignmentProvider] - [runtime_parachains::coretime, Coretime] + [polkadot_runtime_common::assigned_slots, AssignedSlots] + [polkadot_runtime_common::auctions, Auctions] + [polkadot_runtime_common::crowdloan, Crowdloan] + [polkadot_runtime_common::identity_migrator, IdentityMigrator] + [polkadot_runtime_common::paras_registrar, Registrar] + [polkadot_runtime_common::slots, Slots] + [polkadot_runtime_parachains::configuration, Configuration] + [polkadot_runtime_parachains::disputes, ParasDisputes] + [polkadot_runtime_parachains::disputes::slashing, ParasSlashing] + [polkadot_runtime_parachains::hrmp, Hrmp] + [polkadot_runtime_parachains::inclusion, ParaInclusion] + [polkadot_runtime_parachains::initializer, Initializer] + [polkadot_runtime_parachains::paras, Paras] + [polkadot_runtime_parachains::paras_inherent, ParaInherent] + [polkadot_runtime_parachains::assigner_on_demand, OnDemandAssignmentProvider] + [polkadot_runtime_parachains::coretime, Coretime] // Substrate [pallet_bags_list, VoterList] [pallet_balances, Balances] @@ -1789,7 +1789,7 @@ sp_api::impl_runtime_apis! { } } - impl block_builder_api::BlockBuilder for Runtime { + impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } @@ -1798,19 +1798,19 @@ sp_api::impl_runtime_apis! { Executive::finalize_block() } - fn inherent_extrinsics(data: inherents::InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } fn check_inherents( block: Block, - data: inherents::InherentData, - ) -> inherents::CheckInherentsResult { + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) } } - impl tx_pool_api::runtime_api::TaggedTransactionQueue for Runtime { + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( source: TransactionSource, tx: ::Extrinsic, @@ -1820,14 +1820,14 @@ sp_api::impl_runtime_apis! { } } - impl offchain_primitives::OffchainWorkerApi for Runtime { + impl sp_offchain::OffchainWorkerApi for Runtime { fn offchain_worker(header: &::Header) { Executive::offchain_worker(header) } } #[api_version(11)] - impl primitives::runtime_api::ParachainHost for Runtime { + impl polkadot_primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() } @@ -1857,7 +1857,7 @@ sp_api::impl_runtime_apis! { fn check_validation_outputs( para_id: ParaId, - outputs: primitives::CandidateCommitments, + outputs: polkadot_primitives::CandidateCommitments, ) -> bool { parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) } @@ -1942,7 +1942,7 @@ sp_api::impl_runtime_apis! { fn key_ownership_proof( validator_id: ValidatorId, ) -> Option { - use parity_scale_codec::Encode; + use codec::Encode; Historical::prove((PARACHAIN_KEY_TYPE_ID, validator_id)) .map(|p| p.encode()) @@ -1963,11 +1963,11 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::minimum_backing_votes::() } - fn para_backing_state(para_id: ParaId) -> Option { + fn para_backing_state(para_id: ParaId) -> Option { parachains_runtime_api_impl::backing_state::(para_id) } - fn async_backing_params() -> primitives::AsyncBackingParams { + fn async_backing_params() -> polkadot_primitives::AsyncBackingParams { parachains_runtime_api_impl::async_backing_params::() } @@ -1992,22 +1992,22 @@ sp_api::impl_runtime_apis! { } } - impl beefy_primitives::BeefyApi for Runtime { + impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() } - fn validator_set() -> Option> { + fn validator_set() -> Option> { Beefy::validator_set() } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: beefy_primitives::DoubleVotingProof< + equivocation_proof: sp_consensus_beefy::DoubleVotingProof< BlockNumber, BeefyId, BeefySignature, >, - key_owner_proof: beefy_primitives::OpaqueKeyOwnershipProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; @@ -2018,14 +2018,14 @@ sp_api::impl_runtime_apis! { } fn generate_key_ownership_proof( - _set_id: beefy_primitives::ValidatorSetId, + _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, - ) -> Option { - use parity_scale_codec::Encode; + ) -> Option { + use codec::Encode; - Historical::prove((beefy_primitives::KEY_TYPE, authority_id)) + Historical::prove((sp_consensus_beefy::KEY_TYPE, authority_id)) .map(|p| p.encode()) - .map(beefy_primitives::OpaqueKeyOwnershipProof::new) + .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } } @@ -2076,11 +2076,11 @@ sp_api::impl_runtime_apis! { } impl pallet_beefy_mmr::BeefyMmrApi for RuntimeApi { - fn authority_set_proof() -> beefy_primitives::mmr::BeefyAuthoritySet { + fn authority_set_proof() -> sp_consensus_beefy::mmr::BeefyAuthoritySet { BeefyMmrLeaf::authority_set_proof() } - fn next_authority_set_proof() -> beefy_primitives::mmr::BeefyNextAuthoritySet { + fn next_authority_set_proof() -> sp_consensus_beefy::mmr::BeefyNextAuthoritySet { BeefyMmrLeaf::next_authority_set_proof() } } @@ -2113,7 +2113,7 @@ sp_api::impl_runtime_apis! { _set_id: fg_primitives::SetId, authority_id: fg_primitives::AuthorityId, ) -> Option { - use parity_scale_codec::Encode; + use codec::Encode; Historical::prove((fg_primitives::KEY_TYPE, authority_id)) .map(|p| p.encode()) @@ -2121,10 +2121,10 @@ sp_api::impl_runtime_apis! { } } - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeConfiguration { let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); - babe_primitives::BabeConfiguration { + sp_consensus_babe::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), c: epoch_config.c, @@ -2134,32 +2134,32 @@ sp_api::impl_runtime_apis! { } } - fn current_epoch_start() -> babe_primitives::Slot { + fn current_epoch_start() -> sp_consensus_babe::Slot { Babe::current_epoch_start() } - fn current_epoch() -> babe_primitives::Epoch { + fn current_epoch() -> sp_consensus_babe::Epoch { Babe::current_epoch() } - fn next_epoch() -> babe_primitives::Epoch { + fn next_epoch() -> sp_consensus_babe::Epoch { Babe::next_epoch() } fn generate_key_ownership_proof( - _slot: babe_primitives::Slot, - authority_id: babe_primitives::AuthorityId, - ) -> Option { - use parity_scale_codec::Encode; + _slot: sp_consensus_babe::Slot, + authority_id: sp_consensus_babe::AuthorityId, + ) -> Option { + use codec::Encode; - Historical::prove((babe_primitives::KEY_TYPE, authority_id)) + Historical::prove((sp_consensus_babe::KEY_TYPE, authority_id)) .map(|p| p.encode()) - .map(babe_primitives::OpaqueKeyOwnershipProof::new) + .map(sp_consensus_babe::OpaqueKeyOwnershipProof::new) } fn submit_report_equivocation_unsigned_extrinsic( - equivocation_proof: babe_primitives::EquivocationProof<::Header>, - key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof, + equivocation_proof: sp_consensus_babe::EquivocationProof<::Header>, + key_owner_proof: sp_consensus_babe::OpaqueKeyOwnershipProof, ) -> Option<()> { let key_owner_proof = key_owner_proof.decode()?; @@ -2170,7 +2170,7 @@ sp_api::impl_runtime_apis! { } } - impl authority_discovery_primitives::AuthorityDiscoveryApi for Runtime { + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { fn authorities() -> Vec { parachains_runtime_api_impl::relevant_authority_ids::() } @@ -2384,14 +2384,14 @@ sp_api::impl_runtime_apis! { impl pallet_xcm::benchmarking::Config for Runtime { type DeliveryHelper = ( - runtime_common::xcm_sender::ToParachainDeliveryHelper< + polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< xcm_config::XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, AssetHubParaId, (), >, - runtime_common::xcm_sender::ToParachainDeliveryHelper< + polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< xcm_config::XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, @@ -2447,7 +2447,7 @@ sp_api::impl_runtime_apis! { } impl frame_system_benchmarking::Config for Runtime {} impl pallet_nomination_pools_benchmarking::Config for Runtime {} - impl runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {} + impl polkadot_runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {} use xcm::latest::{ AssetId, Fungibility::*, InteriorLocation, Junction, Junctions::*, @@ -2457,7 +2457,7 @@ sp_api::impl_runtime_apis! { impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = xcm_config::XcmConfig; type AccountIdConverter = xcm_config::LocationConverter; - type DeliveryHelper = runtime_common::xcm_sender::ToParachainDeliveryHelper< + type DeliveryHelper = polkadot_runtime_common::xcm_sender::ToParachainDeliveryHelper< xcm_config::XcmConfig, ExistentialDepositAsset, xcm_config::PriceForChildParachainDelivery, diff --git a/polkadot/runtime/westend/src/tests.rs b/polkadot/runtime/westend/src/tests.rs index 4acb81e963b2..4d5e2e946bce 100644 --- a/polkadot/runtime/westend/src/tests.rs +++ b/polkadot/runtime/westend/src/tests.rs @@ -24,7 +24,7 @@ use sp_core::hexdisplay::HexDisplay; #[test] fn remove_keys_weight_is_sensible() { - use runtime_common::crowdloan::WeightInfo; + use polkadot_runtime_common::crowdloan::WeightInfo; let max_weight = ::WeightInfo::refund(RemoveKeysLimit::get()); // Max remove keys limit should be no more than half the total block weight. assert!((max_weight * 2).all_lt(BlockWeights::get().max_block)); @@ -32,7 +32,7 @@ fn remove_keys_weight_is_sensible() { #[test] fn sample_size_is_sensible() { - use runtime_common::auctions::WeightInfo; + use polkadot_runtime_common::auctions::WeightInfo; // Need to clean up all samples at the end of an auction. let samples: BlockNumber = EndingPeriod::get() / SampleLength::get(); let max_weight: frame_support::weights::Weight = diff --git a/polkadot/runtime/westend/src/weights/runtime_common_assigned_slots.rs b/polkadot/runtime/westend/src/weights/runtime_common_assigned_slots.rs index c3f1060a9ac0..08b0b0f34df1 100644 --- a/polkadot/runtime/westend/src/weights/runtime_common_assigned_slots.rs +++ b/polkadot/runtime/westend/src/weights/runtime_common_assigned_slots.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::assigned_slots`. pub struct WeightInfo(PhantomData); -impl runtime_common::assigned_slots::WeightInfo for WeightInfo { +impl polkadot_runtime_common::assigned_slots::WeightInfo for WeightInfo { /// Storage: `Registrar::Paras` (r:1 w:1) /// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Paras::ParaLifecycles` (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_common_auctions.rs b/polkadot/runtime/westend/src/weights/runtime_common_auctions.rs index a6f5bbe5a1da..58ca2a083b2c 100644 --- a/polkadot/runtime/westend/src/weights/runtime_common_auctions.rs +++ b/polkadot/runtime/westend/src/weights/runtime_common_auctions.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::auctions`. pub struct WeightInfo(PhantomData); -impl runtime_common::auctions::WeightInfo for WeightInfo { +impl polkadot_runtime_common::auctions::WeightInfo for WeightInfo { /// Storage: Auctions AuctionInfo (r:1 w:1) /// Proof: Auctions AuctionInfo (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) /// Storage: Auctions AuctionCounter (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_common_crowdloan.rs b/polkadot/runtime/westend/src/weights/runtime_common_crowdloan.rs index 97b0279544c7..47472406de1e 100644 --- a/polkadot/runtime/westend/src/weights/runtime_common_crowdloan.rs +++ b/polkadot/runtime/westend/src/weights/runtime_common_crowdloan.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::crowdloan`. pub struct WeightInfo(PhantomData); -impl runtime_common::crowdloan::WeightInfo for WeightInfo { +impl polkadot_runtime_common::crowdloan::WeightInfo for WeightInfo { /// Storage: Crowdloan Funds (r:1 w:1) /// Proof Skipped: Crowdloan Funds (max_values: None, max_size: None, mode: Measured) /// Storage: Registrar Paras (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_common_identity_migrator.rs b/polkadot/runtime/westend/src/weights/runtime_common_identity_migrator.rs index cec357453b67..4ea6f6796801 100644 --- a/polkadot/runtime/westend/src/weights/runtime_common_identity_migrator.rs +++ b/polkadot/runtime/westend/src/weights/runtime_common_identity_migrator.rs @@ -42,7 +42,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::identity_migrator`. pub struct WeightInfo(PhantomData); -impl runtime_common::identity_migrator::WeightInfo for WeightInfo { +impl polkadot_runtime_common::identity_migrator::WeightInfo for WeightInfo { /// Storage: `Identity::IdentityOf` (r:1 w:1) /// Proof: `Identity::IdentityOf` (`max_values`: None, `max_size`: Some(7538), added: 10013, mode: `MaxEncodedLen`) /// Storage: `Identity::SubsOf` (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_common_paras_registrar.rs b/polkadot/runtime/westend/src/weights/runtime_common_paras_registrar.rs index 50290c0fe59f..befd89874411 100644 --- a/polkadot/runtime/westend/src/weights/runtime_common_paras_registrar.rs +++ b/polkadot/runtime/westend/src/weights/runtime_common_paras_registrar.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::paras_registrar`. pub struct WeightInfo(PhantomData); -impl runtime_common::paras_registrar::WeightInfo for WeightInfo { +impl polkadot_runtime_common::paras_registrar::WeightInfo for WeightInfo { /// Storage: Registrar NextFreeParaId (r:1 w:1) /// Proof Skipped: Registrar NextFreeParaId (max_values: Some(1), max_size: None, mode: Measured) /// Storage: Registrar Paras (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_common_slots.rs b/polkadot/runtime/westend/src/weights/runtime_common_slots.rs index c95859221fa7..b1422e506ab1 100644 --- a/polkadot/runtime/westend/src/weights/runtime_common_slots.rs +++ b/polkadot/runtime/westend/src/weights/runtime_common_slots.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_common::slots`. pub struct WeightInfo(PhantomData); -impl runtime_common::slots::WeightInfo for WeightInfo { +impl polkadot_runtime_common::slots::WeightInfo for WeightInfo { /// Storage: Slots Leases (r:1 w:1) /// Proof Skipped: Slots Leases (max_values: None, max_size: None, mode: Measured) /// Storage: System Account (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_assigner_on_demand.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_assigner_on_demand.rs index acd1834f79ed..8b046f5d34ad 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_assigner_on_demand.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_assigner_on_demand.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::assigner_on_demand`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::assigner_on_demand::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::assigner_on_demand::WeightInfo for WeightInfo { /// Storage: `OnDemandAssignmentProvider::QueueStatus` (r:1 w:1) /// Proof: `OnDemandAssignmentProvider::QueueStatus` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `OnDemandAssignmentProvider::ParaIdAffinity` (r:1 w:0) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_configuration.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_configuration.rs index 8fa3207c6446..5130b04668b2 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_configuration.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_configuration.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::configuration`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::configuration::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::configuration::WeightInfo for WeightInfo { /// Storage: `Configuration::PendingConfigs` (r:1 w:1) /// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_coretime.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_coretime.rs index aa65a2e9034a..443651a6fda4 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_coretime.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_coretime.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::coretime`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::coretime::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::coretime::WeightInfo for WeightInfo { /// Storage: `Configuration::PendingConfigs` (r:1 w:1) /// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_disputes.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_disputes.rs index 4a6a6079cf13..5beb82ec5944 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_disputes.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_disputes.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::disputes`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::disputes::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::disputes::WeightInfo for WeightInfo { /// Storage: ParasDisputes Frozen (r:0 w:1) /// Proof Skipped: ParasDisputes Frozen (max_values: Some(1), max_size: None, mode: Measured) fn force_unfreeze() -> Weight { diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs index 8600717fee1e..a035ea2b0b5e 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::disputes::slashing`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::disputes::slashing::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::disputes::slashing::WeightInfo for WeightInfo { /// Storage: Session CurrentIndex (r:1 w:0) /// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured) /// Storage: Historical HistoricalSessions (r:1 w:0) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_hrmp.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_hrmp.rs index f1d7932fe8b7..8946261664be 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_hrmp.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_hrmp.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::hrmp`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::hrmp::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::hrmp::WeightInfo for WeightInfo { /// Storage: `Paras::ParaLifecycles` (r:1 w:0) /// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_inclusion.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_inclusion.rs index 767097f660e8..25909beb6a07 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_inclusion.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_inclusion.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::inclusion`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::inclusion::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::inclusion::WeightInfo for WeightInfo { /// Storage: MessageQueue BookStateFor (r:1 w:1) /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(55), added: 2530, mode: MaxEncodedLen) /// Storage: MessageQueue Pages (r:1 w:999) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_initializer.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_initializer.rs index 81aca5c958d9..8e501de6e67f 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_initializer.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_initializer.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::initializer`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::initializer::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::initializer::WeightInfo for WeightInfo { /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `d` is `[0, 65536]`. diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_paras.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_paras.rs index 07623f60b012..d96964e69c11 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_paras.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_paras.rs @@ -49,7 +49,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::paras`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::paras::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::paras::WeightInfo for WeightInfo { /// Storage: Paras CurrentCodeHash (r:1 w:1) /// Proof Skipped: Paras CurrentCodeHash (max_values: None, max_size: None, mode: Measured) /// Storage: Paras CodeByHashRefs (r:1 w:1) diff --git a/polkadot/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs b/polkadot/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs index aa99ac9438c4..74dd55cc3f2c 100644 --- a/polkadot/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs +++ b/polkadot/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs @@ -47,7 +47,7 @@ use core::marker::PhantomData; /// Weight functions for `runtime_parachains::paras_inherent`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::paras_inherent::WeightInfo for WeightInfo { +impl polkadot_runtime_parachains::paras_inherent::WeightInfo for WeightInfo { /// Storage: `ParaInherent::Included` (r:1 w:1) /// Proof: `ParaInherent::Included` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// Storage: `System::ParentHash` (r:1 w:0) diff --git a/polkadot/runtime/westend/src/xcm_config.rs b/polkadot/runtime/westend/src/xcm_config.rs index c6c5fb9e72a4..9d7143c96bb5 100644 --- a/polkadot/runtime/westend/src/xcm_config.rs +++ b/polkadot/runtime/westend/src/xcm_config.rs @@ -28,7 +28,7 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use runtime_common::{ +use polkadot_runtime_common::{ xcm_sender::{ChildParachainRouter, ExponentialPrice}, ToAuthor, }; diff --git a/polkadot/statement-table/Cargo.toml b/polkadot/statement-table/Cargo.toml index ad4a053fa3f9..7181afd9989e 100644 --- a/polkadot/statement-table/Cargo.toml +++ b/polkadot/statement-table/Cargo.toml @@ -10,7 +10,7 @@ description = "Stores messages other authorities issue about candidates in Polka workspace = true [dependencies] -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } sp-core = { path = "../../substrate/primitives/core" } -primitives = { package = "polkadot-primitives", path = "../primitives" } +polkadot-primitives = { path = "../primitives" } gum = { package = "tracing-gum", path = "../node/gum" } diff --git a/polkadot/statement-table/src/generic.rs b/polkadot/statement-table/src/generic.rs index 2ee6f6a4f781..e96ed6af73d9 100644 --- a/polkadot/statement-table/src/generic.rs +++ b/polkadot/statement-table/src/generic.rs @@ -30,12 +30,12 @@ use std::{ hash::Hash, }; -use primitives::{ +use polkadot_primitives::{ effective_minimum_backing_votes, ValidatorSignature, ValidityAttestation as PrimitiveValidityAttestation, }; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; const LOG_TARGET: &str = "parachain::statement-table"; /// Context for the statement table. diff --git a/polkadot/statement-table/src/lib.rs b/polkadot/statement-table/src/lib.rs index 3740d15cc4f3..469c877eafc9 100644 --- a/polkadot/statement-table/src/lib.rs +++ b/polkadot/statement-table/src/lib.rs @@ -34,7 +34,7 @@ pub use generic::{Config, Context, Table}; /// Concrete instantiations suitable for v2 primitives. pub mod v2 { use crate::generic; - use primitives::{ + use polkadot_primitives::{ CandidateHash, CommittedCandidateReceipt, CompactStatement as PrimitiveStatement, CoreIndex, ValidatorIndex, ValidatorSignature, }; diff --git a/polkadot/xcm/Cargo.toml b/polkadot/xcm/Cargo.toml index 2cd8e822ae16..690fb377dad7 100644 --- a/polkadot/xcm/Cargo.toml +++ b/polkadot/xcm/Cargo.toml @@ -15,7 +15,7 @@ bounded-collections = { version = "0.2.0", default-features = false, features = derivative = { version = "2.2.0", default-features = false, features = ["use_core"] } impl-trait-for-tuples = "0.2.2" log = { workspace = true } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive", "serde"] } sp-weights = { path = "../../substrate/primitives/weights", default-features = false, features = ["serde"] } serde = { features = ["alloc", "derive", "rc"], workspace = true } @@ -33,9 +33,9 @@ default = ["std"] wasm-api = [] std = [ "bounded-collections/std", + "codec/std", "environmental/std", "log/std", - "parity-scale-codec/std", "scale-info/std", "serde/std", "sp-weights/std", diff --git a/polkadot/xcm/src/double_encoded.rs b/polkadot/xcm/src/double_encoded.rs index 320cccf9b1f0..a5eecdee9796 100644 --- a/polkadot/xcm/src/double_encoded.rs +++ b/polkadot/xcm/src/double_encoded.rs @@ -16,7 +16,7 @@ use crate::MAX_XCM_DECODE_DEPTH; use alloc::vec::Vec; -use parity_scale_codec::{Decode, DecodeLimit, Encode}; +use codec::{Decode, DecodeLimit, Encode}; /// Wrapper around the encoded and decoded versions of a value. /// Caches the decoded value once computed. diff --git a/polkadot/xcm/src/lib.rs b/polkadot/xcm/src/lib.rs index 8b0030e59b5f..1f5191c23407 100644 --- a/polkadot/xcm/src/lib.rs +++ b/polkadot/xcm/src/lib.rs @@ -26,8 +26,8 @@ extern crate alloc; +use codec::{Decode, DecodeLimit, Encode, Error as CodecError, Input, MaxEncodedLen}; use derivative::Derivative; -use parity_scale_codec::{Decode, DecodeLimit, Encode, Error as CodecError, Input, MaxEncodedLen}; use scale_info::TypeInfo; #[deprecated( diff --git a/polkadot/xcm/src/v2/junction.rs b/polkadot/xcm/src/v2/junction.rs index 771931f4b566..68a7886f3039 100644 --- a/polkadot/xcm/src/v2/junction.rs +++ b/polkadot/xcm/src/v2/junction.rs @@ -19,7 +19,7 @@ use super::{BodyId, BodyPart, Junctions, MultiLocation, NetworkId}; use crate::v3::Junction as NewJunction; use bounded_collections::{ConstU32, WeakBoundedVec}; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A single item in a path to describe the relative location of a consensus system. diff --git a/polkadot/xcm/src/v2/mod.rs b/polkadot/xcm/src/v2/mod.rs index 7b6858e6a5c2..38e55d0ea51e 100644 --- a/polkadot/xcm/src/v2/mod.rs +++ b/polkadot/xcm/src/v2/mod.rs @@ -62,9 +62,9 @@ use super::{ }; use alloc::{vec, vec::Vec}; use bounded_collections::{ConstU32, WeakBoundedVec}; +use codec::{self, Decode, Encode, MaxEncodedLen}; use core::{fmt::Debug, result}; use derivative::Derivative; -use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; mod junction; diff --git a/polkadot/xcm/src/v2/multiasset.rs b/polkadot/xcm/src/v2/multiasset.rs index 5681e9ef8a44..7090ef138ca2 100644 --- a/polkadot/xcm/src/v2/multiasset.rs +++ b/polkadot/xcm/src/v2/multiasset.rs @@ -34,8 +34,8 @@ use crate::v3::{ WildMultiAsset as NewWildMultiAsset, }; use alloc::{vec, vec::Vec}; +use codec::{self as codec, Decode, Encode}; use core::cmp::Ordering; -use parity_scale_codec::{self as codec, Decode, Encode}; use scale_info::TypeInfo; /// A general identifier for an instance of a non-fungible asset class. @@ -317,7 +317,7 @@ impl TryFrom for MultiAsset { pub struct MultiAssets(Vec); impl Decode for MultiAssets { - fn decode(input: &mut I) -> Result { + fn decode(input: &mut I) -> Result { Self::from_sorted_and_deduplicated(Vec::::decode(input)?) .map_err(|()| "Out of order".into()) } diff --git a/polkadot/xcm/src/v2/multilocation.rs b/polkadot/xcm/src/v2/multilocation.rs index ac98da8d08c9..9399ca6619c0 100644 --- a/polkadot/xcm/src/v2/multilocation.rs +++ b/polkadot/xcm/src/v2/multilocation.rs @@ -18,8 +18,8 @@ use super::Junction; use crate::v3::MultiLocation as NewMultiLocation; +use codec::{Decode, Encode, MaxEncodedLen}; use core::{mem, result}; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A relative path between state-bearing consensus systems. @@ -883,7 +883,7 @@ impl TryFrom for Junctions { mod tests { use super::{Ancestor, AncestorThen, Junctions::*, MultiLocation, Parent, ParentThen}; use crate::opaque::v2::{Junction::*, NetworkId::*}; - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; #[test] fn inverted_works() { diff --git a/polkadot/xcm/src/v2/traits.rs b/polkadot/xcm/src/v2/traits.rs index 9cfb9b051ab2..4dcb4c50c68c 100644 --- a/polkadot/xcm/src/v2/traits.rs +++ b/polkadot/xcm/src/v2/traits.rs @@ -17,8 +17,8 @@ //! Cross-Consensus Message format data structures. use crate::v3::Error as NewError; +use codec::{Decode, Encode}; use core::result; -use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use super::*; @@ -282,7 +282,7 @@ pub type SendResult = result::Result<(), SendError>; /// # Example /// ```rust /// # use staging_xcm::v2::prelude::*; -/// # use parity_scale_codec::Encode; +/// # use codec::Encode; /// /// /// A sender that only passes the message through and does nothing. /// struct Sender1; diff --git a/polkadot/xcm/src/v3/junction.rs b/polkadot/xcm/src/v3/junction.rs index 32ce352c5c02..aea4e0372515 100644 --- a/polkadot/xcm/src/v3/junction.rs +++ b/polkadot/xcm/src/v3/junction.rs @@ -26,7 +26,7 @@ use crate::{ VersionedLocation, }; use bounded_collections::{BoundedSlice, BoundedVec, ConstU32}; -use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; +use codec::{self, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; diff --git a/polkadot/xcm/src/v3/junctions.rs b/polkadot/xcm/src/v3/junctions.rs index 7b014304fdaf..56f5326fe97c 100644 --- a/polkadot/xcm/src/v3/junctions.rs +++ b/polkadot/xcm/src/v3/junctions.rs @@ -17,8 +17,8 @@ //! XCM `Junctions`/`InteriorMultiLocation` datatype. use super::{Junction, MultiLocation, NetworkId}; +use codec::{Decode, Encode, MaxEncodedLen}; use core::{mem, result}; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// Maximum number of `Junction`s that a `Junctions` can contain. diff --git a/polkadot/xcm/src/v3/mod.rs b/polkadot/xcm/src/v3/mod.rs index 8ff661a9bbac..880520cfedc2 100644 --- a/polkadot/xcm/src/v3/mod.rs +++ b/polkadot/xcm/src/v3/mod.rs @@ -28,12 +28,12 @@ use super::v4::{ use crate::DoubleEncoded; use alloc::{vec, vec::Vec}; use bounded_collections::{parameter_types, BoundedVec}; -use core::{fmt::Debug, result}; -use derivative::Derivative; -use parity_scale_codec::{ +use codec::{ self, decode_vec_with_len, Compact, Decode, Encode, Error as CodecError, Input as CodecInput, MaxEncodedLen, }; +use core::{fmt::Debug, result}; +use derivative::Derivative; use scale_info::TypeInfo; mod junction; diff --git a/polkadot/xcm/src/v3/multiasset.rs b/polkadot/xcm/src/v3/multiasset.rs index 9a67b0e4986c..7db0fa736902 100644 --- a/polkadot/xcm/src/v3/multiasset.rs +++ b/polkadot/xcm/src/v3/multiasset.rs @@ -42,8 +42,8 @@ use crate::{ }; use alloc::{vec, vec::Vec}; use bounded_collections::{BoundedVec, ConstU32}; +use codec::{self as codec, Decode, Encode, MaxEncodedLen}; use core::cmp::Ordering; -use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A general identifier for an instance of a non-fungible asset class. @@ -302,7 +302,7 @@ enum UncheckedFungibility { } impl Decode for Fungibility { - fn decode(input: &mut I) -> Result { + fn decode(input: &mut I) -> Result { match UncheckedFungibility::decode(input)? { UncheckedFungibility::Fungible(a) if a != 0 => Ok(Self::Fungible(a)), UncheckedFungibility::NonFungible(i) => Ok(Self::NonFungible(i)), diff --git a/polkadot/xcm/src/v3/multilocation.rs b/polkadot/xcm/src/v3/multilocation.rs index 731e277b29d8..e51981204d96 100644 --- a/polkadot/xcm/src/v3/multilocation.rs +++ b/polkadot/xcm/src/v3/multilocation.rs @@ -20,8 +20,8 @@ use super::{Junction, Junctions}; use crate::{ v2::MultiLocation as OldMultiLocation, v4::Location as NewMultiLocation, VersionedLocation, }; +use codec::{Decode, Encode, MaxEncodedLen}; use core::result; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A relative path between state-bearing consensus systems. @@ -531,7 +531,7 @@ xcm_procedural::impl_conversion_functions_for_multilocation_v3!(); #[cfg(test)] mod tests { use crate::v3::prelude::*; - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; #[test] fn conversion_works() { diff --git a/polkadot/xcm/src/v3/traits.rs b/polkadot/xcm/src/v3/traits.rs index 680e0bacd0c9..7fa8824c3568 100644 --- a/polkadot/xcm/src/v3/traits.rs +++ b/polkadot/xcm/src/v3/traits.rs @@ -17,8 +17,8 @@ //! Cross-Consensus Message format data structures. use crate::v2::Error as OldError; +use codec::{Decode, Encode, MaxEncodedLen}; use core::result; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; pub use sp_weights::Weight; @@ -407,7 +407,7 @@ pub type SendResult = result::Result<(T, MultiAssets), SendError>; /// /// # Example /// ```rust -/// # use parity_scale_codec::Encode; +/// # use codec::Encode; /// # use staging_xcm::v3::{prelude::*, Weight}; /// # use staging_xcm::VersionedXcm; /// # use std::convert::Infallible; diff --git a/polkadot/xcm/src/v4/asset.rs b/polkadot/xcm/src/v4/asset.rs index 6b6d200f32fe..a081b595adb1 100644 --- a/polkadot/xcm/src/v4/asset.rs +++ b/polkadot/xcm/src/v4/asset.rs @@ -34,8 +34,8 @@ use crate::v3::{ }; use alloc::{vec, vec::Vec}; use bounded_collections::{BoundedVec, ConstU32}; +use codec::{self as codec, Decode, Encode, MaxEncodedLen}; use core::cmp::Ordering; -use parity_scale_codec::{self as codec, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A general identifier for an instance of a non-fungible asset class. @@ -274,7 +274,7 @@ enum UncheckedFungibility { } impl Decode for Fungibility { - fn decode(input: &mut I) -> Result { + fn decode(input: &mut I) -> Result { match UncheckedFungibility::decode(input)? { UncheckedFungibility::Fungible(a) if a != 0 => Ok(Self::Fungible(a)), UncheckedFungibility::NonFungible(i) => Ok(Self::NonFungible(i)), @@ -559,7 +559,7 @@ impl MaxEncodedLen for Assets { } impl Decode for Assets { - fn decode(input: &mut I) -> Result { + fn decode(input: &mut I) -> Result { let bounded_instructions = BoundedVec::>::decode(input)?; Self::from_sorted_and_deduplicated(bounded_instructions.into_inner()) diff --git a/polkadot/xcm/src/v4/junction.rs b/polkadot/xcm/src/v4/junction.rs index 3ae97de5e9b8..36fb616d2dc5 100644 --- a/polkadot/xcm/src/v4/junction.rs +++ b/polkadot/xcm/src/v4/junction.rs @@ -23,7 +23,7 @@ use crate::{ VersionedLocation, }; use bounded_collections::{BoundedSlice, BoundedVec, ConstU32}; -use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; +use codec::{self, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use serde::{Deserialize, Serialize}; diff --git a/polkadot/xcm/src/v4/junctions.rs b/polkadot/xcm/src/v4/junctions.rs index 6d1af59e13dc..e5c54ecb21a5 100644 --- a/polkadot/xcm/src/v4/junctions.rs +++ b/polkadot/xcm/src/v4/junctions.rs @@ -18,8 +18,8 @@ use super::{Junction, Location, NetworkId}; use alloc::sync::Arc; +use codec::{Decode, Encode, MaxEncodedLen}; use core::{mem, ops::Range, result}; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// Maximum number of `Junction`s that a `Junctions` can contain. diff --git a/polkadot/xcm/src/v4/location.rs b/polkadot/xcm/src/v4/location.rs index cee76b689407..9e94d13626d6 100644 --- a/polkadot/xcm/src/v4/location.rs +++ b/polkadot/xcm/src/v4/location.rs @@ -18,8 +18,8 @@ use super::{traits::Reanchorable, Junction, Junctions}; use crate::{v3::MultiLocation as OldLocation, VersionedLocation}; +use codec::{Decode, Encode, MaxEncodedLen}; use core::result; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A relative path between state-bearing consensus systems. @@ -539,7 +539,7 @@ xcm_procedural::impl_conversion_functions_for_location_v4!(); #[cfg(test)] mod tests { use crate::v4::prelude::*; - use parity_scale_codec::{Decode, Encode}; + use codec::{Decode, Encode}; #[test] fn conversion_works() { diff --git a/polkadot/xcm/src/v4/mod.rs b/polkadot/xcm/src/v4/mod.rs index e1ca60087b19..57840562ba3e 100644 --- a/polkadot/xcm/src/v4/mod.rs +++ b/polkadot/xcm/src/v4/mod.rs @@ -24,12 +24,12 @@ use super::v3::{ use crate::DoubleEncoded; use alloc::{vec, vec::Vec}; use bounded_collections::{parameter_types, BoundedVec}; -use core::{fmt::Debug, result}; -use derivative::Derivative; -use parity_scale_codec::{ +use codec::{ self, decode_vec_with_len, Compact, Decode, Encode, Error as CodecError, Input as CodecInput, MaxEncodedLen, }; +use core::{fmt::Debug, result}; +use derivative::Derivative; use scale_info::TypeInfo; mod asset; diff --git a/polkadot/xcm/src/v4/traits.rs b/polkadot/xcm/src/v4/traits.rs index f6136c76d808..351de92c80ed 100644 --- a/polkadot/xcm/src/v4/traits.rs +++ b/polkadot/xcm/src/v4/traits.rs @@ -17,8 +17,8 @@ //! Cross-Consensus Message format data structures. pub use crate::v3::{Error, Result, SendError, XcmHash}; +use codec::{Decode, Encode}; use core::result; -use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; pub use sp_weights::Weight; @@ -161,7 +161,7 @@ pub type SendResult = result::Result<(T, Assets), SendError>; /// /// # Example /// ```rust -/// # use parity_scale_codec::Encode; +/// # use codec::Encode; /// # use staging_xcm::v4::{prelude::*, Weight}; /// # use staging_xcm::VersionedXcm; /// # use std::convert::Infallible; diff --git a/polkadot/xcm/xcm-builder/Cargo.toml b/polkadot/xcm/xcm-builder/Cargo.toml index 707e4aac7968..79c601b98b4f 100644 --- a/polkadot/xcm/xcm-builder/Cargo.toml +++ b/polkadot/xcm/xcm-builder/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] impl-trait-for-tuples = "0.2.1" -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } xcm = { package = "staging-xcm", path = "..", default-features = false } xcm-executor = { package = "staging-xcm-executor", path = "../xcm-executor", default-features = false } @@ -34,7 +34,7 @@ pallet-balances = { path = "../../../substrate/frame/balances" } pallet-xcm = { path = "../pallet-xcm" } pallet-salary = { path = "../../../substrate/frame/salary" } pallet-assets = { path = "../../../substrate/frame/assets" } -primitives = { package = "polkadot-primitives", path = "../../primitives" } +polkadot-primitives = { path = "../../primitives" } polkadot-runtime-parachains = { path = "../../runtime/parachains" } assert_matches = "1.5.0" polkadot-test-runtime = { path = "../../runtime/test-runtime" } @@ -49,18 +49,18 @@ runtime-benchmarks = [ "pallet-salary/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", "polkadot-test-runtime/runtime-benchmarks", - "primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-executor/runtime-benchmarks", ] std = [ + "codec/std", "frame-support/std", "frame-system/std", "log/std", "pallet-transaction-payment/std", - "parity-scale-codec/std", "polkadot-parachain-primitives/std", "scale-info/std", "sp-arithmetic/std", diff --git a/polkadot/xcm/xcm-builder/src/currency_adapter.rs b/polkadot/xcm/xcm-builder/src/currency_adapter.rs index 24261ac06583..99a736d6ac1f 100644 --- a/polkadot/xcm/xcm-builder/src/currency_adapter.rs +++ b/polkadot/xcm/xcm-builder/src/currency_adapter.rs @@ -51,7 +51,7 @@ impl From for XcmError { /// /// # Example /// ``` -/// use parity_scale_codec::Decode; +/// use codec::Decode; /// use frame_support::{parameter_types, PalletId}; /// use sp_runtime::traits::{AccountIdConversion, TrailingZeroInput}; /// use xcm::latest::prelude::*; diff --git a/polkadot/xcm/xcm-builder/src/location_conversion.rs b/polkadot/xcm/xcm-builder/src/location_conversion.rs index c9553030817a..f95258492381 100644 --- a/polkadot/xcm/xcm-builder/src/location_conversion.rs +++ b/polkadot/xcm/xcm-builder/src/location_conversion.rs @@ -15,8 +15,8 @@ // along with Polkadot. If not, see . use crate::universal_exports::ensure_is_remote; +use codec::{Compact, Decode, Encode}; use frame_support::traits::Get; -use parity_scale_codec::{Compact, Decode, Encode}; use sp_io::hashing::blake2_256; use sp_runtime::traits::{AccountIdConversion, TrailingZeroInput, TryConvert}; use sp_std::{marker::PhantomData, prelude::*}; @@ -460,7 +460,7 @@ impl #[cfg(test)] mod tests { use super::*; - use primitives::AccountId; + use polkadot_primitives::AccountId; pub type ForeignChainAliasAccount = HashedDescription; diff --git a/polkadot/xcm/xcm-builder/src/process_xcm_message.rs b/polkadot/xcm/xcm-builder/src/process_xcm_message.rs index 449cda3d2323..ef8c71fc2495 100644 --- a/polkadot/xcm/xcm-builder/src/process_xcm_message.rs +++ b/polkadot/xcm/xcm-builder/src/process_xcm_message.rs @@ -16,8 +16,8 @@ //! Implementation of `ProcessMessage` for an `ExecuteXcm` implementation. +use codec::{Decode, FullCodec, MaxEncodedLen}; use frame_support::traits::{ProcessMessage, ProcessMessageError}; -use parity_scale_codec::{Decode, FullCodec, MaxEncodedLen}; use scale_info::TypeInfo; use sp_std::{fmt::Debug, marker::PhantomData}; use sp_weights::{Weight, WeightMeter}; @@ -118,11 +118,11 @@ impl< #[cfg(test)] mod tests { use super::*; + use codec::Encode; use frame_support::{ assert_err, assert_ok, traits::{ProcessMessageError, ProcessMessageError::*}, }; - use parity_scale_codec::Encode; use polkadot_test_runtime::*; use xcm::{v3, v4, VersionedXcm}; diff --git a/polkadot/xcm/xcm-builder/src/routing.rs b/polkadot/xcm/xcm-builder/src/routing.rs index 5c284aaf1475..543aef97c340 100644 --- a/polkadot/xcm/xcm-builder/src/routing.rs +++ b/polkadot/xcm/xcm-builder/src/routing.rs @@ -16,8 +16,8 @@ //! Various implementations for `SendXcm`. +use codec::Encode; use frame_system::unique; -use parity_scale_codec::Encode; use sp_std::{marker::PhantomData, result::Result, vec::Vec}; use xcm::prelude::*; use xcm_executor::{traits::FeeReason, FeesMode}; diff --git a/polkadot/xcm/xcm-builder/src/tests/mock.rs b/polkadot/xcm/xcm-builder/src/tests/mock.rs index f45650ec5404..f35c73bdb685 100644 --- a/polkadot/xcm/xcm-builder/src/tests/mock.rs +++ b/polkadot/xcm/xcm-builder/src/tests/mock.rs @@ -26,6 +26,7 @@ pub use crate::{ AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, FixedRateOfFungible, FixedWeightBounds, TakeWeightCredit, }; +pub use codec::{Decode, Encode}; use frame_support::traits::{ContainsPair, Everything}; pub use frame_support::{ dispatch::{DispatchInfo, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, @@ -33,7 +34,6 @@ pub use frame_support::{ sp_runtime::{traits::Dispatchable, DispatchError, DispatchErrorWithPostInfo}, traits::{Contains, Get, IsInVec}, }; -pub use parity_scale_codec::{Decode, Encode}; pub use sp_std::{ cell::{Cell, RefCell}, collections::{btree_map::BTreeMap, btree_set::BTreeSet}, diff --git a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs index 076ff4184f0c..10e9f4c6c085 100644 --- a/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs +++ b/polkadot/xcm/xcm-builder/src/tests/pay/mock.rs @@ -25,8 +25,8 @@ use frame_support::{ traits::{ConstU32, Everything}, }; use frame_system::{EnsureRoot, EnsureSigned}; +use polkadot_primitives::{AccountIndex, BlakeTwo256, Signature}; use polkadot_test_runtime::SignedExtra; -use primitives::{AccountIndex, BlakeTwo256, Signature}; use sp_runtime::{generic, traits::MaybeEquivalence, AccountId32, BuildStorage}; use xcm_executor::{traits::ConvertLocation, XcmExecutor}; diff --git a/polkadot/xcm/xcm-builder/src/universal_exports.rs b/polkadot/xcm/xcm-builder/src/universal_exports.rs index 04ceb7e51688..9820d535f7ef 100644 --- a/polkadot/xcm/xcm-builder/src/universal_exports.rs +++ b/polkadot/xcm/xcm-builder/src/universal_exports.rs @@ -17,8 +17,8 @@ //! Traits and utilities to help with origin mutation and bridging. use crate::InspectMessageQueues; +use codec::{Decode, Encode}; use frame_support::{ensure, traits::Get}; -use parity_scale_codec::{Decode, Encode}; use sp_std::{convert::TryInto, marker::PhantomData, prelude::*}; use xcm::prelude::*; use xcm_executor::traits::{validate_export, ExportXcm}; diff --git a/polkadot/xcm/xcm-builder/src/weight.rs b/polkadot/xcm/xcm-builder/src/weight.rs index 6141b0142eed..1efa42ce9560 100644 --- a/polkadot/xcm/xcm-builder/src/weight.rs +++ b/polkadot/xcm/xcm-builder/src/weight.rs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use codec::Decode; use frame_support::{ dispatch::GetDispatchInfo, traits::{ @@ -25,7 +26,6 @@ use frame_support::{ WeightToFee as WeightToFeeT, }, }; -use parity_scale_codec::Decode; use sp_runtime::traits::{SaturatedConversion, Saturating, Zero}; use sp_std::{marker::PhantomData, result::Result}; use xcm::latest::{prelude::*, GetWeight, Weight}; diff --git a/polkadot/xcm/xcm-builder/tests/mock/mod.rs b/polkadot/xcm/xcm-builder/tests/mock/mod.rs index 7f7ff17e2115..62b448a9f430 100644 --- a/polkadot/xcm/xcm-builder/tests/mock/mod.rs +++ b/polkadot/xcm/xcm-builder/tests/mock/mod.rs @@ -14,13 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use codec::Encode; use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ConstU32, Everything, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; -use parity_scale_codec::Encode; use primitive_types::H256; use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage}; use sp_std::cell::RefCell; diff --git a/polkadot/xcm/xcm-executor/Cargo.toml b/polkadot/xcm/xcm-executor/Cargo.toml index 64b2d405b906..3b30b4f13e2d 100644 --- a/polkadot/xcm/xcm-executor/Cargo.toml +++ b/polkadot/xcm/xcm-executor/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] impl-trait-for-tuples = "0.2.2" environmental = { version = "1.1.4", default-features = false } -parity-scale-codec = { version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive", "serde"] } xcm = { package = "staging-xcm", path = "..", default-features = false } sp-std = { path = "../../../substrate/primitives/std", default-features = false } @@ -33,11 +33,11 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", ] std = [ + "codec/std", "environmental/std", "frame-benchmarking/std", "frame-support/std", "log/std", - "parity-scale-codec/std", "scale-info/std", "sp-arithmetic/std", "sp-core/std", diff --git a/polkadot/xcm/xcm-executor/src/lib.rs b/polkadot/xcm/xcm-executor/src/lib.rs index e0b8a8a9c73e..da9de93ca0f6 100644 --- a/polkadot/xcm/xcm-executor/src/lib.rs +++ b/polkadot/xcm/xcm-executor/src/lib.rs @@ -16,12 +16,12 @@ #![cfg_attr(not(feature = "std"), no_std)] +use codec::{Decode, Encode}; use frame_support::{ dispatch::GetDispatchInfo, ensure, traits::{Contains, ContainsPair, Defensive, Get, PalletsInfoAccess}, }; -use parity_scale_codec::{Decode, Encode}; use sp_core::defer; use sp_io::hashing::blake2_128; use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; diff --git a/polkadot/xcm/xcm-executor/src/traits/on_response.rs b/polkadot/xcm/xcm-executor/src/traits/on_response.rs index 1049bacdca5f..5d2412d61375 100644 --- a/polkadot/xcm/xcm-executor/src/traits/on_response.rs +++ b/polkadot/xcm/xcm-executor/src/traits/on_response.rs @@ -15,9 +15,9 @@ // along with Polkadot. If not, see . use crate::{Junctions::Here, Xcm}; +use codec::{Decode, Encode}; use core::result; use frame_support::{pallet_prelude::Get, parameter_types}; -use parity_scale_codec::{Decode, Encode}; use sp_arithmetic::traits::Zero; use sp_std::fmt::Debug; use xcm::latest::{ diff --git a/prdoc/pr_4633.prdoc b/prdoc/pr_4633.prdoc new file mode 100644 index 000000000000..f239191cc198 --- /dev/null +++ b/prdoc/pr_4633.prdoc @@ -0,0 +1,8 @@ +title: "Unify dependency aliases" + +doc: + - audience: [Runtime Dev, Node Dev] + description: | + Changes the re-export names of some crates but does not do any logic changes. + +crates: [ ] diff --git a/substrate/client/cli/Cargo.toml b/substrate/client/cli/Cargo.toml index 1f3bce799b2c..169ed72c96e4 100644 --- a/substrate/client/cli/Cargo.toml +++ b/substrate/client/cli/Cargo.toml @@ -25,7 +25,7 @@ itertools = "0.11" libp2p-identity = { version = "0.1.3", features = ["ed25519", "peerid"] } log = { workspace = true, default-features = true } names = { version = "0.14.0", default-features = false } -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } rand = "0.8.5" regex = "1.6.0" rpassword = "7.0.0" diff --git a/substrate/client/cli/src/commands/chain_info_cmd.rs b/substrate/client/cli/src/commands/chain_info_cmd.rs index 002d7893d9f3..8558c8a2d1cb 100644 --- a/substrate/client/cli/src/commands/chain_info_cmd.rs +++ b/substrate/client/cli/src/commands/chain_info_cmd.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use crate::{CliConfiguration, DatabaseParams, PruningParams, Result as CliResult, SharedParams}; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use sc_client_api::{backend::Backend as BackendT, blockchain::HeaderBackend}; use sp_blockchain::Info; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; diff --git a/substrate/client/cli/src/error.rs b/substrate/client/cli/src/error.rs index 90ad048009ad..90f936561512 100644 --- a/substrate/client/cli/src/error.rs +++ b/substrate/client/cli/src/error.rs @@ -42,7 +42,7 @@ pub enum Error { Client(#[from] sp_blockchain::Error), #[error(transparent)] - Codec(#[from] parity_scale_codec::Error), + Codec(#[from] codec::Error), #[error("Invalid input: {0}")] Input(String), diff --git a/substrate/client/consensus/beefy/Cargo.toml b/substrate/client/consensus/beefy/Cargo.toml index cd183f6bc8b0..f5528ec5931d 100644 --- a/substrate/client/consensus/beefy/Cargo.toml +++ b/substrate/client/consensus/beefy/Cargo.toml @@ -22,7 +22,7 @@ log = { workspace = true, default-features = true } parking_lot = "0.12.1" thiserror = { workspace = true } wasm-timer = "0.2.5" -prometheus = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus" } sc-client-api = { path = "../../api" } sc-consensus = { path = "../common" } sc-network = { path = "../../network" } diff --git a/substrate/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs b/substrate/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs index 350e7a271bc3..c473c14bccc3 100644 --- a/substrate/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs +++ b/substrate/client/consensus/beefy/src/communication/request_response/incoming_requests_handler.rs @@ -144,7 +144,7 @@ where genesis_hash: Hash, fork_id: Option<&str>, client: Arc, - prometheus_registry: Option, + prometheus_registry: Option, ) -> (Self, Network::RequestResponseProtocolConfig) { let (request_receiver, config): (_, Network::RequestResponseProtocolConfig) = on_demand_justifications_protocol_config::<_, _, Network>(genesis_hash, fork_id); diff --git a/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs b/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs index 4d40656375ec..e127e5a89590 100644 --- a/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs +++ b/substrate/client/consensus/beefy/src/communication/request_response/outgoing_requests_engine.rs @@ -85,7 +85,7 @@ impl OnDemandJustificationsEngine, protocol_name: ProtocolName, live_peers: Arc>>, - prometheus_registry: Option, + prometheus_registry: Option, ) -> Self { let metrics = register_metrics(prometheus_registry); Self { diff --git a/substrate/client/consensus/beefy/src/lib.rs b/substrate/client/consensus/beefy/src/lib.rs index 4cb014b00d5b..a47bfe1dbe24 100644 --- a/substrate/client/consensus/beefy/src/lib.rs +++ b/substrate/client/consensus/beefy/src/lib.rs @@ -34,7 +34,7 @@ use crate::{ use futures::{stream::Fuse, FutureExt, StreamExt}; use log::{debug, error, info, warn}; use parking_lot::Mutex; -use prometheus::Registry; +use prometheus_endpoint::Registry; use sc_client_api::{Backend, BlockBackend, BlockchainEvents, FinalityNotifications, Finalizer}; use sc_consensus::BlockImport; use sc_network::{NetworkRequest, NotificationService, ProtocolName}; diff --git a/substrate/client/consensus/beefy/src/metrics.rs b/substrate/client/consensus/beefy/src/metrics.rs index ef3928d79faa..30180fe43ec4 100644 --- a/substrate/client/consensus/beefy/src/metrics.rs +++ b/substrate/client/consensus/beefy/src/metrics.rs @@ -20,7 +20,7 @@ use crate::LOG_TARGET; use log::{debug, error}; -use prometheus::{register, Counter, Gauge, PrometheusError, Registry, U64}; +use prometheus_endpoint::{register, Counter, Gauge, PrometheusError, Registry, U64}; /// Helper trait for registering BEEFY metrics to Prometheus registry. pub(crate) trait PrometheusRegister: Sized { @@ -282,7 +282,7 @@ impl PrometheusRegister for OnDemandOutgoingRequestsMetrics { } pub(crate) fn register_metrics( - prometheus_registry: Option, + prometheus_registry: Option, ) -> Option { prometheus_registry.as_ref().map(T::register).and_then(|result| match result { Ok(metrics) => { diff --git a/substrate/client/consensus/grandpa/Cargo.toml b/substrate/client/consensus/grandpa/Cargo.toml index 9099761fbceb..b03a263ae0a3 100644 --- a/substrate/client/consensus/grandpa/Cargo.toml +++ b/substrate/client/consensus/grandpa/Cargo.toml @@ -25,7 +25,7 @@ finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } futures = "0.3.30" futures-timer = "3.0.1" log = { workspace = true, default-features = true } -parity-scale-codec = { version = "3.6.12", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["derive"] } parking_lot = "0.12.1" rand = "0.8.5" serde_json = { workspace = true, default-features = true } diff --git a/substrate/client/consensus/grandpa/rpc/Cargo.toml b/substrate/client/consensus/grandpa/rpc/Cargo.toml index d4e72baef3e7..a9437a9be075 100644 --- a/substrate/client/consensus/grandpa/rpc/Cargo.toml +++ b/substrate/client/consensus/grandpa/rpc/Cargo.toml @@ -17,7 +17,7 @@ finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } futures = "0.3.30" jsonrpsee = { version = "0.22.5", features = ["client-core", "macros", "server-core"] } log = { workspace = true, default-features = true } -parity-scale-codec = { version = "3.6.12", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", features = ["derive"] } serde = { features = ["derive"], workspace = true, default-features = true } thiserror = { workspace = true } sc-client-api = { path = "../../../api" } diff --git a/substrate/client/consensus/grandpa/rpc/src/lib.rs b/substrate/client/consensus/grandpa/rpc/src/lib.rs index 68de068c3058..430525019dfb 100644 --- a/substrate/client/consensus/grandpa/rpc/src/lib.rs +++ b/substrate/client/consensus/grandpa/rpc/src/lib.rs @@ -127,8 +127,8 @@ mod tests { use super::*; use std::{collections::HashSet, sync::Arc}; + use codec::{Decode, Encode}; use jsonrpsee::{core::EmptyServerParams as EmptyParams, types::SubscriptionId, RpcModule}; - use parity_scale_codec::{Decode, Encode}; use sc_block_builder::BlockBuilderBuilder; use sc_consensus_grandpa::{ report, AuthorityId, FinalityProof, GrandpaJustification, GrandpaJustificationSender, diff --git a/substrate/client/consensus/grandpa/rpc/src/notification.rs b/substrate/client/consensus/grandpa/rpc/src/notification.rs index 42b9123ed8c1..5bcf90f4d79d 100644 --- a/substrate/client/consensus/grandpa/rpc/src/notification.rs +++ b/substrate/client/consensus/grandpa/rpc/src/notification.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use parity_scale_codec::Encode; +use codec::Encode; use sc_consensus_grandpa::GrandpaJustification; use serde::{Deserialize, Serialize}; use sp_runtime::traits::Block as BlockT; diff --git a/substrate/client/consensus/grandpa/src/authorities.rs b/substrate/client/consensus/grandpa/src/authorities.rs index 623223e41eb8..2ac15d761b2e 100644 --- a/substrate/client/consensus/grandpa/src/authorities.rs +++ b/substrate/client/consensus/grandpa/src/authorities.rs @@ -20,10 +20,10 @@ use std::{cmp::Ord, fmt::Debug, ops::Add}; +use codec::{Decode, Encode}; use finality_grandpa::voter_set::VoterSet; use fork_tree::{FilterAction, ForkTree}; use log::debug; -use parity_scale_codec::{Decode, Encode}; use parking_lot::MappedMutexGuard; use sc_consensus::shared_data::{SharedData, SharedDataLocked}; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO}; @@ -662,9 +662,7 @@ pub struct PendingChange { } impl Decode for PendingChange { - fn decode( - value: &mut I, - ) -> Result { + fn decode(value: &mut I) -> Result { let next_authorities = Decode::decode(value)?; let delay = Decode::decode(value)?; let canon_height = Decode::decode(value)?; diff --git a/substrate/client/consensus/grandpa/src/aux_schema.rs b/substrate/client/consensus/grandpa/src/aux_schema.rs index 97a8bc660317..8ec882591be9 100644 --- a/substrate/client/consensus/grandpa/src/aux_schema.rs +++ b/substrate/client/consensus/grandpa/src/aux_schema.rs @@ -20,9 +20,9 @@ use std::fmt::Debug; +use codec::{Decode, Encode}; use finality_grandpa::round::State as RoundState; use log::{info, warn}; -use parity_scale_codec::{Decode, Encode}; use fork_tree::ForkTree; use sc_client_api::backend::AuxStore; diff --git a/substrate/client/consensus/grandpa/src/communication/gossip.rs b/substrate/client/consensus/grandpa/src/communication/gossip.rs index c7fe5a46a5eb..a6aa063357cb 100644 --- a/substrate/client/consensus/grandpa/src/communication/gossip.rs +++ b/substrate/client/consensus/grandpa/src/communication/gossip.rs @@ -86,8 +86,8 @@ //! We only send polite messages to peers, use ahash::{AHashMap, AHashSet}; +use codec::{Decode, DecodeAll, Encode}; use log::{debug, trace}; -use parity_scale_codec::{Decode, DecodeAll, Encode}; use prometheus_endpoint::{register, CounterVec, Opts, PrometheusError, Registry, U64}; use rand::seq::SliceRandom; use sc_network::ReputationChange; diff --git a/substrate/client/consensus/grandpa/src/communication/mod.rs b/substrate/client/consensus/grandpa/src/communication/mod.rs index cf78e1d4cf08..3b0ea2c5ee96 100644 --- a/substrate/client/consensus/grandpa/src/communication/mod.rs +++ b/substrate/client/consensus/grandpa/src/communication/mod.rs @@ -40,12 +40,12 @@ use std::{ time::Duration, }; +use codec::{Decode, DecodeAll, Encode}; use finality_grandpa::{ voter, voter_set::VoterSet, Message::{Precommit, Prevote, PrimaryPropose}, }; -use parity_scale_codec::{Decode, DecodeAll, Encode}; use sc_network::{NetworkBlock, NetworkSyncForkRequest, NotificationService, ReputationChange}; use sc_network_gossip::{GossipEngine, Network as GossipNetwork}; use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO}; diff --git a/substrate/client/consensus/grandpa/src/communication/tests.rs b/substrate/client/consensus/grandpa/src/communication/tests.rs index d7153a79ce0b..5d1562f05188 100644 --- a/substrate/client/consensus/grandpa/src/communication/tests.rs +++ b/substrate/client/consensus/grandpa/src/communication/tests.rs @@ -23,8 +23,8 @@ use super::{ Round, SetId, VoterSet, }; use crate::{communication::grandpa_protocol_name, environment::SharedVoterSetState}; +use codec::{DecodeAll, Encode}; use futures::prelude::*; -use parity_scale_codec::{DecodeAll, Encode}; use sc_network::{ config::{MultiaddrWithPeerId, Role}, event::Event as NetworkEvent, diff --git a/substrate/client/consensus/grandpa/src/environment.rs b/substrate/client/consensus/grandpa/src/environment.rs index 31df038044a4..6199e8a97d99 100644 --- a/substrate/client/consensus/grandpa/src/environment.rs +++ b/substrate/client/consensus/grandpa/src/environment.rs @@ -24,13 +24,13 @@ use std::{ time::Duration, }; +use codec::{Decode, Encode}; use finality_grandpa::{ round::State as RoundState, voter, voter_set::VoterSet, BlockNumberOps, Error as GrandpaError, }; use futures::prelude::*; use futures_timer::Delay; use log::{debug, warn}; -use parity_scale_codec::{Decode, Encode}; use parking_lot::RwLock; use prometheus_endpoint::{register, Counter, Gauge, PrometheusError, U64}; @@ -104,12 +104,10 @@ impl Encode for CompletedRounds { } } -impl parity_scale_codec::EncodeLike for CompletedRounds {} +impl codec::EncodeLike for CompletedRounds {} impl Decode for CompletedRounds { - fn decode( - value: &mut I, - ) -> Result { + fn decode(value: &mut I) -> Result { <(Vec>, SetId, Vec)>::decode(value) .map(|(rounds, set_id, voters)| CompletedRounds { rounds, set_id, voters }) } diff --git a/substrate/client/consensus/grandpa/src/finality_proof.rs b/substrate/client/consensus/grandpa/src/finality_proof.rs index 80b6249ade86..af965f2e4ae6 100644 --- a/substrate/client/consensus/grandpa/src/finality_proof.rs +++ b/substrate/client/consensus/grandpa/src/finality_proof.rs @@ -39,7 +39,7 @@ use log::{trace, warn}; use std::sync::Arc; -use parity_scale_codec::{Decode, Encode}; +use codec::{Decode, Encode}; use sc_client_api::backend::Backend; use sp_blockchain::{Backend as BlockchainBackend, HeaderBackend}; use sp_consensus_grandpa::GRANDPA_ENGINE_ID; diff --git a/substrate/client/consensus/grandpa/src/import.rs b/substrate/client/consensus/grandpa/src/import.rs index bc2983569c53..b594c0f678ce 100644 --- a/substrate/client/consensus/grandpa/src/import.rs +++ b/substrate/client/consensus/grandpa/src/import.rs @@ -18,8 +18,8 @@ use std::{collections::HashMap, marker::PhantomData, sync::Arc}; +use codec::Decode; use log::debug; -use parity_scale_codec::Decode; use sc_client_api::{backend::Backend, utils::is_descendent_of}; use sc_consensus::{ diff --git a/substrate/client/consensus/grandpa/src/justification.rs b/substrate/client/consensus/grandpa/src/justification.rs index a38cb113b40a..934c0d695fda 100644 --- a/substrate/client/consensus/grandpa/src/justification.rs +++ b/substrate/client/consensus/grandpa/src/justification.rs @@ -22,8 +22,8 @@ use std::{ sync::Arc, }; +use codec::{Decode, DecodeAll, Encode}; use finality_grandpa::{voter_set::VoterSet, Error as GrandpaError}; -use parity_scale_codec::{Decode, DecodeAll, Encode}; use sp_blockchain::{Error as ClientError, HeaderBackend}; use sp_consensus_grandpa::AuthorityId; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; diff --git a/substrate/client/consensus/grandpa/src/lib.rs b/substrate/client/consensus/grandpa/src/lib.rs index 03452bd07c75..a07dc035de35 100644 --- a/substrate/client/consensus/grandpa/src/lib.rs +++ b/substrate/client/consensus/grandpa/src/lib.rs @@ -56,9 +56,9 @@ #![warn(missing_docs)] +use codec::Decode; use futures::{prelude::*, StreamExt}; use log::{debug, error, info}; -use parity_scale_codec::Decode; use parking_lot::RwLock; use prometheus_endpoint::{PrometheusError, Registry}; use sc_client_api::{ diff --git a/substrate/client/consensus/grandpa/src/warp_proof.rs b/substrate/client/consensus/grandpa/src/warp_proof.rs index 7169a424c14a..c836ab09fd5d 100644 --- a/substrate/client/consensus/grandpa/src/warp_proof.rs +++ b/substrate/client/consensus/grandpa/src/warp_proof.rs @@ -16,7 +16,7 @@ //! Utilities for generating and verifying GRANDPA warp sync proofs. -use parity_scale_codec::{Decode, DecodeAll, Encode}; +use codec::{Decode, DecodeAll, Encode}; use crate::{ best_justification, find_scheduled_change, AuthoritySetChanges, AuthoritySetHardFork, @@ -38,7 +38,7 @@ use std::{collections::HashMap, sync::Arc}; pub enum Error { /// Decoding error. #[error("Failed to decode block hash: {0}.")] - DecodeScale(#[from] parity_scale_codec::Error), + DecodeScale(#[from] codec::Error), /// Client backend error. #[error("{0}")] Client(#[from] sp_blockchain::Error), @@ -320,7 +320,7 @@ where mod tests { use super::WarpSyncProof; use crate::{AuthoritySetChanges, GrandpaJustification}; - use parity_scale_codec::Encode; + use codec::Encode; use rand::prelude::*; use sc_block_builder::BlockBuilderBuilder; use sp_blockchain::HeaderBackend; diff --git a/substrate/client/service/test/Cargo.toml b/substrate/client/service/test/Cargo.toml index e95e06cee267..3c7542313952 100644 --- a/substrate/client/service/test/Cargo.toml +++ b/substrate/client/service/test/Cargo.toml @@ -20,7 +20,7 @@ array-bytes = "6.2.2" fdlimit = "0.3.0" futures = "0.3.30" log = { workspace = true, default-features = true } -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } parking_lot = "0.12.1" tempfile = "3.1.0" tokio = { version = "1.22.0", features = ["time"] } diff --git a/substrate/client/service/test/src/client/mod.rs b/substrate/client/service/test/src/client/mod.rs index 6542830c998b..bd48fae63444 100644 --- a/substrate/client/service/test/src/client/mod.rs +++ b/substrate/client/service/test/src/client/mod.rs @@ -17,8 +17,8 @@ // along with this program. If not, see . use async_channel::TryRecvError; +use codec::{Decode, Encode, Joiner}; use futures::executor::block_on; -use parity_scale_codec::{Decode, Encode, Joiner}; use sc_block_builder::BlockBuilderBuilder; use sc_client_api::{ in_mem, BlockBackend, BlockchainEvents, ExecutorProvider, FinalityNotifications, HeaderBackend, diff --git a/substrate/frame/Cargo.toml b/substrate/frame/Cargo.toml index 3942f06ce6ee..a3b3d1900e6e 100644 --- a/substrate/frame/Cargo.toml +++ b/substrate/frame/Cargo.toml @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # external deps -parity-scale-codec = { version = "3.6.12", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [ "derive", ] } scale-info = { version = "2.11.1", default-features = false, features = [ @@ -83,6 +83,7 @@ runtime = [ "frame-system-rpc-runtime-api", ] std = [ + "codec/std", "frame-benchmarking?/std", "frame-executive?/std", "frame-support/std", @@ -91,7 +92,6 @@ std = [ "frame-system/std", "frame-try-runtime?/std", "log/std", - "parity-scale-codec/std", "scale-info/std", "sp-api?/std", "sp-arithmetic/std", diff --git a/substrate/frame/contracts/uapi/Cargo.toml b/substrate/frame/contracts/uapi/Cargo.toml index 80de7a1d5d69..e19caa460419 100644 --- a/substrate/frame/contracts/uapi/Cargo.toml +++ b/substrate/frame/contracts/uapi/Cargo.toml @@ -15,7 +15,7 @@ workspace = true paste = { version = "1.0", default-features = false } bitflags = "1.0" scale-info = { version = "2.11.1", default-features = false, features = ["derive"], optional = true } -scale = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [ "derive", "max-encoded-len", ], optional = true } @@ -28,4 +28,4 @@ default-target = ["wasm32-unknown-unknown"] [features] default = ["scale"] -scale = ["dep:scale", "scale-info"] +scale = ["dep:codec", "scale-info"] diff --git a/substrate/frame/contracts/uapi/src/flags.rs b/substrate/frame/contracts/uapi/src/flags.rs index 32553817fb7a..e82b8861e36c 100644 --- a/substrate/frame/contracts/uapi/src/flags.rs +++ b/substrate/frame/contracts/uapi/src/flags.rs @@ -19,7 +19,7 @@ use bitflags::bitflags; bitflags! { /// Flags used by a contract to customize exit behaviour. - #[cfg_attr(feature = "scale", derive(scale::Encode, scale::Decode, scale_info::TypeInfo))] + #[cfg_attr(feature = "scale", derive(codec::Encode, codec::Decode, scale_info::TypeInfo))] pub struct ReturnFlags: u32 { /// If this bit is set all changes made by the contract execution are rolled back. const REVERT = 0x0000_0001; diff --git a/substrate/frame/election-provider-support/solution-type/Cargo.toml b/substrate/frame/election-provider-support/solution-type/Cargo.toml index 3f8893dad6f2..0b631bd7bb03 100644 --- a/substrate/frame/election-provider-support/solution-type/Cargo.toml +++ b/substrate/frame/election-provider-support/solution-type/Cargo.toml @@ -24,7 +24,7 @@ proc-macro2 = "1.0.56" proc-macro-crate = "3.0.0" [dev-dependencies] -parity-scale-codec = "3.6.12" +codec = { package = "parity-scale-codec", version = "3.6.12" } scale-info = "2.11.1" sp-arithmetic = { path = "../../../primitives/arithmetic" } # used by generate_solution_type: diff --git a/substrate/frame/grandpa/Cargo.toml b/substrate/frame/grandpa/Cargo.toml index 302ce327aed4..37048b06608f 100644 --- a/substrate/frame/grandpa/Cargo.toml +++ b/substrate/frame/grandpa/Cargo.toml @@ -34,7 +34,7 @@ sp-staking = { path = "../../primitives/staking", default-features = false, feat sp-std = { path = "../../primitives/std", default-features = false } [dev-dependencies] -grandpa = { package = "finality-grandpa", version = "0.16.2", features = ["derive-codec"] } +finality-grandpa = { version = "0.16.2", features = ["derive-codec"] } frame-benchmarking = { path = "../benchmarking" } frame-election-provider-support = { path = "../election-provider-support" } pallet-balances = { path = "../balances" } diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 2d54f525b1f0..38b5536bc598 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -20,8 +20,8 @@ #![cfg(test)] use crate::{self as pallet_grandpa, AuthorityId, AuthorityList, Config, ConsensusLog}; -use ::grandpa as finality_grandpa; use codec::Encode; +use finality_grandpa; use frame_election_provider_support::{ bounds::{ElectionBounds, ElectionBoundsBuilder}, onchain, SequentialPhragmen, diff --git a/substrate/frame/sassafras/Cargo.toml b/substrate/frame/sassafras/Cargo.toml index 82fb9a1d8c5f..2105ba133147 100644 --- a/substrate/frame/sassafras/Cargo.toml +++ b/substrate/frame/sassafras/Cargo.toml @@ -17,7 +17,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -scale-codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } frame-benchmarking = { path = "../benchmarking", default-features = false, optional = true } frame-support = { path = "../support", default-features = false } @@ -36,11 +36,11 @@ sp-crypto-hashing = { path = "../../primitives/crypto/hashing" } [features] default = ["std"] std = [ + "codec/std", "frame-benchmarking?/std", "frame-support/std", "frame-system/std", "log/std", - "scale-codec/std", "scale-info/std", "sp-consensus-sassafras/std", "sp-io/std", diff --git a/substrate/frame/sassafras/src/lib.rs b/substrate/frame/sassafras/src/lib.rs index 8cbf1e47e320..d521ed9dd91b 100644 --- a/substrate/frame/sassafras/src/lib.rs +++ b/substrate/frame/sassafras/src/lib.rs @@ -47,8 +47,8 @@ #![warn(unused_must_use, unsafe_code, unused_variables, unused_imports, missing_docs)] #![cfg_attr(not(feature = "std"), no_std)] +use codec::{Decode, Encode, MaxEncodedLen}; use log::{debug, error, trace, warn}; -use scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use frame_support::{ diff --git a/substrate/frame/src/lib.rs b/substrate/frame/src/lib.rs index f6507cd02c71..e41f7f1c0ef3 100644 --- a/substrate/frame/src/lib.rs +++ b/substrate/frame/src/lib.rs @@ -316,11 +316,11 @@ pub mod primitives { /// /// This is already part of the [`prelude`]. pub mod derive { + pub use codec::{Decode, Encode}; pub use frame_support::{ CloneNoBound, DebugNoBound, DefaultNoBound, EqNoBound, OrdNoBound, PartialEqNoBound, PartialOrdNoBound, RuntimeDebugNoBound, }; - pub use parity_scale_codec::{Decode, Encode}; pub use scale_info::TypeInfo; pub use sp_runtime::RuntimeDebug; pub use sp_std::fmt::Debug; @@ -345,7 +345,7 @@ pub mod deps { pub use sp_runtime; pub use sp_std; - pub use parity_scale_codec as codec; + pub use codec; pub use scale_info; #[cfg(feature = "runtime")] diff --git a/substrate/frame/support/test/compile_pass/Cargo.toml b/substrate/frame/support/test/compile_pass/Cargo.toml index 37c069247e18..d6e0c66261a9 100644 --- a/substrate/frame/support/test/compile_pass/Cargo.toml +++ b/substrate/frame/support/test/compile_pass/Cargo.toml @@ -17,8 +17,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } -renamed-frame-support = { package = "frame-support", path = "../..", default-features = false } -renamed-frame-system = { package = "frame-system", path = "../../../system", default-features = false } +frame-support = { path = "../..", default-features = false } +frame-system = { path = "../../../system", default-features = false } sp-core = { path = "../../../../primitives/core", default-features = false } sp-runtime = { path = "../../../../primitives/runtime", default-features = false } sp-version = { path = "../../../../primitives/version", default-features = false } @@ -27,8 +27,8 @@ sp-version = { path = "../../../../primitives/version", default-features = false default = ["std"] std = [ "codec/std", - "renamed-frame-support/std", - "renamed-frame-system/std", + "frame-support/std", + "frame-system/std", "scale-info/std", "sp-core/std", "sp-runtime/std", diff --git a/substrate/frame/support/test/compile_pass/src/lib.rs b/substrate/frame/support/test/compile_pass/src/lib.rs index 07d2f7d9ecdb..37af683fbc7f 100644 --- a/substrate/frame/support/test/compile_pass/src/lib.rs +++ b/substrate/frame/support/test/compile_pass/src/lib.rs @@ -21,7 +21,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use renamed_frame_support::{ +use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ConstU16, ConstU32, ConstU64, Everything}, }; @@ -51,8 +51,8 @@ parameter_types! { pub const Version: RuntimeVersion = VERSION; } -#[derive_impl(renamed_frame_system::config_preludes::TestDefaultConfig)] -impl renamed_frame_system::Config for Runtime { +#[derive_impl(frame_system::config_preludes::TestDefaultConfig)] +impl frame_system::Config for Runtime { type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); @@ -84,6 +84,6 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// A GRANDPA message for a substrate chain. -pub type Message
= grandpa::Message<
::Hash,
::Number>; +pub type Message
= + finality_grandpa::Message<
::Hash,
::Number>; /// A signed message. -pub type SignedMessage
= grandpa::SignedMessage< +pub type SignedMessage
= finality_grandpa::SignedMessage<
::Hash,
::Number, AuthoritySignature, @@ -89,21 +90,22 @@ pub type SignedMessage
= grandpa::SignedMessage< /// A primary propose message for this chain's block type. pub type PrimaryPropose
= - grandpa::PrimaryPropose<
::Hash,
::Number>; + finality_grandpa::PrimaryPropose<
::Hash,
::Number>; /// A prevote message for this chain's block type. -pub type Prevote
= grandpa::Prevote<
::Hash,
::Number>; +pub type Prevote
= + finality_grandpa::Prevote<
::Hash,
::Number>; /// A precommit message for this chain's block type. pub type Precommit
= - grandpa::Precommit<
::Hash,
::Number>; + finality_grandpa::Precommit<
::Hash,
::Number>; /// A catch up message for this chain's block type. -pub type CatchUp
= grandpa::CatchUp< +pub type CatchUp
= finality_grandpa::CatchUp<
::Hash,
::Number, AuthoritySignature, AuthorityId, >; /// A commit message for this chain's block type. -pub type Commit
= grandpa::Commit< +pub type Commit
= finality_grandpa::Commit<
::Hash,
::Number, AuthoritySignature, @@ -111,7 +113,7 @@ pub type Commit
= grandpa::Commit< >; /// A compact commit message for this chain's block type. -pub type CompactCommit
= grandpa::CompactCommit< +pub type CompactCommit
= finality_grandpa::CompactCommit<
::Hash,
::Number, AuthoritySignature, @@ -266,18 +268,36 @@ impl EquivocationProof { #[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)] pub enum Equivocation { /// Proof of equivocation at prevote stage. - Prevote(grandpa::Equivocation, AuthoritySignature>), + Prevote( + finality_grandpa::Equivocation< + AuthorityId, + finality_grandpa::Prevote, + AuthoritySignature, + >, + ), /// Proof of equivocation at precommit stage. - Precommit(grandpa::Equivocation, AuthoritySignature>), + Precommit( + finality_grandpa::Equivocation< + AuthorityId, + finality_grandpa::Precommit, + AuthoritySignature, + >, + ), } -impl From, AuthoritySignature>> - for Equivocation +impl + From< + finality_grandpa::Equivocation< + AuthorityId, + finality_grandpa::Prevote, + AuthoritySignature, + >, + > for Equivocation { fn from( - equivocation: grandpa::Equivocation< + equivocation: finality_grandpa::Equivocation< AuthorityId, - grandpa::Prevote, + finality_grandpa::Prevote, AuthoritySignature, >, ) -> Self { @@ -285,13 +305,19 @@ impl From, Autho } } -impl From, AuthoritySignature>> - for Equivocation +impl + From< + finality_grandpa::Equivocation< + AuthorityId, + finality_grandpa::Precommit, + AuthoritySignature, + >, + > for Equivocation { fn from( - equivocation: grandpa::Equivocation< + equivocation: finality_grandpa::Equivocation< AuthorityId, - grandpa::Precommit, + finality_grandpa::Precommit, AuthoritySignature, >, ) -> Self { @@ -358,10 +384,10 @@ where match report.equivocation { Equivocation::Prevote(equivocation) => { - check!(equivocation, grandpa::Message::Prevote); + check!(equivocation, finality_grandpa::Message::Prevote); }, Equivocation::Precommit(equivocation) => { - check!(equivocation, grandpa::Message::Precommit); + check!(equivocation, finality_grandpa::Message::Precommit); }, } } @@ -389,7 +415,7 @@ pub fn localized_payload_with_buffer( /// Check a message signature by encoding the message as a localized payload and /// verifying the provided signature using the expected authority id. pub fn check_message_signature( - message: &grandpa::Message, + message: &finality_grandpa::Message, id: &AuthorityId, signature: &AuthoritySignature, round: RoundNumber, @@ -407,7 +433,7 @@ where /// The encoding necessary to verify the signature will be done using the given /// buffer, the original content of the buffer will be cleared. pub fn check_message_signature_with_buffer( - message: &grandpa::Message, + message: &finality_grandpa::Message, id: &AuthorityId, signature: &AuthoritySignature, round: RoundNumber, @@ -437,11 +463,11 @@ where #[cfg(feature = "std")] pub fn sign_message( keystore: KeystorePtr, - message: grandpa::Message, + message: finality_grandpa::Message, public: AuthorityId, round: RoundNumber, set_id: SetId, -) -> Option> +) -> Option> where H: Encode, N: Encode, @@ -456,7 +482,7 @@ where .try_into() .ok()?; - Some(grandpa::SignedMessage { message, signature, id: public }) + Some(finality_grandpa::SignedMessage { message, signature, id: public }) } /// An opaque type used to represent the key ownership proof at the runtime API diff --git a/substrate/primitives/consensus/sassafras/Cargo.toml b/substrate/primitives/consensus/sassafras/Cargo.toml index c8eb9b76b93b..792755730839 100644 --- a/substrate/primitives/consensus/sassafras/Cargo.toml +++ b/substrate/primitives/consensus/sassafras/Cargo.toml @@ -18,7 +18,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -scale-codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } serde = { features = ["derive"], optional = true, workspace = true } sp-api = { path = "../../api", default-features = false } @@ -30,7 +30,7 @@ sp-runtime = { path = "../../runtime", default-features = false } [features] default = ["std"] std = [ - "scale-codec/std", + "codec/std", "scale-info/std", "serde/std", "sp-api/std", diff --git a/substrate/primitives/consensus/sassafras/src/digests.rs b/substrate/primitives/consensus/sassafras/src/digests.rs index 64190a41ce1c..bac31f57f2da 100644 --- a/substrate/primitives/consensus/sassafras/src/digests.rs +++ b/substrate/primitives/consensus/sassafras/src/digests.rs @@ -22,7 +22,7 @@ use crate::{ EpochConfiguration, Randomness, Slot, SASSAFRAS_ENGINE_ID, }; -use scale_codec::{Decode, Encode, MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; #[cfg(not(feature = "std"))] diff --git a/substrate/primitives/consensus/sassafras/src/lib.rs b/substrate/primitives/consensus/sassafras/src/lib.rs index c1fea74d0452..d7880c4de9e8 100644 --- a/substrate/primitives/consensus/sassafras/src/lib.rs +++ b/substrate/primitives/consensus/sassafras/src/lib.rs @@ -24,7 +24,7 @@ extern crate alloc; use alloc::vec::Vec; -use scale_codec::{Decode, Encode, MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_core::crypto::KeyTypeId; use sp_runtime::{ConsensusEngineId, RuntimeDebug}; diff --git a/substrate/primitives/consensus/sassafras/src/ticket.rs b/substrate/primitives/consensus/sassafras/src/ticket.rs index 345de99be28d..fd025f1d53ea 100644 --- a/substrate/primitives/consensus/sassafras/src/ticket.rs +++ b/substrate/primitives/consensus/sassafras/src/ticket.rs @@ -18,7 +18,7 @@ //! Primitives related to tickets. use crate::vrf::RingVrfSignature; -use scale_codec::{Decode, Encode, MaxEncodedLen}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; pub use sp_core::ed25519::{Public as EphemeralPublic, Signature as EphemeralSignature}; diff --git a/substrate/primitives/consensus/sassafras/src/vrf.rs b/substrate/primitives/consensus/sassafras/src/vrf.rs index 537cff52ab6f..f8def1b5f189 100644 --- a/substrate/primitives/consensus/sassafras/src/vrf.rs +++ b/substrate/primitives/consensus/sassafras/src/vrf.rs @@ -20,7 +20,7 @@ use crate::{Randomness, TicketBody, TicketId}; #[cfg(not(feature = "std"))] use alloc::vec::Vec; -use scale_codec::Encode; +use codec::Encode; use sp_consensus_slots::Slot; pub use sp_core::bandersnatch::{ diff --git a/templates/minimal/runtime/Cargo.toml b/templates/minimal/runtime/Cargo.toml index ab6a48b73f3c..42ea49ff4046 100644 --- a/templates/minimal/runtime/Cargo.toml +++ b/templates/minimal/runtime/Cargo.toml @@ -10,7 +10,7 @@ edition.workspace = true publish = false [dependencies] -parity-scale-codec = { version = "3.6.12", default-features = false } +codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false } scale-info = { version = "2.6.0", default-features = false } # this is a frame-based runtime, thus importing `frame` with runtime feature enabled. @@ -39,7 +39,7 @@ substrate-wasm-builder = { path = "../../../substrate/utils/wasm-builder", optio [features] default = ["std"] std = [ - "parity-scale-codec/std", + "codec/std", "scale-info/std", "frame/std", diff --git a/templates/parachain/node/Cargo.toml b/templates/parachain/node/Cargo.toml index 94873cf1faea..1737c6a9df75 100644 --- a/templates/parachain/node/Cargo.toml +++ b/templates/parachain/node/Cargo.toml @@ -56,7 +56,7 @@ sp-io = { path = "../../../substrate/primitives/io" } sp-runtime = { path = "../../../substrate/primitives/runtime" } sp-timestamp = { path = "../../../substrate/primitives/timestamp" } substrate-frame-rpc-system = { path = "../../../substrate/utils/frame/rpc/system" } -substrate-prometheus-endpoint = { path = "../../../substrate/utils/prometheus" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../substrate/utils/prometheus" } # Polkadot polkadot-cli = { path = "../../../polkadot/cli", features = ["rococo-native"] } diff --git a/templates/parachain/node/src/service.rs b/templates/parachain/node/src/service.rs index ce6308915871..587dd19faf3e 100644 --- a/templates/parachain/node/src/service.rs +++ b/templates/parachain/node/src/service.rs @@ -28,6 +28,7 @@ use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; // Substrate Imports use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; +use prometheus_endpoint::Registry; use sc_client_api::Backend; use sc_consensus::ImportQueue; use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; @@ -37,7 +38,6 @@ use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, Ta use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_keystore::KeystorePtr; -use substrate_prometheus_endpoint::Registry; #[docify::export(wasm_executor)] type ParachainExecutor = WasmExecutor;