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

staking rewards distribution followup #835

Merged
merged 53 commits into from
Jun 17, 2024

Conversation

bekauz
Copy link
Collaborator

@bekauz bekauz commented Jun 1, 2024

reworks the existing staking rewards distribution logic.

contract now functions as a factory for distributing staking rewards.
there is no more main voting power contract; each denom to be distributed needs to specify where to draw its voting power from.

reward rate is derived from the RewardEmissionConfig which describes how many udenoms (Uint128) are to be distributed per time duration (blocks/seconds).

introduces a shutdown option which claws back any undistributed rewards back to the treasury.

also implemented a suite test builder because the current unit test file was about to exceed 3000 lines of code (mostly because of copy pasting the setup in every test). however not all tests are present - this is a pending todo.

@bekauz bekauz marked this pull request as draft June 1, 2024 17:40
@NoahSaso NoahSaso mentioned this pull request Jun 1, 2024
Copy link
Member

@NoahSaso NoahSaso left a comment

Choose a reason for hiding this comment

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

ok wow. nice work! this is a first pass and i don't quite understand everything yet, but i'm getting there. take my questions to represent the lack of my understanding, not that i think you did something wrong.

i think there are a handful of places that could be commented/explained beyond the surface level instructions that are written out (and some variable names improved), but maybe i can take that upon myself to confirm understanding and clean things up once all of the feature changes are done.

memorializing things we discussed in the discord sync here so we don't forget to do them:

  • split shutdown and withdraw into separate actions
  • require specifying recipient when withdrawing, since owner may not be the desired recipient
  • make funding permissionless but keep denom registration permissioned
  • make it possible to update reward rates on-the-fly without affecting past unclaimed rewards (basically a stop and restart)

great fkn work tho, damn

contracts/distribution/dao-rewards-distributor/src/msg.rs Outdated Show resolved Hide resolved
contracts/distribution/dao-rewards-distributor/src/msg.rs Outdated Show resolved Hide resolved
@NoahSaso NoahSaso force-pushed the benskey/distribution-followup branch from 547d477 to 4e4c15c Compare June 6, 2024 20:02
@NoahSaso NoahSaso force-pushed the benskey/distribution-followup branch from 4e4c15c to 5d7143a Compare June 6, 2024 20:08
@bekauz
Copy link
Collaborator Author

bekauz commented Jun 16, 2024

removing the reward emission config updates for now as this pr is big enough. added next steps in #839 .

Copy link

codecov bot commented Jun 16, 2024

Codecov Report

Attention: Patch coverage is 96.87375% with 78 lines in your changes missing coverage. Please review.

Project coverage is 96.28%. Comparing base (87485be) to head (acc5fed).
Report is 1 commits behind head on development.

Current head acc5fed differs from pull request most recent head 3f7eb1c

Please upload reports for the commit 3f7eb1c to get more accurate results.

Files Patch % Lines
...ution/dao-rewards-distributor/src/testing/suite.rs 94.58% 31 Missing ⚠️
...ibution/dao-rewards-distributor/src/testing/mod.rs 93.56% 15 Missing ⚠️
...stribution/dao-rewards-distributor/src/contract.rs 96.90% 14 Missing ⚠️
.../distribution/dao-rewards-distributor/src/state.rs 76.66% 14 Missing ⚠️
...ts/distribution/dao-rewards-distributor/src/msg.rs 88.88% 4 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #835      +/-   ##
===============================================
+ Coverage        96.26%   96.28%   +0.02%     
===============================================
  Files              209      217       +8     
  Lines            53514    56009    +2495     
===============================================
+ Hits             51513    53931    +2418     
- Misses            2001     2078      +77     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bekauz bekauz marked this pull request as ready for review June 16, 2024 22:39
Copy link
Member

@NoahSaso NoahSaso left a comment

Choose a reason for hiding this comment

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

hellllllll yeah. amazing work guys.

for the next PR, we want to refactor to support pausing/unpausing, separate shutdown with recipient message, and update-able emission configs that don't affect the unclaimed rewards

