Skip to content

Commit

Permalink
migrate keyring to frame
Browse files Browse the repository at this point in the history
  • Loading branch information
programskillforverification committed Oct 2, 2024
1 parent 1617852 commit ca3893d
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 57 deletions.
4 changes: 1 addition & 3 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion bridges/snowbridge/pallets/inbound-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ snowbridge-pallet-inbound-queue-fixtures = { optional = true, workspace = true }

[dev-dependencies]
frame-benchmarking = { workspace = true, default-features = true }
sp-keyring = { workspace = true, default-features = true }
snowbridge-pallet-ethereum-client = { workspace = true, default-features = true }
hex-literal = { workspace = true, default-features = true }

Expand Down
3 changes: 1 addition & 2 deletions bridges/snowbridge/pallets/inbound-queue/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
use super::*;

use frame_support::{assert_noop, assert_ok};
use frame_support::{assert_noop, assert_ok, Sr25519Keyring as Keyring};
use hex_literal::hex;
use snowbridge_core::{inbound::Proof, ChannelId};
use sp_keyring::AccountKeyring as Keyring;
use sp_runtime::DispatchError;
use sp_std::convert::From;

Expand Down
2 changes: 0 additions & 2 deletions bridges/snowbridge/runtime/test-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pallet-timestamp = { workspace = true }
pallet-utility = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-keyring = { workspace = true, default-features = true }
sp-runtime = { workspace = true }

