Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
c8ac431
Implement RFC-0097
Apr 21, 2025
b40c592
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Apr 28, 2025
fca892e
Improve test with pagination
Apr 28, 2025
a0d58ea
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Apr 29, 2025
c350589
Add checks in ahm-tests
Apr 29, 2025
848c8ba
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Apr 30, 2025
4bdb6aa
Fix clippy issues
Apr 30, 2025
14ef617
Add prdoc
Apr 30, 2025
92d6b68
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 1, 2025
7e7b49c
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 2, 2025
be0a586
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 5, 2025
0c9d92c
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 6, 2025
97676f0
Add extra test
May 6, 2025
e59ad8f
Use pico-eras to measure time
May 8, 2025
2b05b98
Handle the rebonding scenario
May 8, 2025
1066355
Only round up if needed
May 8, 2025
2191a81
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 8, 2025
c819eb8
Search for unbonding slots throughout the whole unbonding queue
May 9, 2025
aa3d40c
Improve code structure and test
May 9, 2025
f973e3d
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 9, 2025
1866f07
Move back_of_unbonding_queue as a separate storage item
May 9, 2025
0f7d125
Remove max_bonding_duration function
May 9, 2025
7cdf802
Create view functions
May 9, 2025
4d21ca1
Improve test "calculate_lowest_total_stake_works"
May 9, 2025
88449ef
Add extra function to ExtBuilder
May 9, 2025
3d05285
Simplify unbonding queue config in mock
May 12, 2025
92770bf
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 12, 2025
11372b8
Fix benchmarks
May 12, 2025
195fd67
Polish ahm-test dependencies
May 12, 2025
c660d41
Fix compilation issues
May 12, 2025
0866132
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 12, 2025
d67975c
Update prdoc bumps
May 12, 2025
4766e3b
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 13, 2025
827af56
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 13, 2025
4f3cbeb
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 14, 2025
0733988
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 15, 2025
1312eeb
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 16, 2025
4aa9fb6
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 19, 2025
ad5b1d1
Fix documentation
May 19, 2025
5fa2f51
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 20, 2025
5c6a263
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 26, 2025
4d312e6
Reimplement the logic
May 27, 2025
b79a90d
Fix all tests
May 28, 2025
69e32e2
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 28, 2025
d9b4e71
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 28, 2025
e0ba2fa
Add test to withdraw funds
May 28, 2025
57a5747
Add more tests for withdrawal
May 28, 2025
9dda79a
Add extra test to calculate the unbonding duration
May 28, 2025
03b5965
Update documentation
May 28, 2025
32a3e35
Update runtime api
May 28, 2025
e2fbceb
Implement new runtime api
May 28, 2025
7c31a09
Rename view function
May 29, 2025
9568a4b
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 29, 2025
8c5c44c
Fix prdoc
May 29, 2025
330eed6
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 29, 2025
0e95a96
Increase minimum bond duration to 2 eras
May 29, 2025
b2eafa8
Add extra checks when unbonding
May 29, 2025
c76b691
Add extra checks for new storage items
May 29, 2025
eea716f
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 29, 2025
27bb7e9
Merge remote-tracking branch 'origin/master' into RFC-0097-port
May 30, 2025
22c23d3
Add test to delay expected withdrawal by unbonding a huge amount
May 30, 2025
1c59638
Improve tests
May 30, 2025
e42c8a3
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 2, 2025
34e1abd
Add multi-block migration
Jun 2, 2025
f496c42
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 2, 2025
e8c5104
Add benchmarks and weights
Jun 3, 2025
ba1b1a7
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 3, 2025
3c3e8ee
Add pre and post checks to the migration
Jun 3, 2025
e3d1813
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 3, 2025
41f0885
Fix era in tests
Jun 3, 2025
16ceaf5
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 4, 2025
0298cfe
Fix default-features
Jun 4, 2025
45739ba
fmt
Jun 4, 2025
a0b7e6b
Fix clippy issues again
Jun 4, 2025
686a956
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 4, 2025
3dea491
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 6, 2025
b220761
Update prdoc
Jun 6, 2025
cd4ff76
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 9, 2025
8413a9e
Address feedback
Jun 10, 2025
8553273
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 10, 2025
3e57c94
Link ErasLowestRatioTotalStake and Eras
Jun 10, 2025
926aecd
Format
Jun 11, 2025
f45f8a4
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 11, 2025
6229768
Add mbm to runtime
Jun 11, 2025
637884c
Fix compilation error in benchmarks
Jun 11, 2025
8c532bf
Reset preset to development
Jun 11, 2025
77386c3
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 11, 2025
0483d2f
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 12, 2025
3542c3a
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 13, 2025
87e0466
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 16, 2025
08338a9
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 18, 2025
45903a8
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 18, 2025
50d209e
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 19, 2025
d2c99ca
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 20, 2025
940d131
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 23, 2025
75d6a9c
Update prdoc
Jun 24, 2025
6c39d58
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 24, 2025
36e2114
fmt
Jun 24, 2025
e860939
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 25, 2025
522ef70
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 26, 2025
8bd21b4
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 27, 2025
550d394
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jun 30, 2025
2fd16f4
Remove migration from dev chain
Jun 30, 2025
1cbe511
Add the migration to westend AH
Jun 30, 2025
8e74321
Remove no longer needed benchmark setup
Jul 1, 2025
bdb80eb
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jul 1, 2025
20af53e
Improve benchmarks
Jul 1, 2025
d0597b0
Improve documentation
Jul 1, 2025
a8217ba
Improve unbonding queue curating logic
Jul 1, 2025
ba083d8
Improve unbonding logic
Jul 1, 2025
0f1ae18
Allow multiple chunks to be released in the same era
Jul 1, 2025
5ef323f
Update prdoc
Jul 1, 2025
8cb1c10
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jul 3, 2025
c230572
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jul 7, 2025
69ce1c1
Include weight implementation
Jul 8, 2025
005bef5
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jul 14, 2025
408feba
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Jul 24, 2025
f6cb997
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Aug 4, 2025
7546c99
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Aug 4, 2025
f2972c4
Rename TotalUnbondInEra -> ErasTotalUnbond
Aug 4, 2025
96d4226
Use Rotator::planned_era()
Aug 4, 2025
468c0c1
Use ValueQuery for ErasTotalUnbond
Aug 4, 2025
7720b6e
Remove runtime-benchmark dependencies from pallet-ahm-test
Aug 4, 2025
2079d89
Rename variable for clarity
Aug 4, 2025
4456c23
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Aug 4, 2025
ebe47f5
Remove unintended change
Aug 4, 2025
6d77785
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Aug 8, 2025
4522c4f
Rename BondingDuration -> MaxUnbondingDuration
Aug 11, 2025
509cae6
Add extra check when setting the lower unbonding time
Aug 11, 2025
6c98c6b
Improve comment
Aug 11, 2025
36015ce
Fix typo
Aug 11, 2025
f46842e
Add runtime api to query estimated unbonding duration
Aug 11, 2025
468edb6
Use MaxUnbondingDuration for migration benchmarks
Aug 12, 2025
6a30cb4
Use existing error variant
Aug 12, 2025
14ce7ba
Use more idiomatic Rust
Aug 12, 2025
9ae727a
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Aug 12, 2025
19a5d2e
Fix compilation issuFix compilation issue
Aug 12, 2025
e69da63
Calculate correctly the earliest withdrawal era
Aug 12, 2025
f66eaa1
Merge remote-tracking branch 'origin/master' into RFC-0097-port
Aug 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,10 @@ parameter_types! {
impl pallet_migrations::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
#[cfg(not(feature = "runtime-benchmarks"))]
type Migrations = pallet_revive::migrations::v1::Migration<Runtime>;
type Migrations = (
pallet_revive::migrations::v1::Migration<Runtime>,
pallet_staking_async::migrations::v18::LazyMigrationV17ToV18<Runtime>,
);
// Benchmarks need mocked migrations to guarantee that they succeed.
#[cfg(feature = "runtime-benchmarks")]
type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ parameter_types! {
/// Duration of a relay session in our blocks. Needs to be hardcoded per-runtime.
pub const RelaySessionDuration: BlockNumber = 1 * HOURS;
// 2 eras for unbonding (12 hours).
pub const BondingDuration: sp_staking::EraIndex = 2;
pub const MaxUnbondingDuration: sp_staking::EraIndex = 2;
// 1 era in which slashes can be cancelled (6 hours).
pub const SlashDeferDuration: sp_staking::EraIndex = 1;
pub const MaxControllersInDeprecationBatch: u32 = 751;
Expand All @@ -276,7 +276,7 @@ impl pallet_staking_async::Config for Runtime {
type Slash = ();
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type MaxUnbondingDuration = MaxUnbondingDuration;
type SlashDeferDuration = SlashDeferDuration;
type AdminOrigin = EitherOf<EnsureRoot<AccountId>, StakingAdmin>;
type EraPayout = EraPayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,4 +917,17 @@ impl<T: frame_system::Config> pallet_staking_async::WeightInfo for WeightInfo<T>
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(v.into())))
.saturating_add(Weight::from_parts(0, 2749).saturating_mul(v.into()))
}

