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

[Application] Enforce minimum stake when burning #848

Merged
merged 139 commits into from
Oct 11, 2024

Conversation

bryanchriswhite
Copy link
Contributor

@bryanchriswhite bryanchriswhite commented Oct 1, 2024

Summary

Updates ProcessTokenLogicModules() logic to unbond applications whose stake is below the minimum after processing all TLMs.

Dependencies

Dependents

Issue

Type of change

Select one or more from the following:

Testing

  • Documentation: make docusaurus_start; only needed if you make doc changes
  • Unit Tests: make go_develop_and_test
  • LocalNet E2E Tests: make test_e2e
  • DevNet E2E Tests: Add the devnet-test-e2e label to the PR.

Sanity Checklist

  • I have tested my changes using the available tooling
  • I have commented my code
  • I have performed a self-review of my own code; both comments & source code
  • I create and reference any new tickets, if applicable
  • I have left TODOs throughout the codebase, if applicable

bryanchriswhite added a commit that referenced this pull request Oct 9, 2024
## Summary

- Adds minimum stake validation to the application stake message handler
(i.e. total stake must be >= minimum stake).
- Updates error returns in the same handler to ensure all error paths
return appropriate gRPC status errors.
- Replaces some warn and error level logs with info level, which I
believe is more appropriate (until we have a practical debug level, at
which point they should become debug logs).

## Dependencies

- #809
- #843 
- #844 
- #845

## Dependents
 
- #848 
- #849
- #850
- #857
- #852 
- #861 
- #851 
- #863 

## Issue

- #612

## Type of change

Select one or more from the following:

- [x] New feature, functionality or library
- [x] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [ ] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [ ] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [x] I have commented my code
- [ ] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [x] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <r3d0ne@gmail.com>
Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
Co-authored-by: red-0ne <red-0ne@users.noreply.github.com>
…to issues/612/application/burning

