Skip to content

Commit

Permalink
v0.11.2 rc
Browse files Browse the repository at this point in the history
  • Loading branch information
wischli committed Jun 25, 2024
1 parent c037d29 commit 265e509
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 150 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ license = "LGPL-3.0"
homepage = "https://centrifuge.io/"
repository = "https://github.com/centrifuge/centrifuge-chain"
documentation = "https://reference.centrifuge.io/centrifuge_chain/index.html"
version = "0.11.1"
version = "0.11.2"

[workspace.dependencies]
hex-literal = { version = "0.4.1" }
Expand Down
4 changes: 2 additions & 2 deletions runtime/altair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("altair"),
impl_name: create_runtime_str!("altair"),
authoring_version: 1,
spec_version: 1101,
spec_version: 1102,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -1966,7 +1966,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
migrations::UpgradeAltair1101,
migrations::UpgradeAltair1102,
>;

// Frame Order in this block dictates the index of each one in the metadata
Expand Down
2 changes: 1 addition & 1 deletion runtime/altair/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const IDENTITY_MIGRATION_KEY_LIMIT: u64 = 1000;

/// The migration set for Altair @ Kusama.
/// It includes all the migrations that have to be applied on that chain.
pub type UpgradeAltair1101 = (
pub type UpgradeAltair1102 = (
runtime_common::migrations::increase_storage_version::Migration<OraclePriceFeed, 0, 1>,
runtime_common::migrations::increase_storage_version::Migration<OraclePriceCollection, 0, 1>,
runtime_common::migrations::increase_storage_version::Migration<OrderBook, 0, 1>,
Expand Down
4 changes: 2 additions & 2 deletions runtime/centrifuge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("centrifuge"),
impl_name: create_runtime_str!("centrifuge"),
authoring_version: 1,
spec_version: 1101,
spec_version: 1102,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -2080,7 +2080,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
migrations::UpgradeCentrifuge1101,
migrations::UpgradeCentrifuge1102,
>;

// Frame Order in this block dictates the index of each one in the metadata
Expand Down
2 changes: 1 addition & 1 deletion runtime/centrifuge/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ parameter_types! {

/// The migration set for Centrifuge @ Polkadot.
/// It includes all the migrations that have to be applied on that chain.
pub type UpgradeCentrifuge1101 = (
pub type UpgradeCentrifuge1102 = (
runtime_common::migrations::increase_storage_version::Migration<OraclePriceFeed, 0, 1>,
runtime_common::migrations::increase_storage_version::Migration<OraclePriceCollection, 0, 1>,
pallet_collator_selection::migration::v1::MigrateToV1<crate::Runtime>,
Expand Down
4 changes: 2 additions & 2 deletions runtime/development/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("centrifuge-devel"),
impl_name: create_runtime_str!("centrifuge-devel"),
authoring_version: 1,
spec_version: 1101,
spec_version: 1102,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -2069,7 +2069,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
crate::migrations::UpgradeDevelopment1101,
crate::migrations::UpgradeDevelopment1102,
>;

// Frame Order in this block dictates the index of each one in the metadata
Expand Down
138 changes: 1 addition & 137 deletions runtime/development/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,142 +10,6 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use cfg_primitives::AccountId;
use sp_core::parameter_types;
use sp_std::{vec, vec::Vec};

parameter_types! {
pub const CollatorReward: cfg_primitives::Balance = cfg_primitives::constants::CFG;
pub const AnnualTreasuryInflationPercent: u32 = 3;
pub AccountMap: Vec<(AccountId, AccountId)> = vec![];

}

// Number of identities on Dev and Demo Chain on 30.05.2024 was both 0
const IDENTITY_MIGRATION_KEY_LIMIT: u64 = 1000;

/// The migration set for Development & Demo.
/// It includes all the migrations that have to be applied on that chain.
pub type UpgradeDevelopment1101 = (
pallet_collator_selection::migration::v1::MigrateToV1<crate::Runtime>,
pallet_collator_selection::migration::v2::MigrationToV2<crate::Runtime>,
cleanup_foreign_investments::Migration<crate::Runtime>,
// v0 -> v1
pallet_multisig::migrations::v1::MigrateToV1<crate::Runtime>,
// v0 -> v1
pallet_balances::migration::MigrateToTrackInactive<super::Runtime, super::CheckingAccount, ()>,
// v0 -> v1
runtime_common::migrations::nuke::ResetPallet<crate::Preimage, crate::RocksDbWeight, 0>,
// v0 -> v1
runtime_common::migrations::nuke::ResetPallet<crate::Democracy, crate::RocksDbWeight, 0>,
// v0 -> v1
runtime_common::migrations::nuke::ResetPallet<crate::PolkadotXcm, crate::RocksDbWeight, 0>,
runtime_common::migrations::increase_storage_version::Migration<crate::PoolSystem, 0, 2>,
runtime_common::migrations::increase_storage_version::Migration<crate::InterestAccrual, 0, 3>,
runtime_common::migrations::increase_storage_version::Migration<crate::Investments, 0, 1>,
runtime_common::migrations::increase_storage_version::Migration<crate::OraclePriceFeed, 0, 1>,
runtime_common::migrations::increase_storage_version::Migration<
crate::OraclePriceCollection,
0,
1,
>,
runtime_common::migrations::increase_storage_version::Migration<crate::OrmlAssetRegistry, 0, 2>,
// Reset Block rewards on Demo which is at v0
runtime_common::migrations::nuke::ResetPallet<crate::BlockRewards, crate::RocksDbWeight, 0>,
// Reset Block rewards on Dev which is at v2
runtime_common::migrations::nuke::ResetPallet<crate::BlockRewards, crate::RocksDbWeight, 2>,
pallet_block_rewards::migrations::init::InitBlockRewards<
crate::Runtime,
CollatorReward,
AnnualTreasuryInflationPercent,
>,
runtime_common::migrations::restricted_location::MigrateRestrictedTransferLocation<
crate::Runtime,
AccountMap,
>,
runtime_common::migrations::loans::AddWithLinearPricing<crate::Runtime>,
runtime_common::migrations::hold_reason::MigrateTransferAllowListHolds<
crate::Runtime,
crate::RuntimeHoldReason,
>,
// Migrations below this comment originate from Polkadot SDK
pallet_xcm::migration::MigrateToLatestXcmVersion<crate::Runtime>,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<crate::Runtime>,
pallet_identity::migration::versioned::V0ToV1<crate::Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
pallet_uniques::migration::MigrateV0ToV1<crate::Runtime, ()>,
);

mod cleanup_foreign_investments {
use cfg_types::tokens::CurrencyId;
use frame_support::{
storage::StoragePrefixedMap,
traits::{Get, OnRuntimeUpgrade},
weights::Weight,
};
#[cfg(feature = "try-runtime")]
use runtime_common::migrations::utils::count_storage_keys;
use runtime_common::migrations::utils::remove_undecodable_storage_keys;
#[cfg(feature = "try-runtime")]
use sp_runtime::DispatchError;
#[cfg(feature = "try-runtime")]
use sp_runtime::SaturatedConversion;

pub struct Migration<T>(sp_std::marker::PhantomData<T>);

const LOG_PREFIX: &str = "CleanupForeignInvestments";
impl<T> OnRuntimeUpgrade for Migration<T>
where
T: pallet_foreign_investments::Config + frame_system::Config,
{
fn on_runtime_upgrade() -> Weight {
log::info!("{LOG_PREFIX} Initiating removal of undecodable keys");
let (reads, writes) = remove_undecodable_storage_keys::<CurrencyId>(
pallet_foreign_investments::ForeignInvestmentInfo::<T>::final_prefix(),
);

log::info!("{LOG_PREFIX} Removed {writes} undecodable keys");

T::DbWeight::get().reads_writes(reads, writes)
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, DispatchError> {
let n: u32 = count_storage_keys(
pallet_foreign_investments::ForeignInvestmentInfo::<T>::final_prefix(),
);
let n_count: u32 = pallet_foreign_investments::ForeignInvestmentInfo::<T>::iter_keys()
.count()
.saturated_into();

if n == n_count {
log::info!(
"{LOG_PREFIX} Storage cleanup can be skipped because all keys can be decoded"
);
} else {
log::info!(
"{LOG_PREFIX} Failed to decode {} keys, cleanup necessary",
n.saturating_sub(n_count)
);
}

log::info!("{LOG_PREFIX} pre_upgrade done!",);

Ok(sp_std::vec![])
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_pre_state: sp_std::vec::Vec<u8>) -> Result<(), DispatchError> {
let n: u32 = count_storage_keys(
pallet_foreign_investments::ForeignInvestmentInfo::<T>::final_prefix(),
);
let n_count: u32 = pallet_foreign_investments::ForeignInvestmentInfo::<T>::iter_keys()
.count()
.saturated_into();
assert_eq!(n, n_count);

log::info!("{LOG_PREFIX} post_upgrade done with {n} remaining storage keys!",);

Ok(())
}
}
}
pub type UpgradeDevelopment1102 = ();

0 comments on commit 265e509

Please sign in to comment.