/// Storage: `Staking::Ledger` (r:2 w:1)
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1265), added: 3740, mode: `MaxEncodedLen`)
/// The range of component `c` is `[1, 32]`.
fn migration_from_v17_to_v18_migrate_staking_ledger_step(_c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `698 + c * (3 ±0)`
// Estimated: `8470`
// Minimum execution time: 45_000_000 picoseconds.
Weight::from_parts(60_791_228, 8470)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
54 changes: 54 additions & 0 deletions prdoc/pr_8298.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
title: 'Implementation of RFC-0097: Unbonding Queue for pallet-staking-async'
doc:
- audience: [Runtime Dev, Runtime User]
description: |
# Description
This PR implements [RFC-0097](https://polkadot-fellows.github.io/RFCs/approved/0097-unbonding_queue.html) and its
[modification](https://hackmd.io/@vKfUEAWlRR2Ogaq8nYYknw/SyfioMGWgl), which introduces a variable unbonding time
mechanism to improve the security-liquidity trade-off in the staking system.

The unbonding queue allows for faster unbonding of staked tokens while maintaining network security by keeping a
minimum slashable share of stake locked for the full unbonding period.

### Modified extrinsics:
- `unbond`: Enhanced to work with the unbonding queue mechanism, calculating variable unbonding times based on stake distribution.
- `withdraw_unbonded`: Modified to handle withdrawals from the unbonding queue with different unlock periods.
- `rebond`: Updated to work with the queue-based unbonding system.

### Storage items:
- `ElectableStashes`: Added the stake backing up a given electable stash account.
- `UnbondingQueueParams`: New storage item containing configuration parameters:
- `min_slashable_share`: The minimum share of stake of the lowest backed validators that must remain slashable at any point in time.
- `lowest_ratio`: The proportion of the lowest-backed validator set.
- `unbond_period_lower_bound`: Minimum unbonding time in eras.
- `ErasLowestRatioTotalStake`: Tracks the lowest stake proportion among validators in each era.
- `ErasTotalUnbond`: Tracks the stake that started unbonding in a given era.
- `Ledger`: Added `previous_unbonded_stake` to track the accumulated stake to be unbonded at the time a given unlock chunk was created.

### View functions:
- `unbonding_duration`: Used to obtain the list of funds that will be released at a given era.

## Key features:
1. Variable unbonding time: Unbonding time varies based on the amount of stake in the system.
2. Security maintenance: Ensures a sufficient percentage of stake remains slashable at all times.
3. Unbonding queue management: Implements an efficient queue system for managing unbonding requests.

### Migration v18:
Includes multi-block migration `LazyMigrationV17ToV18` that:
- Updates `StakingLedger` structure to include the new `previous_unbonded_stake` field in `UnlockChunk`.
- Migrates `ElectableStashes` from set-based to map-based storage (AccountId -> Balance mapping).
- Performs era adjustment for existing unlock chunks by subtracting the bonding duration.
- Uses stepped migration pattern to handle large datasets efficiently across multiple blocks.
- Includes comprehensive pre/post-upgrade checks for data integrity.

crates:
- name: pallet-staking-async-parachain-runtime
bump: minor
- name: pallet-staking-async-runtime-api
bump: minor
- name: pallet-staking-async
bump: major
- name: sp-staking
bump: patch
- name: asset-hub-westend-runtime
bump: major
4 changes: 4 additions & 0 deletions substrate/frame/staking-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ frame-election-provider-support = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
log = { workspace = true }
pallet-migrations = { workspace = true, default-features = false }
pallet-staking-async-rc-client = { workspace = true }
rand = { features = ["alloc"], workspace = true }
rand_chacha = { workspace = true }
Expand Down Expand Up @@ -59,6 +60,7 @@ std = [
"log/std",
"pallet-bags-list/std",
"pallet-balances/std",
"pallet-migrations/std",
"pallet-staking-async-rc-client/std",
"rand/std",
"rand_chacha/std",
Expand All @@ -80,6 +82,7 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
"pallet-staking-async-rc-client/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
Expand All @@ -90,6 +93,7 @@ try-runtime = [
"frame-system/try-runtime",
"pallet-bags-list/try-runtime",
"pallet-balances/try-runtime",
"pallet-migrations/try-runtime",
"pallet-staking-async-rc-client/try-runtime",
"sp-runtime/try-runtime",
]
2 changes: 0 additions & 2 deletions substrate/frame/staking-async/ahm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ frame = { workspace = true, default-features = true }
frame-support = { workspace = true, default-features = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true, default-features = true }
sp-core = { workspace = true, default-features = true }
sp-session = { workspace = true, default-features = true }
sp-staking = { workspace = true, default-features = true }
sp-tracing = { workspace = true, default-features = true }

Expand Down
11 changes: 8 additions & 3 deletions substrate/frame/staking-async/ahm-test/src/ah/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub(crate) fn roll_until_next_active(mut end_index: SessionIndex) -> Vec<Account
leftover: false,
// arbitrary, feel free to change if test setup updates
new_validator_set: vec![3, 5, 6, 8],
prune_up_to: active_era.checked_sub(BondingDuration::get()),
prune_up_to: active_era.checked_sub(MaxUnbondingDuration::get()),
})
)
);
Expand Down Expand Up @@ -312,7 +312,7 @@ impl multi_block::signed::Config for Runtime {
}

