Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

claim_staking_rewards extrinsic #2080

Merged

Conversation

shannonwells
Copy link
Collaborator

@shannonwells shannonwells commented Jul 15, 2024

Goal

The goal of this PR is to implement the claim_staking_rewards extrinsic, its benchmarks, and tests.

Closes #1970

Discussion

Also removes a trait function that was complicating things and didn't really belong there.

Checklist

  • Design doc(s) updated
  • Tests added
  • Benchmarks added
  • Weights updated

@shannonwells shannonwells changed the base branch from main to feat/capacity-staking-rewards-impl July 15, 2024 23:26
@@ -40,7 +40,7 @@ fn do_retarget_happy_path() {
let from_amount = 600u64;
let to_amount = 300u64;
let to_msa: MessageSourceId = 2;
let staking_type = ProviderBoost;
let staking_type = StakingType::ProviderBoost;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was about silencing linter warnings.

assert_ok!(new_chunk.try_insert(era.into(), (1000u32 * era).into()));
}
ProviderBoostRewardPools::<T>::set(i, Some(new_chunk));
fn fill_reward_pool_chunks<T: Config>(current_era: RewardEra) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous version of this function, while it worked for the provider_boost benchmark, did not correctly fill up the reward_pool_chunks, so it caused an EraOutOfRange error in the claim_staking_reward benchmark.

