Skip to content

Commit

Permalink
chore(deps): move to polkadot-sdk umbrella crate (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 authored Oct 30, 2024
1 parent 15d7121 commit ae35e65
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 38 deletions.
7 changes: 1 addition & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -42,5 +38,4 @@ once_cell = "1.20"
[dev-dependencies]
anyhow = "1"
assert_cmd = "2.0"
sp-storage = "21.0.0"
regex = "1"
2 changes: 1 addition & 1 deletion src/commands/dry_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
11 changes: 7 additions & 4 deletions src/commands/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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?;
Expand Down
13 changes: 8 additions & 5 deletions src/epm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 6 additions & 6 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32, subxt::config::substrate::BlakeTwo256>;
Expand All @@ -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::PolkadotConfig>;
/// Subxt client used by the staking miner on all chains.
Expand All @@ -58,7 +58,7 @@ pub type Config = subxt::PolkadotConfig;

/// Submission type used by the staking miner.
pub type SignedSubmission<S> =
pallet_election_provider_multi_phase::SignedSubmission<AccountId, Balance, S>;
polkadot_sdk::pallet_election_provider_multi_phase::SignedSubmission<AccountId, Balance, S>;

#[subxt::subxt(
runtime_metadata_path = "artifacts/metadata.scale",
Expand All @@ -69,11 +69,11 @@ pub type SignedSubmission<S> =
),
substitute_type(
path = "sp_npos_elections::ElectionScore",
with = "::subxt::utils::Static<::sp_npos_elections::ElectionScore>"
with = "::subxt::utils::Static<polkadot_sdk::sp_npos_elections::ElectionScore>"
),
substitute_type(
path = "pallet_election_provider_multi_phase::Phase<Bn>",
with = "::subxt::utils::Static<::pallet_election_provider_multi_phase::Phase<Bn>>"
with = "::subxt::utils::Static<polkadot_sdk::pallet_election_provider_multi_phase::Phase<Bn>>"
)
)]
pub mod runtime {}
Expand Down
2 changes: 1 addition & 1 deletion src/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ pub fn run(port: u16) -> Result<GracefulShutdown, String> {
}

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<Counter> = Lazy::new(|| {
Expand Down
13 changes: 8 additions & 5 deletions src/static_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

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) => {
Expand All @@ -34,7 +37,7 @@ macro_rules! impl_atomic_u32_parameter_types {
}
}

impl<I: From<u32>> frame_support::traits::Get<I> for $name {
impl<I: From<u32>> polkadot_sdk::frame_support::traits::Get<I> for $name {
fn get() -> I {
I::from(Self::get())
}
Expand All @@ -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);
Expand Down

0 comments on commit ae35e65

Please sign in to comment.