parameter_types! {
pub static BondingDuration: u32 = 3;
pub static MaxUnbondingDuration: u32 = 3;
pub static SlashDeferredDuration: u32 = 2;
pub static SessionsPerEra: u32 = 6;
pub static PlanningEraOffset: u32 = 2;
Expand All @@ -323,7 +323,7 @@ impl pallet_staking_async::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;

type AdminOrigin = EnsureRoot<AccountId>;
type BondingDuration = BondingDuration;
type MaxUnbondingDuration = MaxUnbondingDuration;
type SessionsPerEra = SessionsPerEra;
type PlanningEraOffset = PlanningEraOffset;

Expand Down Expand Up @@ -490,6 +490,11 @@ impl ExtBuilder {
validator_count: 4,
active_era: (0, 0, 0),
force_era: if self.pre_migration { Forcing::ForceNone } else { Forcing::default() },
unbonding_queue_config: Some(pallet_staking_async::UnbondingQueueConfig {
min_slashable_share: Perbill::from_percent(50),
lowest_ratio: Perbill::from_percent(34),
unbond_period_lower_bound: 2,
}),
..Default::default()
}
.assimilate_storage(&mut t)
Expand Down
9 changes: 8 additions & 1 deletion substrate/frame/staking-async/ahm-test/src/ah/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame_support::assert_ok;
use pallet_election_provider_multi_block::{Event as ElectionEvent, Phase};
use pallet_staking_async::{
self as staking_async, session_rotation::Rotator, ActiveEra, ActiveEraInfo, CurrentEra,
Event as StakingEvent,
ErasLowestRatioTotalStake, Event as StakingEvent,
};
use pallet_staking_async_rc_client::{self as rc_client, UnexpectedKind, ValidatorSetReport};

Expand Down Expand Up @@ -102,6 +102,9 @@ fn on_receive_session_report() {
);
}

