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

PoS inflation and rewards #714

Merged
merged 27 commits into from
Apr 13, 2023
Merged

PoS inflation and rewards #714

merged 27 commits into from
Apr 13, 2023

Conversation

brentstone
Copy link
Collaborator

@brentstone brentstone commented Oct 30, 2022

Currently based on #1141, which is based on v0.14.0.

Closes #33, closes #338, closes #339, closes #353, closes #642.

This PR contains the base infrastructure for computing and applying inflationary rewards for proof-of-stake. Rewards are not applied to voting powers in this PR, but rather this is addressed in #1168.

@brentstone brentstone marked this pull request as draft October 31, 2022 19:23
@brentstone brentstone added the PoS label Oct 31, 2022
@brentstone brentstone mentioned this pull request Nov 8, 2022
@brentstone brentstone force-pushed the brent/pos-inflation-rewards branch 3 times, most recently from 155f983 to e663020 Compare November 11, 2022 19:12
@brentstone brentstone force-pushed the brent/pos-inflation-rewards branch 6 times, most recently from c67d8bf to 915edfb Compare December 16, 2022 17:32
@brentstone brentstone mentioned this pull request Dec 20, 2022
15 tasks
@brentstone brentstone force-pushed the brent/pos-inflation-rewards branch 3 times, most recently from 3456409 to 13c1fbc Compare January 13, 2023 17:23
@brentstone
Copy link
Collaborator Author

pls update wasm

@brentstone brentstone marked this pull request as ready for review January 13, 2023 21:10
brentstone added a commit that referenced this pull request Jan 13, 2023
@cwgoes cwgoes added this to the 0.15 milestone Jan 16, 2023
tzemanovic
tzemanovic previously approved these changes Mar 24, 2023
tzemanovic added a commit that referenced this pull request Mar 30, 2023
* brent/pos-inflation-rewards:
  [ci] wasm checksums update
  changelog: add #714
  various import, comment and print clean-ups
  upgrade and refactor vp_token + related logic
  pos: update tests for validator sets updates
  pos: use the native token address as staking token
  core/ledger: fix `value` types in functions that update parameters storage
  fixes/upgrades for tests
  core/token/credit_tokens: handle overflows
  upgrade total token supply tracking and balance tracking at genesis
  pos misc: cargo files, debugging, test parameters
  tests for inflation
  apps/lib: configure genesis to set up any number of validators
  trigger 2-block countdown to new epoch for Tendermint
  log block rewards with accumulator LazyMaps and apply inflation with rewards products
  storage types and keys for inflation
  inflation and rewards modules
  shared/pos: re-use PoS address from address mod
  core: refactor gov address
tzemanovic added a commit that referenced this pull request Mar 31, 2023
* brent/pos-inflation-rewards:
  [ci] wasm checksums update
  changelog: add #714
  various import, comment and print clean-ups
  upgrade and refactor vp_token + related logic
  pos: update tests for validator sets updates
  pos: use the native token address as staking token
  core/ledger: fix `value` types in functions that update parameters storage
  fixes/upgrades for tests
  core/token/credit_tokens: handle overflows
  upgrade total token supply tracking and balance tracking at genesis
  pos misc: cargo files, debugging, test parameters
  tests for inflation
  apps/lib: configure genesis to set up any number of validators
  trigger 2-block countdown to new epoch for Tendermint
  log block rewards with accumulator LazyMaps and apply inflation with rewards products
  storage types and keys for inflation
  inflation and rewards modules
  shared/pos: re-use PoS address from address mod
  core: refactor gov address
@tzemanovic tzemanovic mentioned this pull request Mar 31, 2023
@tzemanovic
Copy link
Member

tzemanovic commented Apr 5, 2023

the devnet for draft #1269 revealed some issues here, so switching this PR back to draft

@tzemanovic tzemanovic marked this pull request as draft April 5, 2023 07:30
@tzemanovic
Copy link
Member

updates:

  • bf85965 - the e2e tests weren't catching issues with tendermint voting power conversion as it was set to 1, so set it back to 0.1
  • e5d8505 - added unscaled Decimal conv for token::Amount useful for some calculations
  • 799b174 - fix missing tendermint voting power conversion when checking voting power given by tendermint against PoS state
  • 11b48fa - fix the error type that was lacking any detail
  • 422a34c - fix the variables given to PosRewardsCalculator to be sourced from token::Amounts (previously total_signing_stake was calculated from tendermint voting powers, but total_consensus_stake was token::Amount which caused mismatch when tm_votes_per_token != 1)
  • 20cae15 - add some debug logging for rewards
  • 7faef3d - fixed a mismatch in stake that was converted to Decimal unscaled (u64::from(stake).into()) and consensus_stake and signing_stake that were both scaled by the From<token::Amount> for Decimal impl

