Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pallet-beefy = { git = "https://github.com/paritytech/substrate", branch = "mast
pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-bounties = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-child-bounties = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -77,7 +78,7 @@ pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-feat

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
hex-literal = { version = "0.3.4", optional = true }
hex-literal = { version = "0.3.4" }

runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false }
Expand All @@ -89,7 +90,6 @@ xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", defa
xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false }

[dev-dependencies]
hex-literal = "0.3.4"
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down Expand Up @@ -124,6 +124,7 @@ std = [
"pallet-beefy-mmr/std",
"pallet-bounties/std",
"pallet-child-bounties/std",
"pallet-state-trie-migration/std",
"pallet-transaction-payment/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-collective/std",
Expand Down Expand Up @@ -207,7 +208,6 @@ runtime-benchmarks = [
"pallet-vesting/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"hex-literal",
"xcm-builder/runtime-benchmarks",
"runtime-parachains/runtime-benchmarks",
"pallet-xcm-benchmarks/runtime-benchmarks",
Expand Down
41 changes: 40 additions & 1 deletion runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
#[cfg(feature = "disable-runtime-api")]
apis: sp_version::create_apis_vec![[]],
transaction_version: 13,
state_version: 0,
state_version: 1,
};

/// The BABE epoch configuration at genesis.
Expand Down Expand Up @@ -1375,6 +1375,9 @@ construct_runtime! {
// Gilts pallet.
Gilt: pallet_gilt::{Pallet, Call, Storage, Event<T>, Config} = 38,

// State trie migration pallet, only temporary.
StateTrieMigration: pallet_state_trie_migration = 41,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This index was chosen a bit randomly, please tell me if there is a more suitable one (the crate will not be in the runtime forever).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
StateTrieMigration: pallet_state_trie_migration = 41,
StateTrieMigration: pallet_state_trie_migration = 254,

And then move it down.


// Parachains pallets. Start indices at 50 to leave room.
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50,
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 51,
Expand Down Expand Up @@ -1463,6 +1466,42 @@ pub type Executive = frame_executive::Executive<
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;

parameter_types! {
// The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high)
pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS;
pub const MigrationSignedDepositBase: Balance = 20 * CENTS * 100;
pub const MigrationMaxKeyLen: u32 = 512;
}

impl pallet_state_trie_migration::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type SignedDepositPerItem = MigrationSignedDepositPerItem;
type SignedDepositBase = MigrationSignedDepositBase;
// An origin that can control the whole pallet: should be Root, or a part of your council.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// An origin that can control the whole pallet: should be Root, or a part of your council.

type ControlOrigin = EnsureRoot<AccountId>;
// specific account for the migration, can trigger the signed migrations.
type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;

// Use same weights as substrate ones.
type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
type MaxKeyLen = MigrationMaxKeyLen;
}

frame_support::ord_parameter_types! {
pub const MigController: AccountId = AccountId::from(hex_literal::hex!("52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649"));
}

#[test]
fn ensure_key_ss58() {
use frame_support::traits::SortedMembers;
use sp_core::crypto::Ss58Codec;
let acc =
AccountId::from_ss58check("5DwBmEFPXRESyEam5SsQF1zbWSCn2kCjyLW51hJHXe9vW4xs").unwrap();
//panic!("{:x?}", acc);
assert_eq!(acc, MigController::sorted_members()[0]);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[test]
fn ensure_key_ss58() {
use frame_support::traits::SortedMembers;
use sp_core::crypto::Ss58Codec;
let acc =
AccountId::from_ss58check("5DwBmEFPXRESyEam5SsQF1zbWSCn2kCjyLW51hJHXe9vW4xs").unwrap();
//panic!("{:x?}", acc);
assert_eq!(acc, MigController::sorted_members()[0]);
}

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;
Expand Down