Skip to content

Commit

Permalink
Unbonding period for Shiden (#561)
Browse files Browse the repository at this point in the history
* Unbonding period for Shiden

* Local runtime version bump
  • Loading branch information
Dinonard authored Feb 1, 2022
1 parent ffb7608 commit 08c5843
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 33 deletions.
12 changes: 6 additions & 6 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 = "3.5.0"
version = "3.6.0"
authors = ["Stake Technologies <devops@stake.co.jp>"]
description = "Astar collator implementation in Rust."
build = "build.rs"
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 = "3.5.0"
version = "3.6.0"
authors = ["Stake Technologies <devops@stake.co.jp>"]
edition = "2018"
build = "build.rs"
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 = "3.5.0"
version = "3.6.0"
authors = ["Stake Technologies <devops@stake.co.jp>"]
edition = "2018"
build = "build.rs"
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 = "3.5.0"
version = "3.6.0"
authors = ["Stake Technologies <devops@stake.co.jp>"]
edition = "2018"
build = "build.rs"
Expand Down
4 changes: 2 additions & 2 deletions runtime/shiden/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shiden-runtime"
version = "3.5.0"
version = "3.6.0"
authors = ["Stake Technologies <devops@stake.co.jp>"]
edition = "2018"
build = "build.rs"
Expand Down Expand Up @@ -82,7 +82,7 @@ try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "p
pallet-block-reward = { git = "https://github.com/AstarNetwork/astar-frame", tag = "pallet-block-reward-3.0.0/polkadot-0.9.13", default-features = false }
pallet-custom-signatures = { git = "https://github.com/AstarNetwork/astar-frame", tag = "pallet-custom-signatures-4.3.0/polkadot-0.9.13", default-features = false }
pallet-precompile-staking = { git = "https://github.com/AstarNetwork/astar-frame", tag = "pallet-precompile-staking-0.2.1/polkadot-0.9.13", default-features = false }
pallet-dapps-staking = { git = "https://github.com/AstarNetwork/astar-frame", tag = "pallet-dapps-staking-1.1.2/polkadot-0.9.13", default-features = false }
pallet-dapps-staking = { git = "https://github.com/AstarNetwork/astar-frame", tag = "pallet-dapps-staking-2.0.0/polkadot-0.9.13", default-features = false }

[build-dependencies]
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.13" }
Expand Down
30 changes: 28 additions & 2 deletions runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use codec::{Decode, Encode};
use frame_support::{
construct_runtime, parameter_types,
traits::{Contains, Currency, FindAuthor, Imbalance, OnUnbalanced},
traits::{Contains, Currency, FindAuthor, Imbalance, OnRuntimeUpgrade, OnUnbalanced},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, WEIGHT_PER_SECOND},
DispatchClass, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
Expand Down Expand Up @@ -86,7 +86,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("shiden"),
impl_name: create_runtime_str!("shiden"),
authoring_version: 1,
spec_version: 35,
spec_version: 36,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down Expand Up @@ -274,6 +274,8 @@ parameter_types! {
pub const MinimumRemainingAmount: Balance = 1 * SDN;
pub const HistoryDepth: u32 = 14;
pub const BonusEraDuration: u32 = 10;
pub const MaxUnlockingChunks: u32 = 5;
pub const UnbondingPeriod: u32 = 5;
}

impl pallet_dapps_staking::Config for Runtime {
Expand All @@ -290,6 +292,8 @@ impl pallet_dapps_staking::Config for Runtime {
type MinimumRemainingAmount = MinimumRemainingAmount;
type HistoryDepth = HistoryDepth;
type BonusEraDuration = BonusEraDuration;
type MaxUnlockingChunks = MaxUnlockingChunks;
type UnbondingPeriod = UnbondingPeriod;
}

/// Multi-VM pointer to smart contract instance.
Expand Down Expand Up @@ -740,8 +744,30 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(DappsStakingMigrationV2,),
>;

// Migration for supporting unbonding period in dapps staking.
pub struct DappsStakingMigrationV2;

impl OnRuntimeUpgrade for DappsStakingMigrationV2 {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
pallet_dapps_staking::migrations::v2::stateful_migrate::<Runtime>(
RuntimeBlockWeights::get().max_block / 5 * 3,
)
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
pallet_dapps_staking::migrations::v2::pre_migrate::<Runtime, Self>()
}

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_dapps_staking::migrations::v2::post_migrate::<Runtime, Self>()
}
}