tzemanovic added a commit that referenced this pull request Apr 5, 2023
* brent/pos-inflation-rewards:
  pos: fix token conversion in rewards products
  pos: add debug log for rewards
  pos: fix token conversion in rewards calculation
  pos: improve inflation rewards error type
  pos: fix debug assertion checking validator voting power
  core/token: add unscaled decimal conversions
  test/e2e: set PoS param tm_votes_per_token = 0.1
@tzemanovic tzemanovic marked this pull request as ready for review April 5, 2023 17:17
@tzemanovic
Copy link
Member

pls update wasm

@juped juped merged commit b3812c1 into main Apr 13, 2023
@juped juped deleted the brent/pos-inflation-rewards branch April 13, 2023 06:07
bengtlofgren pushed a commit that referenced this pull request May 11, 2023
juped added a commit that referenced this pull request Jul 18, 2023
* mariari/inflation-rewards:
  masp: implement remaining inflation logic
  Fixup clippy issues
  Update the test with the correct inflation values
  Corrected the compounding of the MASP transparent balance.
  Now handle native inflation rewards for native tokens.
  Make the formula for the conversion rates reliable, also dump logs for e2e
  Update e2e tests
  Change the last inflation amount to reflect the actual amount minted
  Fix dev.toml having inconsistent token values and inconsistent dot
  Convert test storage to use the WlStorage and added token initalizer
  Add the total token balance to the address of each token account
  Add default values for each token parameter
  Add Parameter data structure for holding an initalizing token params
  Update the update_allowed_conversions to use the pd controller
  Reaplace by hand reward depositing, with a call to mint
  Add Token Parameters module, and keys like inflation and lock ratio
  Move inflation to core from shared
  app/node: tidy up some commented out code and logging
  core/storage: refactor epoch update tracker
  apps/finalize_block: log error when last proposer is missing
  app/finalize_block: refactor log_block_rewards/apply_inflation
  clean redundant code and old comments
  fix `value` types in functions that update parameters storage
  fix block proposer look-up and unit tests
  pos/docs: fix docstring typo
  app/ledger/finalize_block: write inflation + locked ratio via write-log
  app/ledger: tidy up some logging
  app/ledger/finalize_block: fix and refactor block proposer look-up
  test/finalize_block: extend no-DB commit test to ensure we hit inflation
  apps/ledger: only specify num of validators in "dev" build
  changelog: add #714
  [ci] wasm checksums update
  redo block proposer storage in abciplus mode
  clean up documentation and print-outs
  fix e2e::ledger_tests::double_signing_gets_slashed
  fix e2e::ledger_tests::pos_init_validator error
  fix e2e::ledger_tests::proposal_submission
  upgrade total token supply tracking and balance tracking at genesis
  fix e2e test ibc
  WIP - current changes, debug printouts, etc stuff
  update comments and documentation
  Cargo lock and tomls
  tests for inflation
  configure genesis to set up any number of validators
  trigger 2-block countdown to new epoch for Tendermint
  log block rewards with accumulator LazyMaps and apply inflation with rewards products
  storage types and keys for inflation
  inflation and rewards modules
juped added a commit that referenced this pull request Jul 28, 2023
* mariari/inflation-rewards:
  masp_conversions: adjust debug output
  masp: implement remaining inflation logic
  Fixup clippy issues
  Update the test with the correct inflation values
  Corrected the compounding of the MASP transparent balance.
  Now handle native inflation rewards for native tokens.
  Make the formula for the conversion rates reliable, also dump logs for e2e
  Update e2e tests
  Change the last inflation amount to reflect the actual amount minted
  Fix dev.toml having inconsistent token values and inconsistent dot
  Convert test storage to use the WlStorage and added token initalizer
  Add the total token balance to the address of each token account
  Add default values for each token parameter
  Add Parameter data structure for holding an initalizing token params
  Update the update_allowed_conversions to use the pd controller
  Reaplace by hand reward depositing, with a call to mint
  Add Token Parameters module, and keys like inflation and lock ratio
  Move inflation to core from shared
  app/node: tidy up some commented out code and logging
  core/storage: refactor epoch update tracker
  apps/finalize_block: log error when last proposer is missing
  app/finalize_block: refactor log_block_rewards/apply_inflation
  clean redundant code and old comments
  fix `value` types in functions that update parameters storage
  fix block proposer look-up and unit tests
  pos/docs: fix docstring typo
  app/ledger/finalize_block: write inflation + locked ratio via write-log
  app/ledger: tidy up some logging
  app/ledger/finalize_block: fix and refactor block proposer look-up
  test/finalize_block: extend no-DB commit test to ensure we hit inflation
  apps/ledger: only specify num of validators in "dev" build
  changelog: add #714
  [ci] wasm checksums update
  redo block proposer storage in abciplus mode
  clean up documentation and print-outs
  fix e2e::ledger_tests::double_signing_gets_slashed
  fix e2e::ledger_tests::pos_init_validator error
  fix e2e::ledger_tests::proposal_submission
  upgrade total token supply tracking and balance tracking at genesis
  fix e2e test ibc
  WIP - current changes, debug printouts, etc stuff
  update comments and documentation
  Cargo lock and tomls
  tests for inflation
  configure genesis to set up any number of validators
  trigger 2-block countdown to new epoch for Tendermint
  log block rewards with accumulator LazyMaps and apply inflation with rewards products
  storage types and keys for inflation
  inflation and rewards modules
