Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into polkadot-v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Apr 3, 2024
2 parents 3fae0a8 + dc0952e commit 39b3677
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 63 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 @@ -152,7 +152,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 @@ -2052,7 +2052,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 = ();
2 changes: 1 addition & 1 deletion runtime/common/src/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<O: OriginTrait> Ord for Feeder<O> {
fn cmp(&self, other: &Self) -> sp_std::cmp::Ordering {
// Since the inner object could not be Ord,
// we compare their encoded representations
self.0.encode().cmp(&other.encode())
self.0.encode().cmp(&other.0.encode())
}
}

Expand Down

0 comments on commit 39b3677

Please sign in to comment.