@@ -402,6 +410,10 @@ pub mod pallet {
MaxRetargetsExceeded,
/// Tried to exceed bounds of a some Bounded collection
CollectionBoundExceeded,
/// This origin has nothing staked for ProviderBoost.
NotAProviderBoostAccount,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotAStakingAccount was getting a bit overloaded.

/// When this reward expires, i.e. can no longer be claimed
pub expires_at_block: BlockNumber,
/// The total staked in this era as of the current block
pub staked_amount: Balance,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to have the amount they staked in each Reward Info.

// have to save this because calling self.count() after self.0.get_mut produces compiler error
let current_count = self.count();

let current_staking_amount = self.get_last_staking_amount();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some code golf.

@@ -77,7 +77,7 @@ mod test {

assert_eq!(p, 100_000);

assert!(q >= 65_000_000);
assert!(q >= 50_000_000);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pulled in from main b/c benchmarks were failing due to too low weight.

// Proof Size summary in bytes:
// Measured: `1592`
// Estimated: `20591`
// Minimum execution time: 90_000_000 picoseconds.
Copy link
Collaborator Author

@shannonwells shannonwells Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is worst case scenario. Claiming rewards may be able to have some tuning, but also the benchmark should include variation. Created issue #2082 to address this

@shannonwells shannonwells marked this pull request as ready for review July 17, 2024 17:02
@shannonwells shannonwells requested review from a team, mattheworris, enddynayn, aramikm, claireolmstead and JoeCap08055 and removed request for a team July 17, 2024 20:01
Copy link
Collaborator

@aramikm aramikm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just some nits and questions!

common/primitives/src/capacity.rs Outdated Show resolved Hide resolved
pallets/capacity/src/lib.rs Outdated Show resolved Hide resolved
pallets/capacity/src/lib.rs Show resolved Hide resolved
Copy link
Collaborator

@aramikm aramikm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read through the code and looked good to me!

);
let total_to_mint = Self::do_claim_rewards(&staker)?;
Self::deposit_event(Event::ProviderBoostRewardClaimed {
account: staker.clone(),
Copy link
Collaborator

@enddynayn enddynayn Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please check if the clone can be removed from here? It seems at first sight that we might not need to do a clone.

@@ -1024,37 +1053,42 @@ impl<T: Config> Pallet<T> {
Some(provider_boost_history) => {
match provider_boost_history.count() {
0usize => false,
// they staked before the current era, so they have unclaimed rewards.
1usize => provider_boost_history.get_entry_for_era(&current_era).is_none(),
1usize => {
Copy link
Collaborator

@enddynayn enddynayn Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing a match statement makes the code a bit more readable:

pub(crate) fn has_unclaimed_rewards(account: &T::AccountId) -> bool {
    let current_era = Self::get_current_era().era_index;

    if let Some(provider_boost_history) = Self::get_staking_history_for(account) {
        let entry_count = provider_boost_history.count();
        
        match entry_count {
            0 =>  false, 
            1 => {
                let previous_era = current_era.saturating_sub(1);
                provider_boost_history.get_entry_for_era(&previous_era).is_none() &&
                provider_boost_history.get_entry_for_era(&current_era).is_none()
           },
            _ => true
        }
    } else {
       false
    }
}

.fold(zero_balance, |acc, reward_info| acc.saturating_add(reward_info.earned_amount))
.into();
ensure!(total_to_mint.gt(&Zero::zero()), Error::<T>::NothingToClaim);
let _minted_unused = T::Currency::mint_into(&staker, total_to_mint)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need let _minted_unused if we are not using it?

Copy link
Collaborator

@enddynayn enddynayn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 amazing!

@shannonwells shannonwells merged commit ad63363 into feat/capacity-staking-rewards-impl Jul 18, 2024
@shannonwells shannonwells deleted the extrinsic-claim-rewards branch July 18, 2024 16:42
shannonwells added a commit that referenced this pull request Jul 18, 2024
The goal of this PR is to implement the claim_staking_rewards extrinsic, its benchmarks, and tests.

Closes #1970
shannonwells added a commit that referenced this pull request Jul 23, 2024
The goal of this PR is to implement the claim_staking_rewards extrinsic, its benchmarks, and tests.

Closes #1970
shannonwells added a commit that referenced this pull request Oct 9, 2024
The goal of this PR is to implement the claim_staking_rewards extrinsic, its benchmarks, and tests.

Closes #1970
shannonwells added a commit that referenced this pull request Oct 10, 2024
updates to design docs to use a capacity rewards interface
Prototypes, make check working
refinements to design doc

Implement Staking Reward Eras basics (#1589)

Implement the basic functionality of tracking and rotating Reward Era. Closes #1567
Does not include anything to do with the Reward Pool.

Feat/staking rewards rewards provider #1572 (#1598)

The goal of this PR is to implement a really basic version of the
StakingRewardsProvider in the Capacity pallet and in the test mock,
neither of which is actively used.

Closes #1572

Does not include anything to do with setting and storing RewardPoolInfo
when each new Era starts.

change staking target extrinsic, closes #1570 (#1623)

comments, capacity boost fn added to StakingRewardsProvider trait

* Refactor staking type to go in StakingTargetDetails
* Make some functions pass by reference (performance)
* fix broken tests & calls

use capacity_boost and StakingType to adjust capacity generation, add/adjust tests

* Check from/to aren't the same when retargeting
* Performance: move non-db checks to top when retargeting
* Lots more tests
* Fix a bug where we weren't setting the staking type on a retarget
* Remove staking type from StakingAccountDetails
* Fix broken tests from last commit

Feat/reward pool history (#1710)
Closes #1710

Feat/split stake extrinsic #1699 (#1717)

The goal of this PR is to split the `stake` extrinsic into two: `stake` and `provider_boost`
Closes #1707

Feat/split storage #1726 (#1744)

The goal of this PR is to split up storage of boosting and maximized staking accounts,
as well as store retarget history separately, which can store retargeting events for
any type of staking.

Closes #1726

fix e2e tests, correction to implementation design doc

initialize storage for ProviderBoost on runtime upgrade

Set ProviderBoost capacity generated and fix tests (#1947)

* set the amount of capacity generated by a provider boost to the final amount, 50% of what is generated by MaximizedCapacity staking.
* Also Fixes some tests broken from the last rebase with main.
Closes #1569

Update reward pool on `provider_boost` or `unstake` #1699 (#1948)

The goal of this PR is to update the StakingRewardPool on a `provider_boost` or `unstake` extrinsic call.

Closes #1699

Implement rewards calculation formula #1941 (#1956)

The goal of this PR is to implement (but not really use yet) the chosen
formula for calculation of a reward in a single Provider Boost Reward
Era.

Closes #1941

updates after rebase

upsert staking history #1699 (#1963)

The goal of this PR is to add and use storage for individual staking history so that rewards can be calculated and paid out.  Benchmarks run to update capacity weights.

Relates to #1699

Chores/update capacity benchmarks #1949 (#1966)

The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949

Feat/check unclaimed rewards 1969 (#1972)

The goal of this PR is to implement `list_unclaimed_rewards`, and also
one that is lighter weight, `has_unclaimed_rewards`, which returns a
`bool` and which `unstake` extrinsic uses. Unstake now fails if there
are any unclaimed rewards.

Closes #1969
Closes #1578

Feat/reward pool refactor #1976 (#2005)

The goal of this PR is to implement a "chunk" version of the overall
reward pool history to reduce read/write load and hence weight for
transactions and `on_initialize` when a new `RewardEra` needs to start.

Part of #1976

Co-authored-by: Wil Wade <[email protected]>

Revise Provider Boost implementation design doc #2016 (#2020)

The goal of this PR is to review and update the implementation design doc in light of the chosen economic model, and to reflect some changes in behavior.  Review of the design doc also fed back into the code itself. Some code
is no longer needed.

Closes #2016

Co-authored-by: Aramik <[email protected]>

E2e for new extrinsics (#2067)

The goal of this PR is to add some e2e tests for the `provider_boost` extrinsic, and update the `change_staking_target` extrinsic after a rebase with main.

Refactor reward era (#2069)

The goal of this PR is primarily to pull RewardEra out of the Capacity Config and make it the same type everywhere.

`claim_staking_rewards` extrinsic (#2080)
Closes #1970

Capacity runtime api with list_unclaimed_rewards endpoint (#2088)
The goal of this PR is to implement a capacity runtime api for the `list_unclaimed_rewards` endpoint.
Closes #1698

Update Capacity README

address the lint failure.  updates after rebase with main

Remove TODO since it's already been addressed.
Add a minor test case to unstaking tests
Add new extrinsics to Capacity README
shannonwells added a commit that referenced this pull request Oct 18, 2024
updates to design docs to use a capacity rewards interface
Prototypes, make check working
refinements to design doc

Implement Staking Reward Eras basics (#1589)

Implement the basic functionality of tracking and rotating Reward Era. Closes #1567
Does not include anything to do with the Reward Pool.

Feat/staking rewards rewards provider #1572 (#1598)

The goal of this PR is to implement a really basic version of the
StakingRewardsProvider in the Capacity pallet and in the test mock,
neither of which is actively used.

Closes #1572

Does not include anything to do with setting and storing RewardPoolInfo
when each new Era starts.

change staking target extrinsic, closes #1570 (#1623)

comments, capacity boost fn added to StakingRewardsProvider trait

* Refactor staking type to go in StakingTargetDetails
* Make some functions pass by reference (performance)
* fix broken tests & calls

use capacity_boost and StakingType to adjust capacity generation, add/adjust tests

* Check from/to aren't the same when retargeting
* Performance: move non-db checks to top when retargeting
* Lots more tests
* Fix a bug where we weren't setting the staking type on a retarget
* Remove staking type from StakingAccountDetails
* Fix broken tests from last commit

Feat/reward pool history (#1710)
Closes #1710

Feat/split stake extrinsic #1699 (#1717)

The goal of this PR is to split the `stake` extrinsic into two: `stake` and `provider_boost`
Closes #1707

Feat/split storage #1726 (#1744)

The goal of this PR is to split up storage of boosting and maximized staking accounts,
as well as store retarget history separately, which can store retargeting events for
any type of staking.

Closes #1726

fix e2e tests, correction to implementation design doc

initialize storage for ProviderBoost on runtime upgrade

Set ProviderBoost capacity generated and fix tests (#1947)

* set the amount of capacity generated by a provider boost to the final amount, 50% of what is generated by MaximizedCapacity staking.
* Also Fixes some tests broken from the last rebase with main.
Closes #1569

Update reward pool on `provider_boost` or `unstake` #1699 (#1948)

The goal of this PR is to update the StakingRewardPool on a `provider_boost` or `unstake` extrinsic call.

Closes #1699

Implement rewards calculation formula #1941 (#1956)

The goal of this PR is to implement (but not really use yet) the chosen
formula for calculation of a reward in a single Provider Boost Reward
Era.

Closes #1941

updates after rebase

upsert staking history #1699 (#1963)

The goal of this PR is to add and use storage for individual staking history so that rewards can be calculated and paid out.  Benchmarks run to update capacity weights.

Relates to #1699

Chores/update capacity benchmarks #1949 (#1966)

The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949

Feat/check unclaimed rewards 1969 (#1972)

The goal of this PR is to implement `list_unclaimed_rewards`, and also
one that is lighter weight, `has_unclaimed_rewards`, which returns a
`bool` and which `unstake` extrinsic uses. Unstake now fails if there
are any unclaimed rewards.

Closes #1969
Closes #1578

Feat/reward pool refactor #1976 (#2005)

The goal of this PR is to implement a "chunk" version of the overall
reward pool history to reduce read/write load and hence weight for
transactions and `on_initialize` when a new `RewardEra` needs to start.

Part of #1976

Co-authored-by: Wil Wade <[email protected]>

Revise Provider Boost implementation design doc #2016 (#2020)

The goal of this PR is to review and update the implementation design doc in light of the chosen economic model, and to reflect some changes in behavior.  Review of the design doc also fed back into the code itself. Some code
is no longer needed.

Closes #2016

Co-authored-by: Aramik <[email protected]>

E2e for new extrinsics (#2067)

The goal of this PR is to add some e2e tests for the `provider_boost` extrinsic, and update the `change_staking_target` extrinsic after a rebase with main.

Refactor reward era (#2069)

The goal of this PR is primarily to pull RewardEra out of the Capacity Config and make it the same type everywhere.

`claim_staking_rewards` extrinsic (#2080)
Closes #1970

Capacity runtime api with list_unclaimed_rewards endpoint (#2088)
The goal of this PR is to implement a capacity runtime api for the `list_unclaimed_rewards` endpoint.
Closes #1698

Update Capacity README

address the lint failure.  updates after rebase with main

Remove TODO since it's already been addressed.
Add a minor test case to unstaking tests
Add new extrinsics to Capacity README
shannonwells added a commit that referenced this pull request Oct 25, 2024
updates to design docs to use a capacity rewards interface
Prototypes, make check working
refinements to design doc

Implement Staking Reward Eras basics (#1589)

Implement the basic functionality of tracking and rotating Reward Era. Closes #1567
Does not include anything to do with the Reward Pool.

Feat/staking rewards rewards provider #1572 (#1598)

The goal of this PR is to implement a really basic version of the
StakingRewardsProvider in the Capacity pallet and in the test mock,
neither of which is actively used.

Closes #1572

Does not include anything to do with setting and storing RewardPoolInfo
when each new Era starts.

change staking target extrinsic, closes #1570 (#1623)

comments, capacity boost fn added to StakingRewardsProvider trait

* Refactor staking type to go in StakingTargetDetails
* Make some functions pass by reference (performance)
* fix broken tests & calls

use capacity_boost and StakingType to adjust capacity generation, add/adjust tests

* Check from/to aren't the same when retargeting
* Performance: move non-db checks to top when retargeting
* Lots more tests
* Fix a bug where we weren't setting the staking type on a retarget
* Remove staking type from StakingAccountDetails
* Fix broken tests from last commit

Feat/reward pool history (#1710)
Closes #1710

Feat/split stake extrinsic #1699 (#1717)

The goal of this PR is to split the `stake` extrinsic into two: `stake` and `provider_boost`
Closes #1707

Feat/split storage #1726 (#1744)

The goal of this PR is to split up storage of boosting and maximized staking accounts,
as well as store retarget history separately, which can store retargeting events for
any type of staking.

Closes #1726

fix e2e tests, correction to implementation design doc

initialize storage for ProviderBoost on runtime upgrade

Set ProviderBoost capacity generated and fix tests (#1947)

* set the amount of capacity generated by a provider boost to the final amount, 50% of what is generated by MaximizedCapacity staking.
* Also Fixes some tests broken from the last rebase with main.
Closes #1569

Update reward pool on `provider_boost` or `unstake` #1699 (#1948)

The goal of this PR is to update the StakingRewardPool on a `provider_boost` or `unstake` extrinsic call.

Closes #1699

Implement rewards calculation formula #1941 (#1956)

The goal of this PR is to implement (but not really use yet) the chosen
formula for calculation of a reward in a single Provider Boost Reward
Era.

Closes #1941

updates after rebase

upsert staking history #1699 (#1963)

The goal of this PR is to add and use storage for individual staking history so that rewards can be calculated and paid out.  Benchmarks run to update capacity weights.

Relates to #1699

Chores/update capacity benchmarks #1949 (#1966)

The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949

Feat/check unclaimed rewards 1969 (#1972)

The goal of this PR is to implement `list_unclaimed_rewards`, and also
one that is lighter weight, `has_unclaimed_rewards`, which returns a
`bool` and which `unstake` extrinsic uses. Unstake now fails if there
are any unclaimed rewards.

Closes #1969
Closes #1578

Feat/reward pool refactor #1976 (#2005)

The goal of this PR is to implement a "chunk" version of the overall
reward pool history to reduce read/write load and hence weight for
transactions and `on_initialize` when a new `RewardEra` needs to start.

Part of #1976

Co-authored-by: Wil Wade <[email protected]>

Revise Provider Boost implementation design doc #2016 (#2020)

The goal of this PR is to review and update the implementation design doc in light of the chosen economic model, and to reflect some changes in behavior.  Review of the design doc also fed back into the code itself. Some code
is no longer needed.

Closes #2016

Co-authored-by: Aramik <[email protected]>

E2e for new extrinsics (#2067)

The goal of this PR is to add some e2e tests for the `provider_boost` extrinsic, and update the `change_staking_target` extrinsic after a rebase with main.

Refactor reward era (#2069)

The goal of this PR is primarily to pull RewardEra out of the Capacity Config and make it the same type everywhere.

`claim_staking_rewards` extrinsic (#2080)
Closes #1970

Capacity runtime api with list_unclaimed_rewards endpoint (#2088)
The goal of this PR is to implement a capacity runtime api for the `list_unclaimed_rewards` endpoint.
Closes #1698

Update Capacity README

address the lint failure.  updates after rebase with main

Remove TODO since it's already been addressed.
Add a minor test case to unstaking tests
Add new extrinsics to Capacity README
shannonwells added a commit that referenced this pull request Oct 29, 2024
updates to design docs to use a capacity rewards interface
Prototypes, make check working
refinements to design doc

Implement Staking Reward Eras basics (#1589)

Implement the basic functionality of tracking and rotating Reward Era. Closes #1567
Does not include anything to do with the Reward Pool.

Feat/staking rewards rewards provider #1572 (#1598)

The goal of this PR is to implement a really basic version of the
StakingRewardsProvider in the Capacity pallet and in the test mock,
neither of which is actively used.

Closes #1572

Does not include anything to do with setting and storing RewardPoolInfo
when each new Era starts.

change staking target extrinsic, closes #1570 (#1623)

comments, capacity boost fn added to StakingRewardsProvider trait

* Refactor staking type to go in StakingTargetDetails
* Make some functions pass by reference (performance)
* fix broken tests & calls

use capacity_boost and StakingType to adjust capacity generation, add/adjust tests

* Check from/to aren't the same when retargeting
* Performance: move non-db checks to top when retargeting
* Lots more tests
* Fix a bug where we weren't setting the staking type on a retarget
* Remove staking type from StakingAccountDetails
* Fix broken tests from last commit

Feat/reward pool history (#1710)
Closes #1710

Feat/split stake extrinsic #1699 (#1717)

The goal of this PR is to split the `stake` extrinsic into two: `stake` and `provider_boost`
Closes #1707

Feat/split storage #1726 (#1744)

The goal of this PR is to split up storage of boosting and maximized staking accounts,
as well as store retarget history separately, which can store retargeting events for
any type of staking.

Closes #1726

fix e2e tests, correction to implementation design doc

initialize storage for ProviderBoost on runtime upgrade

Set ProviderBoost capacity generated and fix tests (#1947)

* set the amount of capacity generated by a provider boost to the final amount, 50% of what is generated by MaximizedCapacity staking.
* Also Fixes some tests broken from the last rebase with main.
Closes #1569

Update reward pool on `provider_boost` or `unstake` #1699 (#1948)

The goal of this PR is to update the StakingRewardPool on a `provider_boost` or `unstake` extrinsic call.

Closes #1699

Implement rewards calculation formula #1941 (#1956)

The goal of this PR is to implement (but not really use yet) the chosen
formula for calculation of a reward in a single Provider Boost Reward
Era.

Closes #1941

updates after rebase

upsert staking history #1699 (#1963)

The goal of this PR is to add and use storage for individual staking history so that rewards can be calculated and paid out.  Benchmarks run to update capacity weights.

Relates to #1699

Chores/update capacity benchmarks #1949 (#1966)

The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949

Feat/check unclaimed rewards 1969 (#1972)

The goal of this PR is to implement `list_unclaimed_rewards`, and also
one that is lighter weight, `has_unclaimed_rewards`, which returns a
`bool` and which `unstake` extrinsic uses. Unstake now fails if there
are any unclaimed rewards.

Closes #1969
Closes #1578

Feat/reward pool refactor #1976 (#2005)

The goal of this PR is to implement a "chunk" version of the overall
reward pool history to reduce read/write load and hence weight for
transactions and `on_initialize` when a new `RewardEra` needs to start.

Part of #1976

Co-authored-by: Wil Wade <[email protected]>

Revise Provider Boost implementation design doc #2016 (#2020)

The goal of this PR is to review and update the implementation design doc in light of the chosen economic model, and to reflect some changes in behavior.  Review of the design doc also fed back into the code itself. Some code
is no longer needed.

Closes #2016

Co-authored-by: Aramik <[email protected]>

E2e for new extrinsics (#2067)

The goal of this PR is to add some e2e tests for the `provider_boost` extrinsic, and update the `change_staking_target` extrinsic after a rebase with main.

Refactor reward era (#2069)

The goal of this PR is primarily to pull RewardEra out of the Capacity Config and make it the same type everywhere.

`claim_staking_rewards` extrinsic (#2080)
Closes #1970

Capacity runtime api with list_unclaimed_rewards endpoint (#2088)
The goal of this PR is to implement a capacity runtime api for the `list_unclaimed_rewards` endpoint.
Closes #1698

Update Capacity README

address the lint failure.  updates after rebase with main

Remove TODO since it's already been addressed.
Add a minor test case to unstaking tests
Add new extrinsics to Capacity README
shannonwells added a commit that referenced this pull request Oct 30, 2024
updates to design docs to use a capacity rewards interface
Prototypes, make check working
refinements to design doc

Implement Staking Reward Eras basics (#1589)

Implement the basic functionality of tracking and rotating Reward Era. Closes #1567
Does not include anything to do with the Reward Pool.

Feat/staking rewards rewards provider #1572 (#1598)

The goal of this PR is to implement a really basic version of the
StakingRewardsProvider in the Capacity pallet and in the test mock,
neither of which is actively used.

Closes #1572

Does not include anything to do with setting and storing RewardPoolInfo
when each new Era starts.

change staking target extrinsic, closes #1570 (#1623)

comments, capacity boost fn added to StakingRewardsProvider trait

* Refactor staking type to go in StakingTargetDetails
* Make some functions pass by reference (performance)
* fix broken tests & calls

use capacity_boost and StakingType to adjust capacity generation, add/adjust tests

* Check from/to aren't the same when retargeting
* Performance: move non-db checks to top when retargeting
* Lots more tests
* Fix a bug where we weren't setting the staking type on a retarget
* Remove staking type from StakingAccountDetails
* Fix broken tests from last commit

Feat/reward pool history (#1710)
Closes #1710

Feat/split stake extrinsic #1699 (#1717)

The goal of this PR is to split the `stake` extrinsic into two: `stake` and `provider_boost`
Closes #1707

Feat/split storage #1726 (#1744)

The goal of this PR is to split up storage of boosting and maximized staking accounts,
as well as store retarget history separately, which can store retargeting events for
any type of staking.

Closes #1726

fix e2e tests, correction to implementation design doc

initialize storage for ProviderBoost on runtime upgrade

Set ProviderBoost capacity generated and fix tests (#1947)

* set the amount of capacity generated by a provider boost to the final amount, 50% of what is generated by MaximizedCapacity staking.
* Also Fixes some tests broken from the last rebase with main.
Closes #1569

Update reward pool on `provider_boost` or `unstake` #1699 (#1948)

The goal of this PR is to update the StakingRewardPool on a `provider_boost` or `unstake` extrinsic call.

Closes #1699

Implement rewards calculation formula #1941 (#1956)

The goal of this PR is to implement (but not really use yet) the chosen
formula for calculation of a reward in a single Provider Boost Reward
Era.

Closes #1941

updates after rebase

upsert staking history #1699 (#1963)

The goal of this PR is to add and use storage for individual staking history so that rewards can be calculated and paid out.  Benchmarks run to update capacity weights.

Relates to #1699

Chores/update capacity benchmarks #1949 (#1966)

The goal of this PR is to update the benchmark for `on_initialize` to include the weight when a new RewardEra must be created.

Closes #1949

Feat/check unclaimed rewards 1969 (#1972)

The goal of this PR is to implement `list_unclaimed_rewards`, and also
one that is lighter weight, `has_unclaimed_rewards`, which returns a
`bool` and which `unstake` extrinsic uses. Unstake now fails if there
are any unclaimed rewards.

Closes #1969
Closes #1578

Feat/reward pool refactor #1976 (#2005)

The goal of this PR is to implement a "chunk" version of the overall
reward pool history to reduce read/write load and hence weight for
transactions and `on_initialize` when a new `RewardEra` needs to start.

Part of #1976

Co-authored-by: Wil Wade <[email protected]>

Revise Provider Boost implementation design doc #2016 (#2020)

The goal of this PR is to review and update the implementation design doc in light of the chosen economic model, and to reflect some changes in behavior.  Review of the design doc also fed back into the code itself. Some code
is no longer needed.

Closes #2016

Co-authored-by: Aramik <[email protected]>

E2e for new extrinsics (#2067)

The goal of this PR is to add some e2e tests for the `provider_boost` extrinsic, and update the `change_staking_target` extrinsic after a rebase with main.

Refactor reward era (#2069)

The goal of this PR is primarily to pull RewardEra out of the Capacity Config and make it the same type everywhere.

`claim_staking_rewards` extrinsic (#2080)
Closes #1970

Capacity runtime api with list_unclaimed_rewards endpoint (#2088)
The goal of this PR is to implement a capacity runtime api for the `list_unclaimed_rewards` endpoint.
Closes #1698

Update Capacity README

address the lint failure.  updates after rebase with main

Remove TODO since it's already been addressed.
Add a minor test case to unstaking tests
Add new extrinsics to Capacity README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: claim_rewards implementation
3 participants