Skip to content

Commit

Permalink
remove old migrations and bump up version for centrifuge runtime (#1794)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm authored Apr 3, 2024
1 parent a35def2 commit dc0952e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 62 deletions.
2 changes: 1 addition & 1 deletion 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 runtime/centrifuge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "centrifuge-runtime"
version = "0.10.28"
version = "0.10.29"
build = "build.rs"
authors.workspace = true
edition.workspace = true
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 @@ -154,7 +154,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("centrifuge"),
impl_name: create_runtime_str!("centrifuge"),
authoring_version: 1,
spec_version: 1028,
spec_version: 1029,
impl_version: 1,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
Expand Down Expand Up @@ -2062,7 +2062,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
migrations::UpgradeCentrifuge1028,
migrations::UpgradeCentrifuge1029,
>;

// Frame Order in this block dictates the index of each one in the metadata
Expand Down
59 changes: 1 addition & 58 deletions runtime/centrifuge/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,4 @@

/// The migration set for Centrifuge @ Polkadot.
/// It includes all the migrations that have to be applied on that chain.
pub type UpgradeCentrifuge1028 = migrate_anemoy_external_prices::Migration<super::Runtime>;

mod migrate_anemoy_external_prices {
use cfg_primitives::PoolId;
use cfg_traits::data::DataRegistry;
use cfg_types::oracles::OracleKey;
use frame_support::{traits::OnRuntimeUpgrade, weights::Weight};
use pallet_loans::{entities::pricing::ActivePricing, WeightInfo};

const LOG_PREFIX: &str = "MigrateAnemoyPrices:";
const ANEMOY_POOL_ID: PoolId = 4139607887;
/// Simply bumps the storage version of a pallet
///
/// NOTE: Use with caution! Must ensure beforehand that a migration is not
/// necessary
pub struct Migration<R>(sp_std::marker::PhantomData<R>);
impl<R> OnRuntimeUpgrade for Migration<R>
where
R: pallet_loans::Config<PoolId = PoolId, PriceId = OracleKey>
+ pallet_oracle_collection::Config<CollectionId = PoolId, OracleKey = OracleKey>,
{
fn on_runtime_upgrade() -> Weight {
log::info!("{LOG_PREFIX}: STARTING Migrating Anemoy Price Ids.");
let active_loans = pallet_loans::ActiveLoans::<R>::get(ANEMOY_POOL_ID);
active_loans.clone().into_iter().for_each(|(_, loan)| {
if let ActivePricing::External(pricing) = loan.pricing() {
match pallet_oracle_collection::Pallet::<R>::register_id(
&pricing.price_id(),
&ANEMOY_POOL_ID,
) {
Ok(_) => {
log::info!("{LOG_PREFIX}: Registered PriceId: {:?}", pricing.price_id())
}
Err(e) => log::info!(
"{LOG_PREFIX}: Failed to register PriceId: {:?}, with error: {:?}.",
pricing.price_id(),
e
),
}
}
});

log::info!("{LOG_PREFIX}: FINISHED Migrating Anemoy Price Ids.");
<R as pallet_loans::Config>::WeightInfo::create()
.saturating_mul(active_loans.len() as u64)
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, sp_runtime::DispatchError> {
Ok(sp_std::vec![])
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_: sp_std::vec::Vec<u8>) -> Result<(), sp_runtime::DispatchError> {
Ok(())
}
}
}
pub type UpgradeCentrifuge1029 = ();

0 comments on commit dc0952e

Please sign in to comment.