// The lowest stake proportion is zero before the election occurs.
assert_eq!(ErasLowestRatioTotalStake::<T>::iter().collect::<Vec<_>>(), vec![]);

// Next session we will begin election.
assert_ok!(rc_client::Pallet::<T>::relay_session_report(
RuntimeOrigin::root(),
Expand Down Expand Up @@ -196,6 +199,10 @@ fn on_receive_session_report() {
})
)]
);

// After the election, the stake backing the lowest third is composed of only one validator
// backed with 100.
assert_eq!(ErasLowestRatioTotalStake::<T>::iter().collect::<Vec<_>>(), vec![(1, 100)]);
})
}

Expand Down
9 changes: 9 additions & 0 deletions substrate/frame/staking-async/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

use alloc::vec::Vec;
use codec::Codec;

sp_api::decl_runtime_apis! {
Expand All @@ -35,5 +38,11 @@ sp_api::decl_runtime_apis! {

/// Returns true if validator `account` has pages to be claimed for the given era.
fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool;

/// Returns a list of (era, amount) that indices at which era unbonded funds will be unlocked.
fn unbonding_duration(account: AccountId) -> Vec<(sp_staking::EraIndex, Balance)>;

/// Returns the estimated number of eras for unbonding a given amount.
fn estimate_unbonding_duration(amount: Balance) -> sp_staking::EraIndex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ fn staking_async_parachain_genesis(params: GenesisParams, preset: String) -> ser
.into_iter()
.map(|acc| (acc, endowment / 2, StakerStatus::Validator))
.collect(),
unbonding_queue_config: Some(pallet_staking_async::UnbondingQueueConfig {
min_slashable_share: Perbill::from_percent(50),
lowest_ratio: Perbill::from_percent(34),
unbond_period_lower_bound: 0,
}),
..Default::default()
}
})
Expand Down
8 changes: 8 additions & 0 deletions substrate/frame/staking-async/runtimes/parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,14 @@ impl_runtime_apis! {
fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool {
Staking::api_pending_rewards(era, account)
}

fn unbonding_duration(account: AccountId) -> Vec<(sp_staking::EraIndex, Balance)> {
Staking::unbonding_duration(account)
}

fn estimate_unbonding_duration(amount: Balance) -> sp_staking::EraIndex {
Staking::estimate_unbonding_duration(amount)
}
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ parameter_types! {
/// Duration of a relay session in our blocks. Needs to be hardcoded per-runtime.
pub const RelaySessionDuration: BlockNumber = 10;
// 2 eras for unbonding (12 hours).
pub const BondingDuration: sp_staking::EraIndex = 2;
pub const MaxUnbondingDuration: sp_staking::EraIndex = 2;
// 1 era in which slashes can be cancelled (6 hours).
pub const SlashDeferDuration: sp_staking::EraIndex = 1;
// Note: this is not really correct as Max Nominators is (MaxExposurePageSize * page_count) but
Expand All @@ -435,7 +435,7 @@ impl pallet_staking_async::Config for Runtime {
type Slash = ();
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type MaxUnbondingDuration = MaxUnbondingDuration;
type SlashDeferDuration = SlashDeferDuration;
type AdminOrigin = EitherOf<EnsureRoot<AccountId>, StakingAdmin>;
type EraPayout = EraPayout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -900,4 +900,16 @@ impl<T: frame_system::Config> pallet_staking_async::WeightInfo for WeightInfo<T>
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(v.into())))
.saturating_add(Weight::from_parts(0, 3937).saturating_mul(v.into()))
}
/// Storage: `Staking::Ledger` (r:2 w:1)
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(1265), added: 3740, mode: `MaxEncodedLen`)
/// The range of component `c` is `[1, 32]`.
fn migration_from_v17_to_v18_migrate_staking_ledger_step(_c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `698 + c * (3 ±0)`
// Estimated: `8470`
// Minimum execution time: 45_000_000 picoseconds.
Weight::from_parts(60_791_228, 8470)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
Loading
Loading