# Polkadot
Expand Down Expand Up @@ -67,7 +66,6 @@ std = [
"snowbridge-pallet-system/std",
"sp-core/std",
"sp-io/std",
"sp-keyring/std",
"sp-runtime/std",
"xcm-executor/std",
"xcm/std",
Expand Down
6 changes: 3 additions & 3 deletions bridges/snowbridge/runtime/test-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use codec::Encode;
use frame_support::{
assert_err, assert_ok,
traits::{fungible::Mutate, OnFinalize, OnInitialize},
Sr25519Keyring::*,
};
use frame_system::pallet_prelude::BlockNumberFor;
use parachains_runtimes_test_utils::{
Expand All @@ -13,7 +14,6 @@ use parachains_runtimes_test_utils::{
use snowbridge_core::{ChannelId, ParaId};
use snowbridge_pallet_ethereum_client_fixtures::*;
use sp_core::{Get, H160, U256};
use sp_keyring::AccountKeyring::*;
use sp_runtime::{traits::Header, AccountId32, DigestItem, SaturatedConversion, Saturating};
use xcm::{
latest::prelude::*,
Expand Down Expand Up @@ -434,7 +434,7 @@ pub fn ethereum_extrinsic<Runtime>(
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
<Runtime as frame_system::Config>::RuntimeCall,
) -> sp_runtime::DispatchOutcome,
) where
Expand Down Expand Up @@ -570,7 +570,7 @@ pub fn ethereum_to_polkadot_message_extrinsics_work<Runtime>(
collator_session_key: CollatorSessionKeys<Runtime>,
runtime_para_id: u32,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
<Runtime as frame_system::Config>::RuntimeCall,
) -> sp_runtime::DispatchOutcome,
) where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-keyring = { workspace = true, default-features = true }
sp-runtime = { workspace = true }
sp-tracing = { workspace = true, default-features = true }
pallet-balances = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ use bp_header_chain::ChainWithGrandpa;
use bp_messages::UnrewardedRelayersState;
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
use bp_xcm_bridge_hub::XcmAsPlainPayload;
use frame_support::traits::{OnFinalize, OnInitialize};
use frame_support::{
traits::{OnFinalize, OnInitialize},
Sr25519Keyring::*,
};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_bridge_messages::{BridgedChainOf, LaneIdOf, ThisChainOf};
use parachains_runtimes_test_utils::{
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf, SlotDurations,
};
use sp_core::Get;
use sp_keyring::AccountKeyring::*;
use sp_runtime::{traits::Header as HeaderT, AccountId32};
use xcm::latest::prelude::*;

Expand Down Expand Up @@ -103,7 +105,7 @@ pub fn relayed_incoming_message_works<RuntimeHelper>(
local_relay_chain_id: NetworkId,
prepare_configuration: impl Fn() -> LaneIdOf<RuntimeHelper::Runtime, RuntimeHelper::MPI>,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
RuntimeCallOf<RuntimeHelper::Runtime>,
) -> sp_runtime::DispatchOutcome,
expect_rewards: bool,
Expand Down Expand Up @@ -210,7 +212,7 @@ pub fn free_relay_extrinsic_works<RuntimeHelper>(
local_relay_chain_id: NetworkId,
prepare_configuration: impl Fn() -> LaneIdOf<RuntimeHelper::Runtime, RuntimeHelper::MPI>,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
RuntimeCallOf<RuntimeHelper::Runtime>,
) -> sp_runtime::DispatchOutcome,
expect_rewards: bool,
Expand Down Expand Up @@ -344,7 +346,7 @@ pub fn complex_relay_extrinsic_works<RuntimeHelper>(
local_relay_chain_id: NetworkId,
prepare_configuration: impl Fn() -> LaneIdOf<RuntimeHelper::Runtime, RuntimeHelper::MPI>,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
RuntimeCallOf<RuntimeHelper::Runtime>,
) -> sp_runtime::DispatchOutcome,
) where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ use bp_polkadot_core::parachains::ParaHash;
use bp_relayers::{RewardsAccountOwner, RewardsAccountParams};
use bp_runtime::{Chain, Parachain};
use bp_xcm_bridge_hub::XcmAsPlainPayload;
use frame_support::traits::{OnFinalize, OnInitialize};
use frame_support::{
traits::{OnFinalize, OnInitialize},
Sr25519Keyring::*,
};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_bridge_messages::{BridgedChainOf, LaneIdOf, ThisChainOf};
use parachains_runtimes_test_utils::{
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf, SlotDurations,
};
use sp_core::Get;
use sp_keyring::AccountKeyring::*;
use sp_runtime::{traits::Header as HeaderT, AccountId32};
use xcm::latest::prelude::*;

Expand Down Expand Up @@ -112,7 +114,7 @@ pub fn relayed_incoming_message_works<RuntimeHelper>(
local_relay_chain_id: NetworkId,
prepare_configuration: impl Fn() -> LaneIdOf<RuntimeHelper::Runtime, RuntimeHelper::MPI>,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
<RuntimeHelper::Runtime as frame_system::Config>::RuntimeCall,
) -> sp_runtime::DispatchOutcome,
expect_rewards: bool,
Expand Down Expand Up @@ -246,7 +248,7 @@ pub fn free_relay_extrinsic_works<RuntimeHelper>(
local_relay_chain_id: NetworkId,
prepare_configuration: impl Fn() -> LaneIdOf<RuntimeHelper::Runtime, RuntimeHelper::MPI>,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
<RuntimeHelper::Runtime as frame_system::Config>::RuntimeCall,
) -> sp_runtime::DispatchOutcome,
expect_rewards: bool,
Expand Down Expand Up @@ -414,7 +416,7 @@ pub fn complex_relay_extrinsic_works<RuntimeHelper>(
local_relay_chain_id: NetworkId,
prepare_configuration: impl Fn() -> LaneIdOf<RuntimeHelper::Runtime, RuntimeHelper::MPI>,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
<RuntimeHelper::Runtime as frame_system::Config>::RuntimeCall,
) -> sp_runtime::DispatchOutcome,
) where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use frame_support::{
assert_ok,
dispatch::GetDispatchInfo,
traits::{fungible::Mutate, OnFinalize, OnInitialize, PalletInfoAccess},
Sr25519Keyring::*,
};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_bridge_grandpa::{BridgedBlockHash, BridgedHeader};
Expand All @@ -39,7 +40,6 @@ use parachains_runtimes_test_utils::{
mock_open_hrmp_channel, AccountIdOf, CollatorSessionKeys, RuntimeCallOf, SlotDurations,
};
use sp_core::Get;
use sp_keyring::AccountKeyring::*;
use sp_runtime::{traits::TrailingZeroInput, AccountId32};
use xcm::latest::prelude::*;
use xcm_executor::traits::ConvertLocation;
Expand Down Expand Up @@ -264,7 +264,7 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
sibling_parachain_id: u32,
local_relay_chain_id: NetworkId,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
RuntimeCallOf<Runtime>,
) -> sp_runtime::DispatchOutcome,
prepare_message_proof_import: impl FnOnce(
Expand Down Expand Up @@ -374,9 +374,9 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(

/// Execute every call and verify its outcome.
fn execute_and_verify_calls<Runtime: frame_system::Config>(
submitter: sp_keyring::AccountKeyring,
submitter: frame_support::Sr25519Keyring,
construct_and_apply_extrinsic: fn(
sp_keyring::AccountKeyring,
frame_support::Sr25519Keyring,
RuntimeCallOf<Runtime>,
) -> sp_runtime::DispatchOutcome,
calls_and_verifiers: CallsAndVerifiers<Runtime>,
Expand Down
27 changes: 8 additions & 19 deletions substrate/frame/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,13 @@ targets = ["x86_64-unknown-linux-gnu"]
array-bytes = { workspace = true }
binary-merkle-tree.workspace = true
serde = { features = ["alloc", "derive"], workspace = true }
codec = { features = [
"derive",
"max-encoded-len",
], workspace = true }
scale-info = { features = [
"derive",
], workspace = true }
frame-metadata = { features = [
"current",
], workspace = true }
sp-api = { features = [
"frame-metadata",
], workspace = true }
codec = { features = ["derive", "max-encoded-len"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame-metadata = { features = ["current"], workspace = true }
sp-api = { features = ["frame-metadata"], workspace = true }
sp-std = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { features = [
"serde",
], workspace = true }
sp-runtime = { features = ["serde"], workspace = true }
sp-tracing = { workspace = true }
sp-core = { workspace = true }
sp-arithmetic = { workspace = true }
Expand All @@ -46,6 +35,7 @@ sp-weights = { workspace = true }
sp-debug-derive = { workspace = true }
sp-metadata-ir = { workspace = true }
sp-trie = { workspace = true }
sp-keyring = { optional = true, workspace = true }
tt-call = { workspace = true }
macro_magic = { workspace = true }
frame-support-procedural = { workspace = true }
Expand Down Expand Up @@ -102,6 +92,7 @@ std = [
"sp-tracing/std",
"sp-trie/std",
"sp-weights/std",
"sp-keyring/std",
]
runtime-benchmarks = [
"frame-system/runtime-benchmarks",
Expand All @@ -113,9 +104,7 @@ try-runtime = [
"sp-debug-derive/force-debug",
"sp-runtime/try-runtime",
]
experimental = [
"frame-support-procedural/experimental",
]
experimental = ["frame-support-procedural/experimental"]
# By default some types have documentation, `no-metadata-docs` allows to reduce the documentation
# in the metadata.
no-metadata-docs = [
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub use self::{
StorageMap, StorageNMap, StoragePrefixedMap, StorageValue,
},
};
pub use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
pub use sp_runtime::{
self, print, traits::Printable, ConsensusEngineId, MAX_MODULE_ERROR_ENCODED_SIZE,
};
Expand Down
9 changes: 0 additions & 9 deletions substrate/primitives/keyring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ pub mod ed25519;
#[cfg(feature = "bandersnatch-experimental")]
pub mod bandersnatch;

/// Convenience export: Sr25519's Keyring is exposed as `AccountKeyring`, since it tends to be
/// used for accounts (although it may also be used by authorities).
pub use sr25519::Keyring as AccountKeyring;

#[cfg(feature = "bandersnatch-experimental")]
pub use bandersnatch::Keyring as BandersnatchKeyring;
pub use ed25519::Keyring as Ed25519Keyring;
pub use sr25519::Keyring as Sr25519Keyring;

pub mod test {
/// The keyring for use with accounts when using the test runtime.
pub use super::ed25519::Keyring as AccountKeyring;
}
4 changes: 1 addition & 3 deletions substrate/test-utils/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ pub use sc_client_db::{self, Backend, BlocksPruning};
pub use sc_executor::{self, WasmExecutionMethod, WasmExecutor};
pub use sc_service::{client, RpcHandlers};
pub use sp_consensus;
pub use sp_keyring::{
ed25519::Keyring as Ed25519Keyring, sr25519::Keyring as Sr25519Keyring, AccountKeyring,
};
pub use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
pub use sp_keystore::{Keystore, KeystorePtr};
pub use sp_runtime::{Storage, StorageChild};

Expand Down

0 comments on commit ca3893d

Please sign in to comment.