juped added a commit that referenced this pull request Jul 28, 2023
* mariari/inflation-rewards:
  masp_conversions: adjust debug output
  masp: implement remaining inflation logic
  Fixup clippy issues
  Update the test with the correct inflation values
  Corrected the compounding of the MASP transparent balance.
  Now handle native inflation rewards for native tokens.
  Make the formula for the conversion rates reliable, also dump logs for e2e
  Update e2e tests
  Change the last inflation amount to reflect the actual amount minted
  Fix dev.toml having inconsistent token values and inconsistent dot
  Convert test storage to use the WlStorage and added token initalizer
  Add the total token balance to the address of each token account
  Add default values for each token parameter
  Add Parameter data structure for holding an initalizing token params
  Update the update_allowed_conversions to use the pd controller
  Reaplace by hand reward depositing, with a call to mint
  Add Token Parameters module, and keys like inflation and lock ratio
  Move inflation to core from shared
  app/node: tidy up some commented out code and logging
  core/storage: refactor epoch update tracker
  apps/finalize_block: log error when last proposer is missing
  app/finalize_block: refactor log_block_rewards/apply_inflation
  clean redundant code and old comments
  fix `value` types in functions that update parameters storage
  fix block proposer look-up and unit tests
  pos/docs: fix docstring typo
  app/ledger/finalize_block: write inflation + locked ratio via write-log
  app/ledger: tidy up some logging
  app/ledger/finalize_block: fix and refactor block proposer look-up
  test/finalize_block: extend no-DB commit test to ensure we hit inflation
  apps/ledger: only specify num of validators in "dev" build
  changelog: add #714
  [ci] wasm checksums update
  redo block proposer storage in abciplus mode
  clean up documentation and print-outs
  fix e2e::ledger_tests::double_signing_gets_slashed
  fix e2e::ledger_tests::pos_init_validator error
  fix e2e::ledger_tests::proposal_submission
  upgrade total token supply tracking and balance tracking at genesis
  fix e2e test ibc
  WIP - current changes, debug printouts, etc stuff
  update comments and documentation
  Cargo lock and tomls
  tests for inflation
  configure genesis to set up any number of validators
  trigger 2-block countdown to new epoch for Tendermint
  log block rewards with accumulator LazyMaps and apply inflation with rewards products
  storage types and keys for inflation
  inflation and rewards modules
juped added a commit that referenced this pull request Sep 21, 2023
* mariari/inflation-rewards:
  masp_conversions: adjust debug output
  masp: implement remaining inflation logic
  Fixup clippy issues
  Update the test with the correct inflation values
  Corrected the compounding of the MASP transparent balance.
  Now handle native inflation rewards for native tokens.
  Make the formula for the conversion rates reliable, also dump logs for e2e
  Update e2e tests
  Change the last inflation amount to reflect the actual amount minted
  Fix dev.toml having inconsistent token values and inconsistent dot
  Convert test storage to use the WlStorage and added token initalizer
  Add the total token balance to the address of each token account
  Add default values for each token parameter
  Add Parameter data structure for holding an initalizing token params
  Update the update_allowed_conversions to use the pd controller
  Reaplace by hand reward depositing, with a call to mint
  Add Token Parameters module, and keys like inflation and lock ratio
  Move inflation to core from shared
  app/node: tidy up some commented out code and logging
  core/storage: refactor epoch update tracker
  apps/finalize_block: log error when last proposer is missing
  app/finalize_block: refactor log_block_rewards/apply_inflation
  clean redundant code and old comments
  fix `value` types in functions that update parameters storage
  fix block proposer look-up and unit tests
  pos/docs: fix docstring typo
  app/ledger/finalize_block: write inflation + locked ratio via write-log
  app/ledger: tidy up some logging
  app/ledger/finalize_block: fix and refactor block proposer look-up
  test/finalize_block: extend no-DB commit test to ensure we hit inflation
  apps/ledger: only specify num of validators in "dev" build
  changelog: add #714
  [ci] wasm checksums update
  redo block proposer storage in abciplus mode
  clean up documentation and print-outs
  fix e2e::ledger_tests::double_signing_gets_slashed
  fix e2e::ledger_tests::pos_init_validator error
  fix e2e::ledger_tests::proposal_submission
  upgrade total token supply tracking and balance tracking at genesis
  fix e2e test ibc
  WIP - current changes, debug printouts, etc stuff
  update comments and documentation
  Cargo lock and tomls
  tests for inflation
  configure genesis to set up any number of validators
  trigger 2-block countdown to new epoch for Tendermint
  log block rewards with accumulator LazyMaps and apply inflation with rewards products
  storage types and keys for inflation
  inflation and rewards modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants