Skip to content

Commit

Permalink
updated versions + added Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreOssun committed Nov 10, 2023
1 parent bb700ff commit 49eb2a5
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 22 deletions.
10 changes: 5 additions & 5 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 bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astar-collator"
version = "5.24.0"
version = "5.25.0"
description = "Astar collator implementation in Rust."
build = "build.rs"
default-run = "astar-collator"
Expand Down
12 changes: 6 additions & 6 deletions pallets/block-rewards-hybrid/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ fn reward_distribution_config_is_consistent() {
// 4
// 100%
let reward_config = RewardDistributionConfig {
treasury_percent: Perbill::from_percent(3),
base_staker_percent: Perbill::from_percent(14),
dapps_percent: Perbill::from_percent(18),
collators_percent: Perbill::from_percent(31),
adjustable_percent: Perbill::from_percent(34),
ideal_dapps_staking_tvl: Zero::zero(),
treasury_percent: Perbill::from_rational(4663701u32, 100000000u32),
base_staker_percent: Perbill::from_rational(2309024u32, 10000000u32),
dapps_percent: Perbill::from_rational(173094531u32, 1000000000u32),
collators_percent: Perbill::from_rational(29863296u32, 1000000000u32),
adjustable_percent: Perbill::from_rational(519502763u32, 1000000000u32),
ideal_dapps_staking_tvl: Perbill::from_percent(60),
};
assert!(reward_config.is_consistent());
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/astar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astar-runtime"
version = "5.24.0"
version = "5.25.0"
build = "build.rs"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("astar"),
impl_name: create_runtime_str!("astar"),
authoring_version: 1,
spec_version: 71,
spec_version: 72,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down
2 changes: 1 addition & 1 deletion runtime/local/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "local-runtime"
version = "5.23.0"
version = "5.25.0"
build = "build.rs"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl block_rewards_hybrid::BeneficiaryPayout<NegativeImbalance> for BeneficiaryP
}

parameter_types! {
pub const MaxBlockRewardAmount: Balance = 2_664 * MILLIAST;
pub const MaxBlockRewardAmount: Balance = 230_718 * MILLIAST;
}

impl block_rewards_hybrid::Config for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion runtime/shibuya/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shibuya-runtime"
version = "5.24.0"
version = "5.25.0"
build = "build.rs"
authors.workspace = true
edition.workspace = true
Expand Down
40 changes: 37 additions & 3 deletions runtime/shibuya/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!("shibuya"),
impl_name: create_runtime_str!("shibuya"),
authoring_version: 1,
spec_version: 114,
spec_version: 115,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -553,7 +553,7 @@ impl block_rewards_hybrid::BeneficiaryPayout<NegativeImbalance> for BeneficiaryP
}

parameter_types! {
pub const MaxBlockRewardAmount: Balance = 2_530 * MILLISBY;
pub const MaxBlockRewardAmount: Balance = 230_718 * MILLISBY;
}

impl block_rewards_hybrid::Config for Runtime {
Expand Down Expand Up @@ -1312,10 +1312,44 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

pub use frame_support::traits::{OnRuntimeUpgrade, StorageVersion};
pub struct HybridInflationModelMigration;
impl OnRuntimeUpgrade for HybridInflationModelMigration {
fn on_runtime_upgrade() -> Weight {
let mut reward_config = block_rewards_hybrid::RewardDistributionConfig {
// 4.66%
treasury_percent: Perbill::from_rational(4663701u32, 100000000u32),
// 23.09%
base_staker_percent: Perbill::from_rational(2309024u32, 10000000u32),
// 17.31%
dapps_percent: Perbill::from_rational(173094531u32, 1000000000u32),
// 2.99%
collators_percent: Perbill::from_rational(29863296u32, 1000000000u32),
// 51.95%
adjustable_percent: Perbill::from_rational(519502763u32, 1000000000u32),
// 60.00%
ideal_dapps_staking_tvl: Perbill::from_percent(60),
};

// This HAS to be tested prior to update - we need to ensure that config is consistent
#[cfg(feature = "try-runtime")]
assert!(reward_config.is_consistent());

// This should never execute but we need to have code in place that ensures config is consistent
if !reward_config.is_consistent() {
reward_config = Default::default();
}

block_rewards_hybrid::RewardDistributionConfigStorage::<Runtime>::put(reward_config);

<Runtime as frame_system::pallet::Config>::DbWeight::get().writes(1)
}
}

/// All migrations that will run on the next runtime upgrade.
///
/// Once done, migrations should be removed from the tuple.
pub type Migrations = ();
pub type Migrations = HybridInflationModelMigration;

type EventRecord = frame_system::EventRecord<
<Runtime as frame_system::Config>::RuntimeEvent,
Expand Down
2 changes: 1 addition & 1 deletion runtime/shiden/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shiden-runtime"
version = "5.24.0"
version = "5.25.0"
build = "build.rs"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("shiden"),
impl_name: create_runtime_str!("shiden"),
authoring_version: 1,
spec_version: 111,
spec_version: 112,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down

0 comments on commit 49eb2a5

Please sign in to comment.