Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d723499
wip: poc
wischli Jul 20, 2022
82da1d9
refactor: extrinsics and inherents
wischli Jul 28, 2022
03cd34d
refactor: remove storage redundancy
wischli Jul 29, 2022
766c777
tests: fix existing ones for staking
wischli Jul 29, 2022
791ef9c
tests: 80%
wischli Aug 1, 2022
38e92dd
feat: rm delegate_another_candidate and more
wischli Aug 1, 2022
d8bb955
docs: remove deprecated weight
wischli Aug 1, 2022
24dc4bf
Apply suggestions from code review
wischli Aug 2, 2022
7789cda
tests: 100%
wischli Aug 2, 2022
870b534
fix: benchmarks
wischli Aug 3, 2022
8926e4c
feat: remove multiple delegations (#391)
wischli Aug 8, 2022
3dd9c6d
Merge remote-tracking branch 'origin/wf/1930-staking-refactor' into w…
wischli Aug 8, 2022
05f520e
Merge branch 'develop' into wf/1930-staking-refactor
wischli Aug 8, 2022
f8c1419
Apply suggestions from code review
wischli Aug 9, 2022
ad13650
fix: suggestions from @ntn-x2 review
wischli Aug 9, 2022
adbcd46
fmt
wischli Aug 9, 2022
ddebe3a
fix: typos
wischli Aug 9, 2022
28e47ef
Merge remote-tracking branch 'origin/develop' into wf/1930-staking-re…
wischli Aug 10, 2022
7b9fda3
fix: docker file
wischli Aug 11, 2022
3e21d0c
Merge remote-tracking branch 'origin/develop' into wf/1930-staking-re…
wischli Sep 7, 2022
e70c044
feat: add staking rewards runtime api
wischli Sep 8, 2022
b1de42a
docs: add new extrinsics to staking header
wischli Sep 8, 2022
6f73296
feat: add staking rates api
wischli Sep 8, 2022
20fd523
tests: add api
wischli Sep 8, 2022
0f8160b
fix: unify staking runtime api
wischli Sep 9, 2022
420170d
refactor: stricter claiming
wischli Sep 15, 2022
25f1878
Merge remote-tracking branch 'origin/develop' into wf/1930-staking-re…
wischli Sep 15, 2022
a3b2631
fix: easy suggestions from code review
wischli Sep 16, 2022
15424e0
refactor: separate runtime api from custom rpc
wischli Sep 16, 2022
e703493
tests: comp api claim with claiming
wischli Sep 19, 2022
a00364b
refactor: move runtime api calls to mod
wischli Sep 19, 2022
02eb407
stlye: fmt
wischli Sep 19, 2022
379c736
refactor: split api into separate crates
wischli Sep 19, 2022
dfbd9e3
Merge remote-tracking branch 'origin/develop' into wf/1930-staking-re…
wischli Oct 27, 2022
bc0890f
Merge remote-tracking branch 'origin/develop' into wf/1930-staking-re…
wischli Oct 28, 2022
c5548db
Merge remote-tracking branch 'origin/wf/1930-staking-refactor' into w…
wischli Oct 28, 2022
a9f58bc
refactor: simplify staking api name
wischli Oct 28, 2022
01d09bb
refactor: normalize public creds runtime api
wischli Oct 28, 2022
4f30a8a
refactor: machete cleanup
wischli Oct 28, 2022
36e4abd
tests: add safety check to API rewards
wischli Oct 31, 2022
56a5539
style: fmt
wischli Oct 31, 2022
98eab08
Merge branch 'develop' into wf/1930-staking-refactor
wischli Oct 31, 2022
30044dd
feat: write delegator state migration
wischli Sep 16, 2022
55620d2
refactor: remove unneeded no_std flags
wischli Oct 31, 2022
30be731
refactor: Delegator interface functions
wischli Nov 1, 2022
55c6ac3
refactor: rm Option for Delegator.owner
wischli Nov 1, 2022
cd9684e
style: apply turbofish to staking
wischli Nov 1, 2022
f459050
fix: replace RewardCount with two counters
wischli Nov 2, 2022
39e3716
refactor: rm col input for del stake adjustment
wischli Nov 2, 2022
bf304e5
Merge remote-tracking branch 'origin/wf/1930-staking-refactor' into w…
wischli Nov 2, 2022
f87f01e
style: fmt
wischli Nov 3, 2022
f6f73aa
Merge remote-tracking branch 'origin/develop' into wf-1930-staking-re…
wischli Nov 3, 2022
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
Prev Previous commit
Next Next commit
docs: remove deprecated weight
  • Loading branch information
wischli committed Aug 1, 2022
commit d8bb95564ec38a0af7acca2968f152009e19d086
106 changes: 0 additions & 106 deletions pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,6 @@ pub mod pallet {
/// ShouldEndSession<_>>::should_end_session.
///
/// The dispatch origin must be Root.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: [Origin Account]
/// - Writes: ForceNewRound
/// # </weight>
#[pallet::weight(<T as pallet::Config>::WeightInfo::set_inflation())]
pub fn force_new_round(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
Expand All @@ -769,12 +763,6 @@ pub mod pallet {
/// The dispatch origin must be Root.
///
/// Emits `RoundInflationSet`.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: [Origin Account]
/// - Writes: InflationConfig
/// # </weight>
#[pallet::weight(<T as pallet::Config>::WeightInfo::set_inflation())]
pub fn set_inflation(
origin: OriginFor<T>,
Expand Down Expand Up @@ -831,20 +819,6 @@ pub mod pallet {
/// The dispatch origin must be Root.
///
/// Emits `MaxSelectedCandidatesSet`.
///
///
/// # <weight>
/// - The transaction's complexity is mainly dependent on updating the
/// `SelectedCandidates` storage in `select_top_candidates` which in
/// return depends on the number of `MaxSelectedCandidates` (N).
/// - For each N, we read `CandidatePool` from the storage.
/// ---------
/// Weight: O(N + D) where N is `MaxSelectedCandidates` bounded by
/// `MaxTopCandidates` and D is the number of delegators of a
/// candidate bounded by `MaxDelegatorsPerCollator`.
/// - Reads: MaxSelectedCandidates, TopCandidates, N * CandidatePool
/// - Writes: MaxSelectedCandidates
/// # </weight>
#[pallet::weight(<T as pallet::Config>::WeightInfo::set_max_selected_candidates(
*new,
T::MaxDelegatorsPerCollator::get()
Expand Down Expand Up @@ -913,12 +887,6 @@ pub mod pallet {
/// The dispatch origin must be Root.
///
/// Emits `BlocksPerRoundSet`.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: [Origin Account], Round
/// - Writes: Round
/// # </weight>
#[pallet::weight(<T as pallet::Config>::WeightInfo::set_blocks_per_round())]
pub fn set_blocks_per_round(origin: OriginFor<T>, new: T::BlockNumber) -> DispatchResult {
ensure_root(origin)?;
Expand Down Expand Up @@ -948,12 +916,6 @@ pub mod pallet {
/// The dispatch origin must be Root.
///
/// Emits `MaxCandidateStakeChanged`.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: [Origin Account], MaxCollatorCandidateStake
/// - Writes: Round
/// # </weight>
#[pallet::weight(<T as Config>::WeightInfo::set_max_candidate_stake())]
pub fn set_max_candidate_stake(origin: OriginFor<T>, new: BalanceOf<T>) -> DispatchResult {
ensure_root(origin)?;
Expand Down Expand Up @@ -1047,8 +1009,6 @@ pub mod pallet {
/// candidates nor of the delegators set.
///
/// Emits `JoinedCollatorCandidates`.
///
/// # <weight>
#[pallet::weight(<T as pallet::Config>::WeightInfo::join_candidates(
T::MaxTopCandidates::get(),
T::MaxDelegatorsPerCollator::get()
Expand Down Expand Up @@ -1641,14 +1601,6 @@ pub mod pallet {
/// allowed range as set in the pallet's configuration.
///
/// Emits `DelegatorStakedLess`.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: [Origin Account], DelegatorState, BlockNumber, Unstaking,
/// TopCandidates, CandidatePool, MaxSelectedCandidates
/// - Writes: Unstaking, DelegatorState, CandidatePool,
/// TotalCollatorStake
/// # </weight>
#[pallet::weight(<T as pallet::Config>::WeightInfo::delegator_stake_less(
T::MaxTopCandidates::get(),
T::MaxDelegatorsPerCollator::get()
Expand Down Expand Up @@ -1882,11 +1834,6 @@ pub mod pallet {

impl<T: Config> Pallet<T> {
/// Check whether an account is currently delegating.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: DelegatorState
/// # </weight>
pub fn is_delegator(acc: &T::AccountId) -> bool {
DelegatorState::<T>::get(acc).is_some()
}
Expand All @@ -1895,11 +1842,6 @@ pub mod pallet {
/// whether their state is CollatorStatus::Active.
///
/// Returns Some(is_active) if the account is a candidate, else None.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: CandidatePool
/// # </weight>
pub fn is_active_candidate(acc: &T::AccountId) -> Option<bool> {
if let Some(state) = CandidatePool::<T>::get(acc) {
Some(state.status == CandidateStatus::Active)
Expand All @@ -1913,12 +1855,6 @@ pub mod pallet {
///
/// NOTE: It is assumed that the calling context checks whether the
/// collator candidate is currently active before calling this function.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: TopCandidates, CandidatePool, TotalCollatorStake
/// - Writes: TopCandidates, TotalCollatorStake
/// # </weight>
fn update_top_candidates(
candidate: T::AccountId,
old_self: BalanceOf<T>,
Expand Down Expand Up @@ -2136,11 +2072,6 @@ pub mod pallet {
/// In case a collator from last round was replaced by a candidate with
/// the same total stake during sorting, we revert this swap to
/// prioritize collators over candidates.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: TopCandidates, MaxSelectedCandidates
/// # </weight>
pub fn selected_candidates() -> BoundedVec<T::AccountId, T::MaxTopCandidates> {
let candidates = TopCandidates::<T>::get();

Expand Down Expand Up @@ -2174,12 +2105,6 @@ pub mod pallet {
///
/// Emits `DelegationReplaced` if the stake exceeds one of the current
/// delegations.
///
/// # <weight>
/// Weight: O(D) where D is the number of delegators for this collator
/// bounded by `MaxDelegatorsPerCollator`.
/// - Reads/Writes: 0
/// # </weight>
#[allow(clippy::type_complexity)]
fn do_update_delegator(
stake: Stake<T::AccountId, BalanceOf<T>>,
Expand Down Expand Up @@ -2229,13 +2154,6 @@ pub mod pallet {
///
/// Consumes unstaked balance which can be unlocked in the future up to
/// amount and updates `Unstaking` storage accordingly.
///
/// # <weight>
/// Weight: O(U) where U is the number of locked unstaking requests
/// bounded by `MaxUnstakeRequests`.
/// - Reads: Unstaking, Locks
/// - Writes: Unstaking, Locks
/// # </weight>
fn increase_lock(who: &T::AccountId, amount: BalanceOf<T>, more: BalanceOf<T>) -> Result<u32, DispatchError> {
ensure!(
pallet_balances::Pallet::<T>::free_balance(who) >= amount.into(),
Expand Down Expand Up @@ -2288,12 +2206,6 @@ pub mod pallet {
/// Throws if the amount is zero (unlikely) or if active unlocking
/// requests exceed limit. The latter defends against stake reduction
/// spamming.
///
/// # <weight>
/// Weight: O(1)
/// - Reads: BlockNumber, Unstaking
/// - Writes: Unstaking
/// # </weight>
fn prep_unstake(who: &T::AccountId, amount: BalanceOf<T>, is_removal: bool) -> DispatchResult {
// should never occur but let's be safe
ensure!(!amount.is_zero(), Error::<T>::StakeNotFound);
Expand Down Expand Up @@ -2327,16 +2239,6 @@ pub mod pallet {
/// Clear the CandidatePool of the candidate and remove all delegations
/// to the candidate. Moreover, prepare unstaking for the candidate and
/// their former delegations.
///
/// # <weight>
/// Weight: O(D + U) where D is the number of delegators of the collator
/// candidate bounded by `MaxDelegatorsPerCollator` and U is the
/// number of locked unstaking requests bounded by `MaxUnstakeRequests`.
/// - Reads: BlockNumber, D * DelegatorState, D * Unstaking
/// - Writes: D * DelegatorState, (D + 1) * Unstaking
/// - Kills: CandidatePool, DelegatorState for all delegators which only
/// delegated to the candidate
/// # </weight>
fn remove_candidate(
collator: &T::AccountId,
state: &CandidateOf<T, T::MaxDelegatorsPerCollator>,
Expand Down Expand Up @@ -2382,14 +2284,6 @@ pub mod pallet {

/// Withdraw all staked currency which was unstaked at least
/// `StakeDuration` blocks ago.
///
/// # <weight>
/// Weight: O(U) where U is the number of locked unstaking
/// requests bounded by `MaxUnstakeRequests`.
/// - Reads: Unstaking, Locks
/// - Writes: Unstaking, Locks
/// - Kills: Unstaking & Locks if no balance is locked anymore
/// # </weight>
fn do_unlock(who: &T::AccountId) -> Result<u32, DispatchError> {
let now = <frame_system::Pallet<T>>::block_number();
let mut unstaking = <Unstaking<T>>::get(who);
Expand Down