* pokt/issues/612/application/staking:
  Empty commit
  [Tokenomics] Prevent GMR to produce zero values (#866)
  Empty commit
…burning

* pokt/main:
  [DifficultyHash] Prepare for difficulty multiplier usage (#836)
  [Application] Enforce minimum stake when staking (#847)
@bryanchriswhite bryanchriswhite changed the base branch from issues/612/application/staking to main October 10, 2024 07:24
Copy link
Contributor

@red-0ne red-0ne left a comment

Choose a reason for hiding this comment

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

Added a small comment request but everything looks good to me.

Preemptively approving.

// start checking the denom here.
if application.Stake.Amount.LT(apptypes.DefaultMinStake.Amount) {
// Unbond the application because it has less than the minimum stake.
if err = k.applicationKeeper.UnbondApplication(ctx, &application); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add a comment that unbonding is only viable when an application is only staked for a single service.

If it is staked for multiple one, this would prevent other settlements to burn tokens.

Copy link
Contributor Author

@bryanchriswhite bryanchriswhite Oct 11, 2024

Choose a reason for hiding this comment

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

  1. Set application UnbondingSessionEndHeight = -1 and save here.
  2. In SettlePendingClaims(), after ProcessTokenLogicModules() loop, unstake apps from 1 by lookup via claims.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NOTE: UnbondingSessionEndHeight is a uint64 so I went with 1 instead of -1 to keep the change small. I think this should be fine as 1 is not really a practical value for an actual unbonding session end height.

@bryanchriswhite
Copy link
Contributor Author

E2E tests passing locally but timing out in CI, waiting for devnet to come up.

image

@bryanchriswhite bryanchriswhite merged commit b60dac9 into main Oct 11, 2024
9 of 10 checks passed
bryanchriswhite added a commit that referenced this pull request Oct 11, 2024
…-update-param

* pokt/main:
  [Application] Enforce minimum stake when burning (#848)
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
* issues/612/shared/refresh: (46 commits)
  test: supplier up-staking from below min. stake
  fix: linter error
  fix: flaky test
  [Application] Enforce minimum stake when burning (#848)
  Empty commit
  chore: review feedback improvements
  chore: regenerate protobufs
  chore: review feedback improvements
  test: fix application min stake integration test
  chore: review feedback improvements
  Empty commit
  fix: linter error
  chore: quick fixes
  [DifficultyHash] Prepare for difficulty multiplier usage (#836)
  [Application] Enforce minimum stake when staking (#847)
  Empty commit
  [Tokenomics] Prevent GMR to produce zero values (#866)
  Empty commit
  [Application] Add `min_stake` application module param (#845)
  chore: regenerate protobufs
  ...
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
* issues/612/proof/refresh: (46 commits)
  test: supplier up-staking from below min. stake
  fix: linter error
  fix: flaky test
  [Application] Enforce minimum stake when burning (#848)
  Empty commit
  chore: review feedback improvements
  chore: regenerate protobufs
  chore: review feedback improvements
  test: fix application min stake integration test
  chore: review feedback improvements
  Empty commit
  fix: linter error
  chore: quick fixes
  [DifficultyHash] Prepare for difficulty multiplier usage (#836)
  [Application] Enforce minimum stake when staking (#847)
  Empty commit
  [Tokenomics] Prevent GMR to produce zero values (#866)
  Empty commit
  [Application] Add `min_stake` application module param (#845)
  chore: regenerate protobufs
  ...

# Conflicts:
#	x/service/types/errors.go
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
## Summary

```bash
ignite scaffold message update-param --module supplier --signer authority name as_type --response params
```

Adds the `MsgUpdateParam` message so that the supplier module may update
individual parameters following section 0 from the updated docs (see
#839).

## Dependencies

- #809
- #843 
- #844 
- #845
- #847
- #848

## Dependents
  
- #850
- #857
- #852 
- #861 
- #851 
- #863 

## Issue

- #612

## Type of change

Select one or more from the following:

- [x] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [ ] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [x] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [x] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [x] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <r3d0ne@gmail.com>
Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
Co-authored-by: red-0ne <red-0ne@users.noreply.github.com>
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
…-uint64

* issues/612/service/refresh: (46 commits)
  test: supplier up-staking from below min. stake
  fix: linter error
  fix: flaky test
  [Application] Enforce minimum stake when burning (#848)
  Empty commit
  chore: review feedback improvements
  chore: regenerate protobufs
  chore: review feedback improvements
  test: fix application min stake integration test
  chore: review feedback improvements
  Empty commit
  fix: linter error
  chore: quick fixes
  [DifficultyHash] Prepare for difficulty multiplier usage (#836)
  [Application] Enforce minimum stake when staking (#847)
  Empty commit
  [Tokenomics] Prevent GMR to produce zero values (#866)
  Empty commit
  [Application] Add `min_stake` application module param (#845)
  chore: regenerate protobufs
  ...
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
## Summary

- Adds the `min_stake` param to the supplier module following section 0
from the updated docs (see
#839).
- Adds missing validation unit test coverage around existing application
module param, max_delegated_gateways.
- Pushes validation from the MsgUpdateParam handler down into
MsgUpdateParam#ValidateBasic().
- Ensures Params#Valid() is called prior to setting params in
MsgUpdateParam handler.
- Updates error returns in the same handler to ensure all error paths
return appropriate gRPC status errors.

## Dependencies

- #809
- #843 
- #844 
- #845
- #847
- #848
- #849

## Dependents
  
- #857
- #852 
- #861 
- #851 
- #863 

## Issue

- #612

## Type of change

Select one or more from the following:

- [x] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [ ] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [ ] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [x] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [x] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <r3d0ne@gmail.com>
Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
Co-authored-by: red-0ne <red-0ne@users.noreply.github.com>
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
## Summary

1. Adds minimum stake validation to the supplier stake message handler
(i.e. total stake must be >= minimum stake).
2. Updates error returns in the same handler to ensure all error paths
return appropriate gRPC status errors.

## Dependencies

- #809
- #843 
- #844 
- #845
- #847
- #848
- #849
- #850

## Dependents
  
- #852 
- #861 
- #851 

## Issue

- #612

## Type of change

Select one or more from the following:

- [x] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [ ] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [ ] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [x] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <r3d0ne@gmail.com>
Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
Co-authored-by: red-0ne <red-0ne@users.noreply.github.com>
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
…cation

* pokt/main:
  [Supplier] Enforce minimum stake when staking (#857)
  [Supplier] Add `min_stake` supplier module param (#850)
  [Supplier] Add `MsgUpdateParam` to application module (#849)
  [Application] Enforce minimum stake when burning (#848)
@bryanchriswhite bryanchriswhite deleted the issues/612/application/burning branch October 14, 2024 12:20
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
## Summary

The "adding_params.md" doc has (or will have) changed substantially (see
#839) since the shared module's param logic was last updated. This PR
aligns the shared module's param logic with the snippets in the updated
docs.

Specifically, this refresh includes:
- Moving validation logic from `msgServer#UpdateParam()` to
`MsgUpdateParam#ValidateBasic()`.
- Replacing magic strings of param names with their standard variable
counterparts (i.e. `sharedtypes.Param...`).
- Improving some local variable names.
- Replacing usages of `interface{}` with `any`.

## Dependencies

- #809
- #843 
- #844 
- #845
- #847
- #848
- #849
- #850
- #857

## Dependents

- #851 
- #861 

## Issue

- #612

## Type of change

Select one or more from the following:

- [ ] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [x] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [ ] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [ ] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <r3d0ne@gmail.com>
Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
Co-authored-by: red-0ne <red-0ne@users.noreply.github.com>
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
## Summary

The "adding_params.md" doc has (or will have) changed substantially (see
#839) since the proof module's param logic was last updated. This PR
aligns the proof module's param logic with the snippets in the updated
docs.

Specifically, this refresh includes:
- Moving validation logic from `msgServer#UpdateParam()` to
`MsgUpdateParam#ValidateBasic()`.
- Replacing magic strings of param names with their standard variable
counterparts (i.e. `prooftypes.Param...`).
- Improving some local variable names.
- Replacing usages of `interface{}` with `any`.
- Improving validation for all coin type params to be consistent with
application, gateway, and supplier coin type validation.

# Dependencies

- #809
- #843 
- #844 
- #845
- #847
- #848
- #849
- #850
- #857
- #852

## Dependents

- #861 

## Issue

- #612

## Type of change

Select one or more from the following:

- [ ] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [x] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [ ] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [x] I have tested my changes using the available tooling
- [ ] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <r3d0ne@gmail.com>
Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
Co-authored-by: red-0ne <red-0ne@users.noreply.github.com>
bryanchriswhite added a commit that referenced this pull request Oct 14, 2024
## Summary

The "adding_params.md" doc has (or will have) changed substantially (see
#839) since the shared module's param logic was last updated. This PR
aligns the service module's param logic with the snippets in the updated
docs.

Specifically, this refresh includes:
- Moving validation logic from `msgServer#UpdateParam()` to
`MsgUpdateParam#ValidateBasic()`.
- Replacing magic strings of param names with their standard variable
counterparts (i.e. `prooftypes.Param...`).
- Improving some local variable names.
- Replacing usages of `interface{}` with `any`.
- Improving validation for all coin type params to be consistent with
application, gateway, and supplier coin type validation.

## Dependencies

- #809
- #843 
- #844 
- #845
- #847
- #848
- #849
- #850
- #857
- #852 
- #851

## Issue

- #612

## Type of change

Select one or more from the following:

- [ ] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [x] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [ ] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [ ] I have tested my changes using the available tooling
- [ ] I have commented my code
- [ ] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable

---------

Co-authored-by: Redouane Lakrache <r3d0ne@gmail.com>
Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
Co-authored-by: red-0ne <red-0ne@users.noreply.github.com>
bryanchriswhite added a commit that referenced this pull request Oct 15, 2024
…ed-params

* pokt/main:
  [On-Chain] Refactor `uint64` type individual param update logic (#863)
  [Service] Refresh service module params logic (#861)
  [Proof] Refresh proof module params logic (#851)
  [Shared] Refresh shared module params logic (#852)
  [Docs] Fix example of how to set rev share precentage (#877)
  [Tokenomics] Implement difficulty proportional rewards (#880)
  [Supplier] Enforce minimum stake when staking (#857)
  [Supplier] Add `min_stake` supplier module param (#850)
  [Supplier] Add `MsgUpdateParam` to application module (#849)
  [Application] Enforce minimum stake when burning (#848)
  [DifficultyHash] Prepare for difficulty multiplier usage (#836)
  [Application] Enforce minimum stake when staking (#847)
  [Tokenomics] Prevent GMR to produce zero values (#866)
bryanchriswhite added a commit that referenced this pull request Oct 15, 2024
* pokt/main:
  [On-Chain] Refactor `uint64` type individual param update logic (#863)
  [Service] Refresh service module params logic (#861)
  [Proof] Refresh proof module params logic (#851)
  [Shared] Refresh shared module params logic (#852)
  [Docs] Fix example of how to set rev share precentage (#877)
  [Tokenomics] Implement difficulty proportional rewards (#880)
  [Supplier] Enforce minimum stake when staking (#857)
  [Supplier] Add `min_stake` supplier module param (#850)
  [Supplier] Add `MsgUpdateParam` to application module (#849)
  [Application] Enforce minimum stake when burning (#848)
  [DifficultyHash] Prepare for difficulty multiplier usage (#836)
  [Application] Enforce minimum stake when staking (#847)
  [Tokenomics] Prevent GMR to produce zero values (#866)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
application Changes related to the Application actor consensus-breaking IMPORTANT! If the PR with this tag is merged, next release WILL HAVE TO BE an upgrade. devnet devnet-test-e2e on-chain On-chain business logic protocol General core protocol related changes push-image CI related - pushes images to ghcr.io
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[Utility] Minimum staking values for each actor
2 participants