From ae35e6553fb3cf21c31dfd7bd704407dd7b7fbb2 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Wed, 30 Oct 2024 17:23:40 +0100 Subject: [PATCH] chore(deps): move to polkadot-sdk umbrella crate (#926) --- Cargo.lock | 7 +------ Cargo.toml | 7 +------ src/commands/dry_run.rs | 2 +- src/commands/monitor.rs | 11 +++++++---- src/epm.rs | 13 ++++++++----- src/helpers.rs | 2 +- src/opt.rs | 5 ++--- src/prelude.rs | 12 ++++++------ src/prometheus.rs | 2 +- src/static_types.rs | 13 ++++++++----- 10 files changed, 36 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e34c613d4..5e85c0a4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7046,25 +7046,20 @@ dependencies = [ "anyhow", "assert_cmd", "clap", - "frame-election-provider-support", - "frame-support", "futures", "hyper", "jsonrpsee", "log", "once_cell", - "pallet-election-provider-multi-phase", "parity-scale-codec", "pin-project-lite", + "polkadot-sdk", "prometheus", "regex", "scale-info", "scale-value", "serde", "serde_json", - "sp-npos-elections", - "sp-runtime", - "sp-storage", "subxt", "thiserror", "tokio", diff --git a/Cargo.toml b/Cargo.toml index f3a6b87f0..b534115a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,11 +28,7 @@ scale-value = "0.17" subxt = { version = "0.38.0", features = ["substrate-compat"] } # polkadot-sdk -frame-election-provider-support = "38.0.0" -pallet-election-provider-multi-phase = "37.0.0" -sp-npos-elections = "34.0.0" -frame-support = "38.0.0" -sp-runtime = "39.0.2" +polkadot-sdk = { version = "0.7", features = ["frame-election-provider-support", "frame-support", "sp-npos-elections", "sp-runtime", "pallet-election-provider-multi-phase"] } # prometheus prometheus = "0.13" @@ -42,5 +38,4 @@ once_cell = "1.20" [dev-dependencies] anyhow = "1" assert_cmd = "2.0" -sp-storage = "21.0.0" regex = "1" diff --git a/src/commands/dry_run.rs b/src/commands/dry_run.rs index f2a72bb09..9c2115284 100644 --- a/src/commands/dry_run.rs +++ b/src/commands/dry_run.rs @@ -16,7 +16,7 @@ //! The dry-run command. -use pallet_election_provider_multi_phase::RawSolution; +use polkadot_sdk::pallet_election_provider_multi_phase::RawSolution; use subxt::config::DefaultExtrinsicParamsBuilder; use crate::{ diff --git a/src/commands/monitor.rs b/src/commands/monitor.rs index 7de269beb..756fc19e4 100644 --- a/src/commands/monitor.rs +++ b/src/commands/monitor.rs @@ -27,11 +27,14 @@ use crate::{ }; use clap::Parser; use codec::{Decode, Encode}; -use frame_election_provider_support::NposSolution; use futures::future::TryFutureExt; use jsonrpsee::core::ClientError as JsonRpseeError; -use pallet_election_provider_multi_phase::{RawSolution, SolutionOf}; -use sp_runtime::Perbill; +use polkadot_sdk::{ + frame_election_provider_support::NposSolution, + pallet_election_provider_multi_phase::{RawSolution, SolutionOf}, + sp_npos_elections, + sp_runtime::Perbill, +}; use std::{str::FromStr, sync::Arc}; use subxt::{ backend::{legacy::rpc_methods::DryRunResult, rpc::RpcSubscription}, @@ -458,7 +461,7 @@ where /// Ensure that now is the signed phase. async fn ensure_signed_phase(api: &ChainClient, block_hash: Hash) -> Result<(), Error> { - use pallet_election_provider_multi_phase::Phase; + use polkadot_sdk::pallet_election_provider_multi_phase::Phase; let addr = runtime::storage().election_provider_multi_phase().current_phase(); let phase = api.storage().at(block_hash).fetch(&addr).await?; diff --git a/src/epm.rs b/src/epm.rs index 6cf56149d..93bcdfca1 100644 --- a/src/epm.rs +++ b/src/epm.rs @@ -32,14 +32,17 @@ use std::{ }; use codec::{Decode, Encode}; -use frame_election_provider_support::{Get, NposSolution, PhragMMS, SequentialPhragmen}; -use frame_support::{weights::Weight, BoundedVec}; -use pallet_election_provider_multi_phase::{ - unsigned::TrimmingStatus, RawSolution, ReadySolution, SolutionOf, SolutionOrSnapshotSize, +use polkadot_sdk::{ + frame_election_provider_support::{self, Get, NposSolution, PhragMMS, SequentialPhragmen}, + frame_support::{weights::Weight, BoundedVec}, + pallet_election_provider_multi_phase::{ + self, unsigned::TrimmingStatus, MinerConfig, RawSolution, ReadySolution, SolutionOf, + SolutionOrSnapshotSize, + }, + sp_npos_elections::{ElectionScore, VoteWeight}, }; use scale_info::{PortableRegistry, TypeInfo}; use scale_value::scale::decode_as_type; -use sp_npos_elections::{ElectionScore, VoteWeight}; use subxt::{dynamic::Value, tx::DynamicPayload}; const EPM_PALLET_NAME: &str = "ElectionProviderMultiPhase"; diff --git a/src/helpers.rs b/src/helpers.rs index 441702588..53c320d2e 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -16,9 +16,9 @@ use crate::{error::Error, prelude::*}; use codec::Decode; -use frame_support::weights::Weight; use jsonrpsee::core::ClientError as JsonRpseeError; use pin_project_lite::pin_project; +use polkadot_sdk::frame_support::weights::Weight; use serde::Deserialize; use std::{ future::Future, diff --git a/src/opt.rs b/src/opt.rs index 86a819428..94146f424 100644 --- a/src/opt.rs +++ b/src/opt.rs @@ -17,9 +17,8 @@ use crate::error::Error; use clap::*; -use serde::{Deserialize, Serialize}; -use sp_npos_elections::BalancingConfig; -use sp_runtime::DeserializeOwned; +use polkadot_sdk::{frame_support, sp_npos_elections::BalancingConfig}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{collections::HashMap, fmt, str::FromStr}; use subxt::backend::legacy::rpc_methods as subxt_rpc; diff --git a/src/prelude.rs b/src/prelude.rs index 69ad4699e..6c55f8ae6 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -21,10 +21,10 @@ //! needing to sprinkle `any_runtime` in a few extra places. // re-exports. -pub use pallet_election_provider_multi_phase::{Miner, MinerConfig}; +pub use polkadot_sdk::pallet_election_provider_multi_phase::{Miner, MinerConfig}; pub use subxt::ext::sp_core; /// The account id type. -pub type AccountId = sp_runtime::AccountId32; +pub type AccountId = polkadot_sdk::sp_runtime::AccountId32; /// The header type. We re-export it here, but we can easily get it from block as well. pub type Header = subxt::config::substrate::SubstrateHeader; @@ -47,7 +47,7 @@ pub const LOG_TARGET: &str = "polkadot-staking-miner"; pub type Pair = sp_core::sr25519::Pair; /// The accuracy that we use for election computation. -pub type Accuracy = sp_runtime::Perbill; +pub type Accuracy = polkadot_sdk::sp_runtime::Perbill; pub type RpcClient = subxt::backend::legacy::LegacyRpcMethods; /// Subxt client used by the staking miner on all chains. @@ -58,7 +58,7 @@ pub type Config = subxt::PolkadotConfig; /// Submission type used by the staking miner. pub type SignedSubmission = - pallet_election_provider_multi_phase::SignedSubmission; + polkadot_sdk::pallet_election_provider_multi_phase::SignedSubmission; #[subxt::subxt( runtime_metadata_path = "artifacts/metadata.scale", @@ -69,11 +69,11 @@ pub type SignedSubmission = ), substitute_type( path = "sp_npos_elections::ElectionScore", - with = "::subxt::utils::Static<::sp_npos_elections::ElectionScore>" + with = "::subxt::utils::Static" ), substitute_type( path = "pallet_election_provider_multi_phase::Phase", - with = "::subxt::utils::Static<::pallet_election_provider_multi_phase::Phase>" + with = "::subxt::utils::Static>" ) )] pub mod runtime {} diff --git a/src/prometheus.rs b/src/prometheus.rs index 18ce0376d..2636d5419 100644 --- a/src/prometheus.rs +++ b/src/prometheus.rs @@ -85,8 +85,8 @@ pub fn run(port: u16) -> Result { } mod hidden { - use frame_election_provider_support::Weight; use once_cell::sync::Lazy; + use polkadot_sdk::{frame_election_provider_support::Weight, sp_npos_elections}; use prometheus::{opts, register_counter, register_gauge, Counter, Gauge}; static TRIMMED_SOLUTION_STARTED: Lazy = Lazy::new(|| { diff --git a/src/static_types.rs b/src/static_types.rs index 00454c1d6..73e02f441 100644 --- a/src/static_types.rs +++ b/src/static_types.rs @@ -15,9 +15,12 @@ // along with Polkadot. If not, see . use crate::{epm, prelude::*}; -use frame_election_provider_support::traits::NposSolution; -use frame_support::{traits::ConstU32, weights::Weight}; -use pallet_election_provider_multi_phase::{RawSolution, SolutionOrSnapshotSize}; +use polkadot_sdk::{ + frame_election_provider_support::{self, traits::NposSolution}, + frame_support::{self, traits::ConstU32, weights::Weight}, + pallet_election_provider_multi_phase::{self, RawSolution, SolutionOrSnapshotSize}, + sp_runtime, +}; macro_rules! impl_atomic_u32_parameter_types { ($mod:ident, $name:ident) => { @@ -34,7 +37,7 @@ macro_rules! impl_atomic_u32_parameter_types { } } - impl> frame_support::traits::Get for $name { + impl> polkadot_sdk::frame_support::traits::Get for $name { fn get() -> I { I::from(Self::get()) } @@ -52,7 +55,7 @@ macro_rules! impl_atomic_u32_parameter_types { } mod max_weight { - use frame_support::weights::Weight; + use polkadot_sdk::frame_support::{self, weights::Weight}; use std::sync::atomic::{AtomicU64, Ordering}; static REF_TIME: AtomicU64 = AtomicU64::new(0);