@NoahSaso NoahSaso merged commit 8be18d1 into development Jun 17, 2024
5 of 7 checks passed
@NoahSaso NoahSaso deleted the benskey/distribution-followup branch June 17, 2024 16:05
ismellike added a commit to Arena-DAO/dao-contracts that referenced this pull request Jul 19, 2024
commit 0c09c62
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Thu Jul 18 20:56:03 2024 -0500

    Revert integration_tests.yml

commit c46937a
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 17 13:18:11 2024 -0500

    Update basic.yml to cache only cargo deps

    Nightly toolchain is required for integration_tests

commit 7773cb0
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 17 12:45:09 2024 -0500

    Set integration_tests toolchain to latest stable

commit 74aea83
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Thu Jul 11 02:21:52 2024 -0500

    Cargo schema + fix orch wasm build and tests

commit e8081ac
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Thu Jul 11 00:40:32 2024 -0500

    Fix cargo stuff

commit d5a1850
Merge: 87925b2 5918cbe
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 10 23:48:52 2024 -0500

    Merge branch 'development' into feature/cw-orch-interface

commit 87925b2
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 10 23:47:50 2024 -0500

    Add cache to basic.yml

commit 2951f8c
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 10 23:47:40 2024 -0500

    Fix lints

    Also updates just lint to match basic.yml

