Skip to content

Commit

Permalink
remove all
Browse files Browse the repository at this point in the history
  • Loading branch information
programskillforverification committed Oct 2, 2024
1 parent 9c8aaff commit 12d0b3a
Show file tree
Hide file tree
Showing 17 changed files with 264 additions and 298 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions cumulus/xcm/xcm-emulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ frame-support = { workspace = true, default-features = true }
frame-system = { workspace = true, default-features = true }
sp-io = { workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-keyring = { workspace = true, default-features = true }
sp-crypto-hashing = { workspace = true, default-features = true }
sp-std = { workspace = true, default-features = true }
sp-runtime = { workspace = true, default-features = true }
Expand Down
21 changes: 7 additions & 14 deletions cumulus/xcm/xcm-emulator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub use sp_arithmetic::traits::Bounded;
pub use sp_core::{parameter_types, sr25519, storage::Storage, Pair};
pub use sp_crypto_hashing::blake2_256;
pub use sp_io::TestExternalities;
pub use sp_keyring::Sr25519Keyring;
pub use sp_runtime::BoundedSlice;
pub use sp_tracing;

Expand Down Expand Up @@ -226,7 +227,12 @@ pub trait Chain: TestExt {
type OriginCaller;

fn account_id_of(seed: &str) -> AccountId {
helpers::get_account_id_from_seed::<sr25519::Public>(seed)
use sp_runtime::traits::IdentifyAccount;
use std::str::FromStr;
sp_runtime::MultiSigner::from(
Sr25519Keyring::from_str(seed).expect("should parse str seed to keyring"),
)
.into_account()
}

fn account_data_of(account: AccountIdOf<Self::Runtime>) -> AccountData<Balance>;
Expand Down Expand Up @@ -1608,17 +1614,4 @@ pub mod helpers {

ref_time_within && proof_size_within
}

/// Helper function to generate an account ID from seed.
pub fn get_account_id_from_seed<TPublic: sp_core::Public>(seed: &str) -> AccountId
where
sp_runtime::MultiSigner:
From<<<TPublic as sp_runtime::CryptoType>::Pair as sp_core::Pair>::Public>,
{
use sp_runtime::traits::IdentifyAccount;
let pubkey = TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public();
sp_runtime::MultiSigner::from(pubkey).into_account()
}
}
4 changes: 2 additions & 2 deletions polkadot/node/test/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub fn polkadot_local_testnet_genesis() -> serde_json::Value {
fn get_authority_keys_from_seed(
seed: &str,
) -> (AccountId, AccountId, BabeId, GrandpaId, ValidatorId, AssignmentId, AuthorityDiscoveryId) {
let sr25519_keyring = Sr25519Keyring::from_str(seed).expect("Parse keyring error");
let ed25519_keyring = Ed25519Keyring::from_str(seed).expect("Parse keyring error");
let sr25519_keyring = Sr25519Keyring::from_str(seed).expect("should parse str seed to keyring");
let ed25519_keyring = Ed25519Keyring::from_str(seed).expect("should parse str seed to keyring");
(
sr25519_keyring.to_account_id(),
sr25519_keyring.to_account_id(),
Expand Down
3 changes: 1 addition & 2 deletions polkadot/runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,9 @@ mod tests {
traits::{Currency, WithdrawReasons},
};
use sp_runtime::{
traits::{BlakeTwo256, Dispatchable, Identity, IdentityLookup, Verify},
traits::{BlakeTwo256, Dispatchable, Identity, IdentityLookup},
ArithmeticError, BuildStorage,
DispatchError::BadOrigin,
MultiSignature,
};

type Block = frame_system::mocking::MockBlock<Test>;
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ sp-storage = { workspace = true }
sp-version = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-block-builder = { workspace = true }
sp-keyring = { workspace = true }

pallet-authority-discovery = { workspace = true }
pallet-authorship = { workspace = true }
Expand Down
96 changes: 53 additions & 43 deletions polkadot/runtime/rococo/src/genesis_config_presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,15 @@ use crate::{
#[cfg(not(feature = "std"))]
use alloc::format;
use alloc::{vec, vec::Vec};
use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, SchedulerParams, ValidatorId};
use polkadot_primitives::{AccountId, AssignmentId, SchedulerParams, 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_core::Pair;
use sp_genesis_builder::PresetId;
use sp_runtime::traits::IdentifyAccount;

/// Helper function to generate a crypto pair from seed
fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}

/// Helper function to generate an account ID from seed
fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
use sp_keyring::{Ed25519Keyring, Sr25519Keyring};

/// Helper function to generate stash, controller and session key from seed
fn get_authority_keys_from_seed(
Expand All @@ -62,39 +47,64 @@ fn get_authority_keys_from_seed(
BeefyId,
) {
let keys = get_authority_keys_from_seed_no_beefy(seed);
(keys.0, keys.1, keys.2, keys.3, keys.4, keys.5, keys.6, get_from_seed::<BeefyId>(seed))
(
keys.0,
keys.1,
keys.2,
keys.3,
keys.4,
keys.5,
keys.6,
BeefyId::from(
sp_consensus_beefy::ecdsa_crypto::Pair::from_string(&format!("//{}", seed), None)
.expect("should parse str seed to keyring")
.public(),
),
)
}

/// Helper function to generate stash, controller and session key from seed
fn get_authority_keys_from_seed_no_beefy(
seed: &str,
) -> (AccountId, AccountId, BabeId, GrandpaId, ValidatorId, AssignmentId, AuthorityDiscoveryId) {
use core::str::FromStr;
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<BabeId>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<ValidatorId>(seed),
get_from_seed::<AssignmentId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
Sr25519Keyring::from_str(&format!("{}//stash", seed))
.expect("should parse str seed to keyring")
.to_account_id(),
Sr25519Keyring::from_str(seed)
.expect("should parse str seed to keyring")
.to_account_id(),
BabeId::from(
Sr25519Keyring::from_str(seed)
.expect("should parse str seed to keyring")
.public(),
),
GrandpaId::from(
Ed25519Keyring::from_str(seed)
.expect("should parse str seed to keyring")
.public(),
),
ValidatorId::from(
Sr25519Keyring::from_str(seed)
.expect("should parse str seed to keyring")
.public(),
),
AssignmentId::from(
Sr25519Keyring::from_str(seed)
.expect("should parse str seed to keyring")
.public(),
),
AuthorityDiscoveryId::from(
Sr25519Keyring::from_str(seed)
.expect("should parse str seed to keyring")
.public(),
),
)
}

fn testnet_accounts() -> Vec<AccountId> {
Vec::from([
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
])
Sr25519Keyring::iter().map(|x| x.to_account_id()).collect()
}

fn rococo_session_keys(
Expand Down Expand Up @@ -478,7 +488,7 @@ fn rococo_staging_testnet_config_genesis() -> serde_json::Value {
fn rococo_development_config_genesis() -> serde_json::Value {
rococo_testnet_genesis(
Vec::from([get_authority_keys_from_seed("Alice")]),
get_account_id_from_seed::<sr25519::Public>("Alice"),
Sr25519Keyring::Alice.to_account_id(),
None,
)
}
Expand All @@ -487,7 +497,7 @@ fn rococo_development_config_genesis() -> serde_json::Value {
fn rococo_local_testnet_genesis() -> serde_json::Value {
rococo_testnet_genesis(
Vec::from([get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")]),
get_account_id_from_seed::<sr25519::Public>("Alice"),
Sr25519Keyring::Alice.to_account_id(),
None,
)
}
Expand All @@ -502,7 +512,7 @@ fn versi_local_testnet_genesis() -> serde_json::Value {
get_authority_keys_from_seed("Charlie"),
get_authority_keys_from_seed("Dave"),
]),
get_account_id_from_seed::<sr25519::Public>("Alice"),
Sr25519Keyring::Alice.to_account_id(),
None,
)
}
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ sp-version = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-block-builder = { workspace = true }
sp-npos-elections = { workspace = true }
sp-keyring = { workspace = true }

frame-election-provider-support = { workspace = true }
frame-executive = { workspace = true }
Expand Down
Loading

0 comments on commit 12d0b3a

Please sign in to comment.