Skip to content

Commit 63e3567

Browse files
committed
Cleanup migrations
1 parent cf8dbd1 commit 63e3567

File tree

4 files changed

+5
-175
lines changed

4 files changed

+5
-175
lines changed

Cargo.lock

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ pallet-migrations = { version = "13.0.0", default-features = false }
161161
pallet-preimage = { version = "43.0.0", default-features = false }
162162
pallet-scheduler = { version = "44.0.0", default-features = false }
163163
pallet-session = { version = "43.0.0", default-features = false }
164-
pallet-state-trie-migration = { version = "48.0.0", default-features = false }
165164
pallet-treasury = { version = "42.0.0", default-features = false }
166165
pallet-utility = { version = "43.0.0", default-features = false }
167166
pallet-vesting = { version = "43.0.0", default-features = false }

runtime/robonomics/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ frame-metadata-hash-extension.workspace = true
4343
pallet-identity.workspace = true
4444
pallet-scheduler.workspace = true
4545
pallet-session.workspace = true
46-
pallet-state-trie-migration.workspace = true
4746
pallet-treasury.workspace = true
4847
pallet-membership.workspace = true
4948
pallet-migrations.workspace = true
@@ -199,7 +198,6 @@ try-runtime = [
199198
"pallet-migrations/try-runtime",
200199
"pallet-multisig/try-runtime",
201200
"pallet-session/try-runtime",
202-
"pallet-state-trie-migration/try-runtime",
203201
"pallet-timestamp/try-runtime",
204202
"pallet-transaction-payment/try-runtime",
205203
"pallet-utility/try-runtime",

runtime/robonomics/src/lib.rs

Lines changed: 5 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
8484
spec_name: alloc::borrow::Cow::Borrowed("robonomics"),
8585
impl_name: alloc::borrow::Cow::Borrowed("robonomics-airalab"),
8686
authoring_version: 1,
87-
spec_version: 40,
87+
spec_version: 41,
8888
impl_version: 1,
8989
apis: RUNTIME_API_VERSIONS,
9090
transaction_version: 2,
@@ -204,7 +204,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
204204

205205
impl pallet_timestamp::Config for Runtime {
206206
type Moment = u64;
207-
type OnTimestampSet = ();
207+
type OnTimestampSet = Aura;
208208
type MinimumPeriod = ConstU64<0>;
209209
type WeightInfo = ();
210210
}
@@ -537,7 +537,7 @@ construct_runtime! {
537537
Timestamp: pallet_timestamp = 12,
538538
Multisig: pallet_multisig = 15,
539539
MultiBlockMigrations: pallet_migrations = 16,
540-
StateTrieMigration: pallet_state_trie_migration = 17,
540+
// Ex: StateTrieMigration: pallet_state_trie_migration = 17,
541541

542542
// Parachain systems.
543543
ParachainSystem: cumulus_pallet_parachain_system = 21,
@@ -628,98 +628,7 @@ pub type Executive = frame_executive::Executive<
628628
>;
629629

630630
/// Migrations to apply on runtime upgrade.
631-
pub type Migrations = (
632-
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
633-
//cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
634-
//cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
635-
InitMigrationStorage,
636-
// permanent
637-
//pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
638-
);
639-
640-
pub struct InitMigrationStorage;
641-
impl frame_support::traits::OnRuntimeUpgrade for InitMigrationStorage {
642-
fn on_runtime_upgrade() -> Weight {
643-
use sp_core::crypto::Ss58Codec;
644-
use sp_keyring::Sr25519Keyring;
645-
646-
// setup sudo
647-
if let Ok(sudo_key) =
648-
AccountId::from_ss58check("5Cakru1BpXPiezeD2LRZh3pJamHcbX9yZ13KLBxuqdTpgnYF")
649-
{
650-
let _ = Sudo::set_key(RuntimeOrigin::root(), sudo_key.into());
651-
}
652-
653-
// setup collators
654-
use pallet_collator_selection::{CandidacyBond, DesiredCandidates, Invulnerables};
655-
let desired_candidates = 25;
656-
let candidacy_bond = 32 * XRT;
657-
let invulnerables: Vec<AccountId> = vec![
658-
Sr25519Keyring::Alice.to_account_id(),
659-
Sr25519Keyring::Bob.to_account_id(),
660-
];
661-
662-
let bounded_invulnerables: BoundedVec<
663-
_,
664-
<Runtime as pallet_collator_selection::Config>::MaxInvulnerables,
665-
> = invulnerables
666-
.clone()
667-
.try_into()
668-
.expect("genesis invulnerables are more than T::MaxInvulnerables");
669-
670-
DesiredCandidates::<Runtime>::put(desired_candidates);
671-
CandidacyBond::<Runtime>::put(candidacy_bond);
672-
Invulnerables::<Runtime>::put(bounded_invulnerables);
673-
674-
// Genesis init pallet_session
675-
use pallet_session::{NextKeys, QueuedKeys, SessionHandler, SessionManager, Validators};
676-
677-
// insert genesis keys
678-
NextKeys::<Runtime>::insert(
679-
Sr25519Keyring::Alice.to_account_id(),
680-
SessionKeys {
681-
aura: Sr25519Keyring::Alice.public().into(),
682-
},
683-
);
684-
NextKeys::<Runtime>::insert(
685-
Sr25519Keyring::Bob.to_account_id(),
686-
SessionKeys {
687-
aura: Sr25519Keyring::Bob.public().into(),
688-
},
689-
);
690-
691-
// init validators
692-
let initial_validators_0 =
693-
<Runtime as pallet_session::Config>::SessionManager::new_session_genesis(0)
694-
.unwrap_or_else(|| {
695-
frame_support::print(
696-
"No initial validator provided by `SessionManager`, use \
697-
session config keys to generate initial validator set.",
698-
);
699-
invulnerables
700-
});
701-
702-
let initial_validators_1 =
703-
<Runtime as pallet_session::Config>::SessionManager::new_session_genesis(1)
704-
.unwrap_or_else(|| initial_validators_0.clone());
705-
706-
let queued_keys: Vec<_> = initial_validators_1
707-
.into_iter()
708-
.filter_map(|v| pallet_session::Pallet::<Runtime>::load_keys(&v).map(|k| (v, k)))
709-
.collect();
710-
711-
<Runtime as pallet_session::Config>::SessionHandler::on_genesis_session::<
712-
<Runtime as pallet_session::Config>::Keys,
713-
>(&queued_keys);
714-
715-
Validators::<Runtime>::put(initial_validators_0);
716-
QueuedKeys::<Runtime>::put(queued_keys);
717-
718-
<Runtime as pallet_session::Config>::SessionManager::start_session(0);
719-
720-
Default::default()
721-
}
722-
}
631+
pub type Migrations = ();
723632

724633
#[cfg(feature = "runtime-benchmarks")]
725634
extern crate frame_benchmarking;
@@ -943,66 +852,7 @@ impl_runtime_apis! {
943852
}
944853
}
945854

946-
/// Recovery block executor that pass blocks when authorities list is empty.
947-
pub struct BlockExecutor<T, I>(core::marker::PhantomData<(T, I)>);
948-
949-
impl<Block, T, I> frame_support::traits::ExecuteBlock<Block> for BlockExecutor<T, I>
950-
where
951-
Block: BlockT,
952-
T: cumulus_pallet_aura_ext::Config,
953-
I: frame_support::traits::ExecuteBlock<Block>,
954-
{
955-
fn execute_block(block: Block) {
956-
if pallet_aura::Authorities::<T>::get().len() > 0 {
957-
// Execute block with aura pallet
958-
cumulus_pallet_aura_ext::BlockExecutor::<T, I>::execute_block(block);
959-
} else {
960-
// Workaround because we don't have authorities
961-
use sp_consensus_aura::digests::CompatibleDigestItem;
962-
use sp_runtime::{traits::Header, RuntimeAppPublic};
963-
964-
// Filter aura digests befor pass block to executor
965-
let (mut header, extrinsics) = block.deconstruct();
966-
header.digest_mut().logs.retain(|s|
967-
CompatibleDigestItem::<<T::AuthorityId as RuntimeAppPublic>::Signature>::as_aura_seal(s)
968-
.is_none()
969-
);
970-
971-
I::execute_block(Block::new(header, extrinsics));
972-
}
973-
}
974-
}
975-
976855
cumulus_pallet_parachain_system::register_validate_block! {
977856
Runtime = Runtime,
978-
BlockExecutor = BlockExecutor<Runtime, Executive>,
979-
}
980-
981-
parameter_types! {
982-
// 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)
983-
pub const MigrationSignedDepositPerItem: Balance = COASE;
984-
pub const MigrationSignedDepositBase: Balance = 2_000 * COASE;
985-
pub const MigrationMaxKeyLen: u32 = 512;
986-
}
987-
988-
impl pallet_state_trie_migration::Config for Runtime {
989-
type RuntimeEvent = RuntimeEvent;
990-
type Currency = Balances;
991-
type RuntimeHoldReason = RuntimeHoldReason;
992-
type SignedDepositPerItem = MigrationSignedDepositPerItem;
993-
type SignedDepositBase = MigrationSignedDepositBase;
994-
// An origin that can control the whole pallet: should be Root, or a part of your council.
995-
type ControlOrigin = frame_system::EnsureSignedBy<RootMigController, AccountId>;
996-
// specific account for the migration, can trigger the signed migrations.
997-
type SignedFilter = frame_system::EnsureSignedBy<MigController, AccountId>;
998-
999-
// Replace this with weight based on your runtime.
1000-
type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
1001-
1002-
type MaxKeyLen = MigrationMaxKeyLen;
1003-
}
1004-
1005-
frame_support::ord_parameter_types! {
1006-
pub const MigController: AccountId = AccountId::from(hex_literal::hex!("16eb796bee0c857db3d646ee7070252707aec0c7d82b2eda856632f6a2306a58"));
1007-
pub const RootMigController: AccountId = AccountId::from(hex_literal::hex!("16eb796bee0c857db3d646ee7070252707aec0c7d82b2eda856632f6a2306a58"));
857+
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
1008858
}

0 commit comments

Comments
 (0)