Skip to content

Commit

Permalink
Resolve TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Mar 18, 2024
1 parent 994ca0d commit 1cbc702
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions pallets/static-price-provider/src/lib.rs
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ pub mod pallet {
use super::*;

/// The current storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
@@ -118,8 +118,8 @@ pub mod pallet {
pub struct ActivePriceUpdate<T, P>(PhantomData<(T, P)>);
impl<T: Config, P: Get<FixedU128>> OnRuntimeUpgrade for ActivePriceUpdate<T, P> {
fn on_runtime_upgrade() -> Weight {
if Pallet::<T>::on_chain_storage_version() > 1 {
return Weight::zero();
if Pallet::<T>::on_chain_storage_version() != 1 {
return T::DbWeight::get().reads(1);
}

let init_price = P::get().max(FixedU128::from_rational(1, FixedU128::DIV.into()));
@@ -128,6 +128,6 @@ impl<T: Config, P: Get<FixedU128>> OnRuntimeUpgrade for ActivePriceUpdate<T, P>

StorageVersion::new(2).put::<Pallet<T>>();

T::DbWeight::get().writes(2)
T::DbWeight::get().reads_writes(1, 2)
}
}
8 changes: 7 additions & 1 deletion runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1154,10 +1154,16 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

use astar_primitives::oracle::CurrencyAmount;
parameter_types! {
// Keep it exactly the same as before
pub const InitPrice: CurrencyAmount = CurrencyAmount::from_rational(18, 100);
}

/// All migrations that will run on the next runtime upgrade.
///
/// Once done, migrations should be removed from the tuple.
pub type Migrations = (pallet_contracts::Migration<Runtime>,);
pub type Migrations = (pallet_static_price_provider::ActivePriceUpdate<Runtime, InitPrice>,);

type EventRecord = frame_system::EventRecord<
<Runtime as frame_system::Config>::RuntimeEvent,
2 changes: 1 addition & 1 deletion runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
@@ -174,7 +174,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("shibuya"),
impl_name: create_runtime_str!("shibuya"),
authoring_version: 1,
spec_version: 125, // TODO: revert this
spec_version: 123,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
16 changes: 5 additions & 11 deletions runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1105,22 +1105,16 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

use astar_primitives::oracle::CurrencyAmount;
parameter_types! {
pub const DappStakingMigrationName: &'static str = "DappStakingMigration";
// Keep it exactly the same as before
pub const InitPrice: CurrencyAmount = CurrencyAmount::from_rational(32, 100);
}

/// All migrations that will run on the next runtime upgrade.
///
/// Once done, migrations should be removed from the tuple.
pub type Migrations = (
// Part of shiden-119
frame_support::migrations::RemovePallet<
DappStakingMigrationName,
<Runtime as frame_system::Config>::DbWeight,
>,
// Part of shiden-119
RecalculationEraFix,
pallet_contracts::Migration<Runtime>,
);
pub type Migrations = (pallet_static_price_provider::ActivePriceUpdate<Runtime, InitPrice>,);

use frame_support::traits::OnRuntimeUpgrade;
pub struct RecalculationEraFix;

0 comments on commit 1cbc702

Please sign in to comment.