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

Injectable locked coins functionality #577

Merged
merged 10 commits into from
Jul 18, 2023

Conversation

SpicyLemon
Copy link

@SpicyLemon SpicyLemon commented Jul 6, 2023

Description

Related: provenance-io/provenance#1619

This PR:

  1. Create a GetLockedCoinsFn type and allows them to be provided to the bank's view keeper.
  2. Renames LockedCoins to UnvestedCoins, appends UnvestedCoins as a GetLockedCoinsFn by default, and remakes LockedCoins to just call the defined GetLockedCoinsFn.
  3. Updates SpendableCoins to ignore only resulting negative/zero denoms instead of reporting that nothing is spendable when one denom is over-locked.
  4. Adds a call to SendRestrictionFn to DelegateCoins.
  5. In SendCoins, moves the SendRestrictionFn call to after subUnlockedCoins so that all calls to the SendRestrictionFn now happen after the subtraction but before the addition.

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

…keeper. Also, call the send restriction function during DelegateCoins.
…he subUnlockedCoins so that it happens in the same order as InputOutputCoins and also does the most-likely thing to fail first.
…coin entries. In SpendableCoins, when there's a negative coin, only ignore those rather than claiming there's no spendable balance at all.
…t to not do a partial write for the expected-to-fail SendCoins.
…nsWithRestrictions to use a cache context to not get partial updates.
…r the coins have been subtracted from the source account.
@SpicyLemon SpicyLemon changed the title Injectable locked coins funcitonality Injectable locked coins functionality Jul 6, 2023
…ecause the last validator was being removed at the end of the last block. So the exported state didn't have any validators causing the import to panic. When that happens on other blocks, it handles it just fine, it was just that it was happening on the very last block that caused the problem.
@SpicyLemon
Copy link
Author

The following make targets completed without issue: test test-sim-nondeterminism test-sim-import-export test-sim-after-import test-sim-multi-seed-short

@SpicyLemon SpicyLemon merged commit 163cf53 into main-pio Jul 18, 2023
SpicyLemon added a commit that referenced this pull request Jul 28, 2023
* [1619]: Create a GetLockedCoinsFn that can be injected into the view keeper. Also, call the send restriction function during DelegateCoins.

* [1619]: Move the send restriction application in SendCoins to after the subUnlockedCoins so that it happens in the same order as InputOutputCoins and also does the most-likely thing to fail first.

* [1619]: Wrap all GetLockedCoinsFn such that it only returns positive coin entries. In SpendableCoins, when there's a negative coin, only ignore those rather than claiming there's no spendable balance at all.

* [1619]: Tweak the spec doc.

* [1619]: Tweak the sanction TestBankSendCoinsUsesSendRestrictionFn test to not do a partial write for the expected-to-fail SendCoins.

* [1619]: Refactor TestInputOutputCoinsWithRestrictions and TestSendCoinsWithRestrictions to use a cache context to not get partial updates.

* [1619]: Tweak/fix some comments.

* [1619]: Move the sendRestriction application in DelegateCoins to after the coins have been subtracted from the source account.

* [1619]: Fix test-sim-after-import that started failing at seed 3012 because the last validator was being removed at the end of the last block. So the exported state didn't have any validators causing the import to panic. When that happens on other blocks, it handles it just fine, it was just that it was happening on the very last block that caused the problem.

* [1619]: Add changelog entry.
SpicyLemon added a commit that referenced this pull request Jul 31, 2023
…nd (#578) (#579)

* Injectable locked coins functionality (#577)

* [1619]: Create a GetLockedCoinsFn that can be injected into the view keeper. Also, call the send restriction function during DelegateCoins.

* [1619]: Move the send restriction application in SendCoins to after the subUnlockedCoins so that it happens in the same order as InputOutputCoins and also does the most-likely thing to fail first.

* [1619]: Wrap all GetLockedCoinsFn such that it only returns positive coin entries. In SpendableCoins, when there's a negative coin, only ignore those rather than claiming there's no spendable balance at all.

* [1619]: Tweak the spec doc.

* [1619]: Tweak the sanction TestBankSendCoinsUsesSendRestrictionFn test to not do a partial write for the expected-to-fail SendCoins.

* [1619]: Refactor TestInputOutputCoinsWithRestrictions and TestSendCoinsWithRestrictions to use a cache context to not get partial updates.

* [1619]: Tweak/fix some comments.

* [1619]: Move the sendRestriction application in DelegateCoins to after the coins have been subtracted from the source account.

* [1619]: Fix test-sim-after-import that started failing at seed 3012 because the last validator was being removed at the end of the last block. So the exported state didn't have any validators causing the import to panic. When that happens on other blocks, it handles it just fine, it was just that it was happening on the very last block that caused the problem.

* [1619]: Add changelog entry.

* Add binary version to status (#578)

* Added custom nodeInfo type on response, and query for NodeInfo in order to get binary version. Refactored code to remove circular dependency.

* Added json tags to lowercase fields.

* Removed comment.

* Added ChangeLog entry.

---------

Co-authored-by: Matt Witkowski <mwitkowski@provenance.io>
@SpicyLemon SpicyLemon deleted the prov/dwedul/1619-inj-locked-coins branch December 17, 2024 18:48
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