-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Supplier] Refactor/non custodial staking tests #718
Conversation
… refactor/non-custodial-staking-tests
… refactor/non-custodial-staking-tests
… refactor/non-custodial-staking-tests
… refactor/non-custodial-staking-tests
… refactor/non-custodial-staking-tests
The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks. You may need to run GCP workloads (requires changing the namespace to 718) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an OPTIONAL minor NIT, but otherwise looks g2g!
… refactor/non-custodial-staking-tests
## Summary This PR implements non-custodial staking by * Adding a `Supplier.OwnerAddress` that represents the `Supplier` owner * Modifying `stake` and `unstake` CLI * Ensure that only the owner is able to `stake`, `unstake`, `change owner`, `change operator` * Update supplier staking config parser * Have the owner receive the rewards. *NOTE: ~950LOC is proto auto-generated code* The PR will be ready after: - [ ] Validating non-custodial logic added in this PR - [ ] Merging #718 into this one - [ ] Merging #720 into this one - [ ] Merging #722 into this one ## Issue - #493 - https://www.notion.so/buildwithgrove/Non-custodial-staking-92a136174dac41279717e8b963672e38 ## Type of change Select one or more: - [x] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Documentation - [ ] Other (specify) ## Testing **Documentation changes** (only if making doc changes) - [ ] `make docusaurus_start`; only needed if you make doc changes **Local Testing** (only if making code changes) - [ ] **Unit Tests**: `make go_develop_and_test` - [ ] **LocalNet E2E Tests**: `make test_e2e` - See [quickstart guide](https://dev.poktroll.com/developer_guide/quickstart) for instructions **PR Testing** (only if making code changes) - [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR. - **THIS IS VERY EXPENSIVE**, so only do it after all the reviews are complete. - Optionally run `make trigger_ci` if you want to re-trigger tests without any code changes - If tests fail, try re-running failed tests only using the GitHub UI as shown [here](https://github.com/pokt-network/poktroll/assets/1892194/607984e9-0615-4569-9452-4c730190c1d2) ## 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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new field `OwnerAddress` in the `Supplier` struct for improved ownership management. - Enhanced supplier configuration structures with `OwnerAddress` and `OperatorAddress` fields for better role management. - Added new validation methods to ensure correct ownership and operator address integrity. - **Bug Fixes** - Improved validation logic to ensure only authorized users can modify supplier details. - **Documentation** - Clarified comments in code to improve understanding of address management and supplier roles. - **Chores** - Added new error constants to enhance error handling and user feedback for supplier-related operations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
WalkthroughThe recent changes enhance the structure and functionality of supplier-related entities across multiple files. Key modifications include the addition of an Changes
Recent review detailsConfiguration used: CodeRabbit UI Files ignored due to path filters (1)
Files selected for processing (18)
Files skipped from review due to trivial changes (1)
Additional context usedGitHub Check: misspell
Additional comments not posted (42)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (7)
x/supplier/types/message_unstake_supplier_test.go (5)
20-26
: Enhance error message clarity.The test case description "invalid operator address" is clear, but consider providing more context in the expected error message to ensure clarity during test failures.
- expectedErr: ErrSupplierInvalidAddress, + expectedErr: fmt.Errorf("invalid operator address: %w", ErrSupplierInvalidAddress),
28-33
: Clarify missing address error.The test case for "missing operator address" could benefit from a more descriptive error message to clarify the cause of the error.
- expectedErr: ErrSupplierInvalidAddress, + expectedErr: fmt.Errorf("missing operator address: %w", ErrSupplierInvalidAddress),
35-41
: Improve invalid signer address test case.The test case for "invalid signer address" is well-structured. Ensure that the error message provides sufficient context for debugging.
- expectedErr: ErrSupplierInvalidAddress, + expectedErr: fmt.Errorf("invalid signer address: %w", ErrSupplierInvalidAddress),
43-48
: Enhance missing signer address error message.The "missing signer address" test case should include a more descriptive error message for better clarity.
- expectedErr: ErrSupplierInvalidAddress, + expectedErr: fmt.Errorf("missing signer address: %w", ErrSupplierInvalidAddress),
57-62
: Explicit handling for same signer and operator addresses is missing.The
ValidateBasic
method checks for valid Bech32 addresses but does not explicitly handle the case where theSigner
andAddress
are the same. Consider adding logic to handle this scenario if it is required.
x/supplier/types/message_unstake_supplier.go
:ValidateBasic
methodAnalysis chain
Verify same signer and operator addresses scenario.
The test case for "valid message - same signer and operator addresses" is a good addition. Verify that this scenario is handled correctly in the implementation.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify handling of same signer and operator addresses in MsgUnstakeSupplier. # Test: Search for handling logic in MsgUnstakeSupplier. Expect: Proper handling of same addresses. rg --type go -A 5 'func (m MsgUnstakeSupplier) ValidateBasic'Length of output: 63
Script:
#!/bin/bash # Search for the definition of MsgUnstakeSupplier and any associated methods. ast-grep --lang go --pattern 'type MsgUnstakeSupplier struct { $$$ }' # Search for any methods associated with MsgUnstakeSupplier. rg --type go 'func (m MsgUnstakeSupplier)' -A 10Length of output: 1225
Script:
#!/bin/bash # Search for references to MsgUnstakeSupplier in the codebase to identify usage or validation. rg --type go 'MsgUnstakeSupplier' -A 5Length of output: 66190
x/supplier/module/tx_unstake_supplier_test.go (1)
64-67
: Consider adding a test for missing operator address.While there is a test for a missing signer address, consider adding a similar test for a missing operator address.
+ { + desc: "unstake supplier: missing operator address", + signerAddress: ownerAccount.Address.String(), + expectedErr: types.ErrSupplierInvalidAddress, + },x/supplier/config/supplier_configs_reader_test.go (1)
493-493
: Correct spelling error in comment.The word "explictly" is misspelled. It should be "explicitly."
- # explictly omitted owner address + # explicitly omitted owner addressTools
GitHub Check: misspell
[warning] 493-493: [misspell] x/supplier/config/supplier_configs_reader_test.go#L493
"explictly" is a misspelling of "explicitly"
## Summary This PR implements non-custodial staking by * Adding a `Supplier.OwnerAddress` that represents the `Supplier` owner * Modifying `stake` and `unstake` CLI * Ensure that only the owner is able to `stake`, `unstake`, `change owner`, `change operator` * Update supplier staking config parser * Have the owner receive the rewards. *NOTE: ~950LOC is proto auto-generated code* The PR will be ready after: - [ ] Validating non-custodial logic added in this PR - [ ] Merging #718 into this one - [ ] Merging #720 into this one - [ ] Merging #722 into this one ## Issue - #493 - https://www.notion.so/buildwithgrove/Non-custodial-staking-92a136174dac41279717e8b963672e38 ## Type of change Select one or more: - [x] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Documentation - [ ] Other (specify) ## Testing **Documentation changes** (only if making doc changes) - [ ] `make docusaurus_start`; only needed if you make doc changes **Local Testing** (only if making code changes) - [ ] **Unit Tests**: `make go_develop_and_test` - [ ] **LocalNet E2E Tests**: `make test_e2e` - See [quickstart guide](https://dev.poktroll.com/developer_guide/quickstart) for instructions **PR Testing** (only if making code changes) - [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR. - **THIS IS VERY EXPENSIVE**, so only do it after all the reviews are complete. - Optionally run `make trigger_ci` if you want to re-trigger tests without any code changes - If tests fail, try re-running failed tests only using the GitHub UI as shown [here](https://github.com/pokt-network/poktroll/assets/1892194/607984e9-0615-4569-9452-4c730190c1d2) ## 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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new field `OwnerAddress` in the `Supplier` struct for improved ownership management. - Enhanced supplier configuration structures with `OwnerAddress` and `OperatorAddress` fields for better role management. - Added new validation methods to ensure correct ownership and operator address integrity. - **Bug Fixes** - Improved validation logic to ensure only authorized users can modify supplier details. - **Documentation** - Clarified comments in code to improve understanding of address management and supplier roles. - **Chores** - Added new error constants to enhance error handling and user feedback for supplier-related operations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary This PR is a follow-up to #716. * It refactors the existing unit/integration tests to add `Supplier.OwnerAddress` * Adapts the `Supplier` (un)staking and tests (staking config, (un)staking CLI and keeper methods) to comply with the `Supplier` non-custodial staking. ## Issue - #493 ## Type of change Select one or more: - [ ] New feature, functionality or library - [ ] Bug fix - [x] Code health or cleanup - [ ] Documentation - [ ] Other (specify) ## Testing **Documentation changes** (only if making doc changes) - [ ] `make docusaurus_start`; only needed if you make doc changes **Local Testing** (only if making code changes) - [x] **Unit Tests**: `make go_develop_and_test` - [ ] **LocalNet E2E Tests**: `make test_e2e` - See [quickstart guide](https://dev.poktroll.com/developer_guide/quickstart) for instructions **PR Testing** (only if making code changes) - [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR. - **THIS IS VERY EXPENSIVE**, so only do it after all the reviews are complete. - Optionally run `make trigger_ci` if you want to re-trigger tests without any code changes - If tests fail, try re-running failed tests only using the GitHub UI as shown [here](https://github.com/pokt-network/poktroll/assets/1892194/607984e9-0615-4569-9452-4c730190c1d2) ## 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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced readability of output messages in the Makefile. - Added `OwnerAddress` to the `Supplier` data model for better ownership tracking. - Introduced support for both owner and operator addresses in various staking and unstaking processes. - **Bug Fixes** - Updated tests for `MsgUnstakeSupplier` to correctly validate signer addresses and enhance robustness. - **Documentation** - Improved test coverage and clarity for supplier-related functionality, reflecting the new data model changes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
This PR is a follow-up to #716.
Supplier.OwnerAddress
Supplier
(un)staking and tests (staking config, (un)staking CLI and keeper methods) to comply with theSupplier
non-custodial staking.Issue
Type of change
Select one or more:
Testing
Documentation changes (only if making doc changes)
make docusaurus_start
; only needed if you make doc changesLocal Testing (only if making code changes)
make go_develop_and_test
make test_e2e
PR Testing (only if making code changes)
devnet-test-e2e
label to the PR.make trigger_ci
if you want to re-trigger tests without any code changesSanity Checklist
Summary by CodeRabbit
New Features
OwnerAddress
to theSupplier
data model for better ownership tracking.Bug Fixes
MsgUnstakeSupplier
to correctly validate signer addresses and enhance robustness.Documentation