impl fp_self_contained::SelfContainedCall for Call {
type SignedInfo = H160;

Expand Down
46 changes: 27 additions & 19 deletions runtime/shiden/src/weights/pallet_dapps_staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
//! Autogenerated weights for `pallet_dapps_staking`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-10-25, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-testnet"), DB CACHE: 128
//! DATE: 2021-11-30, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shiden-dev"), DB CACHE: 128

// Executed Command:
// ./target/release/astar-collator
// benchmark
// --chain
// shiden-testnet
// shiden-dev
// --execution
// wasm
// --wasm-execution
Expand All @@ -33,14 +33,14 @@
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weight functions for pallet_dapps_staking.
/// Weight functions for `pallet_dapps_staking`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_dapps_staking::WeightInfo for WeightInfo<T> {
// Storage: DappsStaking RegisteredDevelopers (r:1 w:1)
// Storage: DappsStaking RegisteredDapps (r:1 w:1)
// Storage: DappsStaking PreApprovalIsEnabled (r:1 w:0)
fn register() -> Weight {
(68_206_000 as Weight)
(39_297_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
Expand All @@ -52,22 +52,22 @@ impl<T: frame_system::Config> pallet_dapps_staking::WeightInfo for WeightInfo<T>
// Storage: DappsStaking Ledger (r:25 w:25)
// Storage: Balances Locks (r:25 w:25)
fn unregister(n: u32, ) -> Weight {
(417_315_000 as Weight)
// Standard Error: 370_000
.saturating_add((43_644_000 as Weight).saturating_mul(n as Weight))
(0 as Weight)
// Standard Error: 146_000
.saturating_add((29_171_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight)))
}
// Storage: DappsStaking PreApprovalIsEnabled (r:0 w:1)
fn enable_developer_pre_approval() -> Weight {
(3_093_000 as Weight)
(1_694_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: DappsStaking PreApprovedDevelopers (r:1 w:1)
fn developer_pre_approval() -> Weight {
(10_097_000 as Weight)
(5_210_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
Expand All @@ -79,37 +79,45 @@ impl<T: frame_system::Config> pallet_dapps_staking::WeightInfo for WeightInfo<T>
// Storage: DappsStaking EraRewardsAndStakes (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn bond_and_stake() -> Weight {
(351_300_000 as Weight)
(226_591_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: DappsStaking RegisteredDapps (r:1 w:0)
// Storage: DappsStaking RegisteredDevelopers (r:1 w:0)
// Storage: DappsStaking CurrentEra (r:1 w:0)
// Storage: DappsStaking ContractEraStake (r:3 w:1)
// Storage: DappsStaking ContractEraStake (r:1 w:1)
// Storage: DappsStaking Ledger (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: DappsStaking EraRewardsAndStakes (r:1 w:1)
fn unbond_unstake_and_withdraw() -> Weight {
(379_690_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
fn unbond_and_unstake() -> Weight {
(221_721_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: DappsStaking Ledger (r:1 w:1)
// Storage: DappsStaking CurrentEra (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
fn withdraw_unbonded() -> Weight {
(82_365_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: DappsStaking RegisteredDapps (r:1 w:0)
// Storage: DappsStaking CurrentEra (r:1 w:0)
// Storage: DappsStaking ContractEraStake (r:1 w:1)
// Storage: DappsStaking EraRewardsAndStakes (r:1 w:0)
// Storage: Balances TotalIssuance (r:1 w:1)
fn claim(n: u32, ) -> Weight {
(80_743_000 as Weight)
// Standard Error: 30_000
.saturating_add((9_858_000 as Weight).saturating_mul(n as Weight))
(70_778_000 as Weight)
// Standard Error: 15_000
.saturating_add((5_258_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: DappsStaking ForceEra (r:0 w:1)
fn force_new_era() -> Weight {
(3_082_000 as Weight)
(1_854_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}

0 comments on commit 08c5843

Please sign in to comment.