commit 5918cbe
Author: noah <noahsaso@gmail.com>
Date:   Mon Jul 8 18:33:22 2024 -0400

    OmniFlix NFT (x/onft) staked voting module (DA0-DA0#838)

commit ac249f4
Author: noah <noahsaso@gmail.com>
Date:   Sat Jul 6 23:11:22 2024 -0400

    Improve pre-propose proposal creation permission granularity (and bump versions to v2.5.0) (DA0-DA0#843)

commit 8be18d1
Author: bekauz <bekauz@protonmail.com>
Date:   Mon Jun 17 18:05:24 2024 +0200

    staking rewards distribution followup (DA0-DA0#835)

    Co-authored-by: Noah Saso <noahsaso@gmail.com>
    Co-authored-by: Jake Hartnell <jake.hartnell@gmail.com>

commit bb8224e
Author: noah <noahsaso@gmail.com>
Date:   Thu Jun 6 00:32:12 2024 -0400

    moved .cargo/config to .cargo/config.toml (DA0-DA0#837)

commit 87485be
Author: bekauz <bekauz@protonmail.com>
Date:   Wed May 22 18:39:06 2024 +0200

    bump cw-std to 1.5.4 (DA0-DA0#824)

commit 8c945ac
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 09:09:32 2024 +0000

    Added other derives

commit f720001
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 09:06:45 2024 +0000

    Added derive fns

commit 003f87d
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 08:54:07 2024 +0000

    Fix tests

commit 88ec5ed
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 08:52:54 2024 +0000

    Added Queryfns on voting

commit 3440d34
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 08:06:38 2024 +0000

    Finalize test changes

commit 9492e37
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 07:40:35 2024 +0000

    More tests

commit 5883c87
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Thu May 16 17:24:41 2024 +0000

    Added tests with cw-orch

commit b01de1c
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Thu May 16 14:41:02 2024 +0000

    First test modifications

commit 3ab7017
Author: noah <noahsaso@gmail.com>
Date:   Mon Apr 1 20:04:11 2024 +0200

    Update versions to 2.4.2 (DA0-DA0#817)

commit caea80a
Author: noah <noahsaso@gmail.com>
Date:   Mon Apr 1 19:32:50 2024 +0200

    support kujira's /kujira.denom... tokenfactory fork (DA0-DA0#816)
ismellike added a commit to Arena-DAO/dao-contracts that referenced this pull request Jul 19, 2024
commit aff2c4e
Author: Gabe <glopez11193@gmail.com>
Date:   Fri Jul 19 12:08:16 2024 -0500

    Revert basic.yml

    i think caching is causing issues with the cargo.lock

commit 6db4637
Author: Gabe <glopez11193@gmail.com>
Date:   Fri Jul 19 12:06:17 2024 -0500

    Lint + not(target_arch = "wasm32") in lib.rs

commit 18241d0
Merge: 761a780 87847fd
Author: Gabe <glopez11193@gmail.com>
Date:   Fri Jul 19 10:58:25 2024 -0500

    Merge branch 'pr/1' into feature/cw-orch-interface

commit 761a780
Author: Gabe <glopez11193@gmail.com>
Date:   Fri Jul 19 02:40:02 2024 -0500

    Update to cw-orch .24.1

commit 0c09c62
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Thu Jul 18 20:56:03 2024 -0500

    Revert integration_tests.yml

commit c46937a
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 17 13:18:11 2024 -0500

    Update basic.yml to cache only cargo deps

    Nightly toolchain is required for integration_tests

commit 7773cb0
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 17 12:45:09 2024 -0500

    Set integration_tests toolchain to latest stable

commit 87847fd
Author: hard-nett <hardnettt@proton.me>
Date:   Sat Jul 13 18:53:38 2024 +0000

    add cw-orch to external contract

commit 74aea83
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Thu Jul 11 02:21:52 2024 -0500

    Cargo schema + fix orch wasm build and tests

commit e8081ac
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Thu Jul 11 00:40:32 2024 -0500

    Fix cargo stuff

commit d5a1850
Merge: 87925b2 5918cbe
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 10 23:48:52 2024 -0500

    Merge branch 'development' into feature/cw-orch-interface

commit 87925b2
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 10 23:47:50 2024 -0500

    Add cache to basic.yml

commit 2951f8c
Author: Gabriel Lopez <glopez11193@gmail.com>
Date:   Wed Jul 10 23:47:40 2024 -0500

    Fix lints

    Also updates just lint to match basic.yml

commit 5918cbe
Author: noah <noahsaso@gmail.com>
Date:   Mon Jul 8 18:33:22 2024 -0400

    OmniFlix NFT (x/onft) staked voting module (DA0-DA0#838)

commit ac249f4
Author: noah <noahsaso@gmail.com>
Date:   Sat Jul 6 23:11:22 2024 -0400

    Improve pre-propose proposal creation permission granularity (and bump versions to v2.5.0) (DA0-DA0#843)

commit 8be18d1
Author: bekauz <bekauz@protonmail.com>
Date:   Mon Jun 17 18:05:24 2024 +0200

    staking rewards distribution followup (DA0-DA0#835)

    Co-authored-by: Noah Saso <noahsaso@gmail.com>
    Co-authored-by: Jake Hartnell <jake.hartnell@gmail.com>

commit bb8224e
Author: noah <noahsaso@gmail.com>
Date:   Thu Jun 6 00:32:12 2024 -0400

    moved .cargo/config to .cargo/config.toml (DA0-DA0#837)

commit 87485be
Author: bekauz <bekauz@protonmail.com>
Date:   Wed May 22 18:39:06 2024 +0200

    bump cw-std to 1.5.4 (DA0-DA0#824)

commit 8c945ac
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 09:09:32 2024 +0000

    Added other derives

commit f720001
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 09:06:45 2024 +0000

    Added derive fns

commit 003f87d
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 08:54:07 2024 +0000

    Fix tests

commit 88ec5ed
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 08:52:54 2024 +0000

    Added Queryfns on voting

commit 3440d34
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 08:06:38 2024 +0000

    Finalize test changes

commit 9492e37
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Fri May 17 07:40:35 2024 +0000

    More tests

commit 5883c87
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Thu May 16 17:24:41 2024 +0000

    Added tests with cw-orch

commit b01de1c
Author: Kayanski <kowalski.kowalskin@gmail.com>
Date:   Thu May 16 14:41:02 2024 +0000

    First test modifications

commit 3ab7017
Author: noah <noahsaso@gmail.com>
Date:   Mon Apr 1 20:04:11 2024 +0200

    Update versions to 2.4.2 (DA0-DA0#817)

commit caea80a
Author: noah <noahsaso@gmail.com>
Date:   Mon Apr 1 19:32:50 2024 +0200

    support kujira's /kujira.denom... tokenfactory fork (DA0-DA0#816)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants