Skip to content

Commit 231ca92

Browse files
committed
add versioned migration and bump spec version
1 parent 80d8766 commit 231ca92

File tree

6 files changed

+31
-9
lines changed

6 files changed

+31
-9
lines changed

crates/pallet-domains/src/benchmarking.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ mod benchmarks {
777777
operator_id,
778778
deposit,
779779
domain_stake_summary.current_epoch_index,
780+
None,
780781
)
781782
.unwrap();
782783
Ok::<T::Share, StakingError>(deposit.known.shares)
@@ -799,6 +800,7 @@ mod benchmarks {
799800
operator_id,
800801
withdrawal,
801802
current_domain_epoch_index,
803+
None,
802804
)?;
803805
assert_eq!(withdrawal.withdrawals.len() as u32, w);
804806
Ok::<(), StakingError>(())

crates/pallet-domains/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl<T: Config> sp_domains::SkipBalanceChecks for DomainsSkipBalanceChecks<T> {
187187
}
188188

189189
/// The current storage version.
190-
const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);
190+
const STORAGE_VERSION: StorageVersion = StorageVersion::new(6);
191191

192192
/// The number of bundle of a particular domain to be included in the block is probabilistic
193193
/// and based on the consensus chain slot probability and domain bundle slot probability, usually

crates/pallet-domains/src/migrations.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
mod v1_to_v5;
2+
mod v5_to_v6;
23

34
pub(crate) use share_price_v0::OperatorEpochSharePrice as OperatorEpochSharePriceV0;
45
pub use v1_to_v5::VersionCheckedMigrateDomainsV1ToV5;
6+
pub use v5_to_v6::VersionCheckedMigrateDomainsV5ToV6;
57

68
mod share_price_v0 {
79
use crate::staking::{DomainEpoch, SharePrice as SharePriceV1};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Migration module for pallet-domains
2+
3+
use crate::{AllowedDefaultSharePriceEpoch, AllowedMissingSharePriceEpoch, Config, Pallet};
4+
use core::marker::PhantomData;
5+
use frame_support::migrations::VersionedMigration;
6+
use frame_support::traits::UncheckedOnRuntimeUpgrade;
7+
use frame_support::weights::Weight;
8+
use sp_core::Get;
9+
10+
pub type VersionCheckedMigrateDomainsV5ToV6<T> = VersionedMigration<
11+
5,
12+
6,
13+
VersionUncheckedMigrateV5ToV6<T>,
14+
Pallet<T>,
15+
<T as frame_system::Config>::DbWeight,
16+
>;
17+
18+
pub struct VersionUncheckedMigrateV5ToV6<T>(PhantomData<T>);
19+
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV5ToV6<T> {
20+
fn on_runtime_upgrade() -> Weight {
21+
AllowedDefaultSharePriceEpoch::<T>::put(AllowedMissingSharePriceEpoch::get());
22+
T::DbWeight::get().writes(1)
23+
}
24+
}

crates/pallet-domains/src/staking_epoch.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,6 @@ pub(crate) mod tests {
10221022
epoch_index: EpochIndex,
10231023
) {
10241024
let domain_epoch: DomainEpoch = (domain_id, epoch_index).into();
1025-
println!("{:?}", domain_epoch);
10261025
for operator_id in operators {
10271026
assert!(OperatorEpochSharePrice::<Test>::contains_key(
10281027
operator_id,

crates/subspace-runtime/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
128128
impl_name: Cow::Borrowed("subspace"),
129129
authoring_version: 0,
130130
// The spec version can be different on Taurus and Mainnet
131-
spec_version: 19,
131+
spec_version: 20,
132132
impl_version: 0,
133133
apis: RUNTIME_API_VERSIONS,
134134
transaction_version: 0,
@@ -1135,12 +1135,7 @@ pub type Executive = frame_executive::Executive<
11351135
frame_system::ChainContext<Runtime>,
11361136
Runtime,
11371137
AllPalletsWithSystem,
1138-
// TODO: remove only after migrations are run on Mainnet
1139-
(
1140-
pallet_domains::migrations::VersionCheckedMigrateDomainsV1ToV5<Runtime>,
1141-
pallet_messenger::migrations::VersionCheckedMigrateDomainsV0ToV1<Runtime>,
1142-
pallet_messenger::migrations::VersionCheckedMigrateDomainsV1ToV2<Runtime>,
1143-
),
1138+
(pallet_domains::migrations::VersionCheckedMigrateDomainsV5ToV6<Runtime>,),
11441139
>;
11451140

11461141
impl pallet_subspace::extensions::MaybeSubspaceCall<Runtime> for RuntimeCall {

0 commit comments

Comments
 (0)