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

[Session,Service] Ensure SessionHeader and Service basic validation. #782

Merged
merged 14 commits into from
Sep 10, 2024

Conversation

red-0ne
Copy link
Contributor

@red-0ne red-0ne commented Sep 3, 2024

Summary

This PR addresses the following TODO_BETAs:

TODO_BETA: Call msg.GetSessionHeader().ValidateBasic() once its implemented

TODO_BETA: Ensure this is used everywhere a SessionHeader is validated.

TODO_TECHDEBT(BETA): Refactor to a Service#ValidateBasic method.

  • It ensures that SessionHeader#ValidateBasic() is covering all usage of SessionHeader both on-chain and off-chain.
  • Implements Service#ValidateBasic which is a sub-check of SessionHeader#ValidateBasic
  • Refactors some tests to align with the new shape of the errors returned.

Type of change

Select one or more:

  • New feature, functionality or library
  • 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

  • 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

@red-0ne red-0ne added service Anything related to general-purpose RPC service support session Changes related to Session management off-chain Off-chain business logic on-chain On-chain business logic code health Cleans up some code labels Sep 3, 2024
@red-0ne red-0ne self-assigned this Sep 3, 2024
@okdas okdas added the consensus-breaking IMPORTANT! If the PR with this tag is merged, next release WILL HAVE TO BE an upgrade. label Sep 3, 2024
@Olshansk Olshansk added this to the Shannon Beta TestNet Launch milestone Sep 5, 2024
x/proof/keeper/msg_server_submit_proof_test.go Outdated Show resolved Hide resolved
x/proof/types/message_create_claim.go Outdated Show resolved Hide resolved
x/proof/types/message_submit_proof.go Outdated Show resolved Hide resolved
x/proof/types/message_submit_proof_test.go Outdated Show resolved Hide resolved
return ErrSharedInvalidService.Wrapf("invalid service name: %s", s.Name)
}

return nil
Copy link
Member

Choose a reason for hiding this comment

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

Please ensure the other fields (e.g. owner, CUPR, etc...) aren't empty and/or valid as well.

Copy link
Member

Choose a reason for hiding this comment

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

This might require adding unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Service evolved. Good catch!

Copy link
Contributor Author

@red-0ne red-0ne Sep 6, 2024

Choose a reason for hiding this comment

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

Adding these fields to the validation breaks a lot of code and tests because we're creating services with Id only in a lot of places, Instead, I propose to replace these Services with Ids in a follow-up PR as stated in service.proto

// TODO_MAINNET: Avoid embedding the full Service because we just need the ID.

I estimate it could be done in 1 day. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

How about this:

  1. Add TODO_BETA/TODO_BLOCKER(@red-0ne): ... in the validation function explaining this situation
  2. Update the PR and merge it in
  3. Iterate on the ServiceId thing next week

@red-0ne red-0ne requested a review from Olshansk September 7, 2024 00:47
Copy link
Contributor

@bryanchriswhite bryanchriswhite left a comment

Choose a reason for hiding this comment

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

Nice one! 🚀

x/proof/types/message_submit_proof_test.go Outdated Show resolved Hide resolved
x/proof/types/message_submit_proof_test.go Show resolved Hide resolved
x/proof/types/message_submit_proof_test.go Outdated Show resolved Hide resolved
x/session/keeper/session_hydrator.go Outdated Show resolved Hide resolved
x/session/types/session_header.go Outdated Show resolved Hide resolved
x/session/types/session_header.go Outdated Show resolved Hide resolved
x/session/types/session_header.go Outdated Show resolved Hide resolved
x/shared/helpers/service_configs.go Outdated Show resolved Hide resolved
x/shared/helpers/service_configs.go Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Sep 9, 2024

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 make trigger_ci to submit an empty commit that'll trigger the tests.

GCP workloads (requires changing the namespace to 782)
Grafana network dashboard for devnet-issue-782

@github-actions github-actions bot added devnet push-image CI related - pushes images to ghcr.io labels Sep 9, 2024
x/shared/types/service.go Show resolved Hide resolved
@red-0ne red-0ne merged commit 614ad77 into main Sep 10, 2024
10 checks passed
bryanchriswhite added a commit that referenced this pull request Sep 16, 2024
…ke-transfer

* pokt/main:
  [Tooling, Code Health] refactor: split Makefile into multiple files (#816)
  [Tooling] fix and add makefile targets (#814)
  [Docs] Add a debugging tip: using transaction hashes (#786)
  [Refactor] Replace embedded Service with ServiceId (#802)
  [Session,Service] Ensure SessionHeader and Service basic validation. (#782)
  [Tokenomics] Preparation for Global Mint Reimbursement Request (#755)
  [Quick PR][LocalNet] Turn off minimum-gas-prices (#805)
  [GATEWAY POC] A couple helpers to help deploy a PATH gateway (#801)
  [Documentation] Cosmovisor  (#768)
  [CI] Add cosmovisor to container images (#796)
  Use a descriptive error if service ID is not found (#787)
  [SessionManager] Implement off-chain proof params usage (#765)
  [SDK] Update shannon sdk dependency (#800)
  [E2E Test] Remove redundant logging (#798)
bryanchriswhite added a commit that referenced this pull request Sep 16, 2024
…actor/transfer-msg_period-param

* issues/657/feat/app-stake-transfer:
  [Tooling, Code Health] refactor: split Makefile into multiple files (#816)
  [Tooling] fix and add makefile targets (#814)
  [Docs] Add a debugging tip: using transaction hashes (#786)
  [Refactor] Replace embedded Service with ServiceId (#802)
  [Session,Service] Ensure SessionHeader and Service basic validation. (#782)
  [Tokenomics] Preparation for Global Mint Reimbursement Request (#755)
  [Quick PR][LocalNet] Turn off minimum-gas-prices (#805)
  [GATEWAY POC] A couple helpers to help deploy a PATH gateway (#801)
  [Documentation] Cosmovisor  (#768)
  [CI] Add cosmovisor to container images (#796)
  Use a descriptive error if service ID is not found (#787)
  [SessionManager] Implement off-chain proof params usage (#765)
  [SDK] Update shannon sdk dependency (#800)
  [E2E Test] Remove redundant logging (#798)
bryanchriswhite added a commit that referenced this pull request Sep 16, 2024
…ues/657/chore/app-transfer-period

* issues/657/refactor/transfer-msg_period-param:
  [Tooling, Code Health] refactor: split Makefile into multiple files (#816)
  [Tooling] fix and add makefile targets (#814)
  [Docs] Add a debugging tip: using transaction hashes (#786)
  [Refactor] Replace embedded Service with ServiceId (#802)
  [Session,Service] Ensure SessionHeader and Service basic validation. (#782)
  [Tokenomics] Preparation for Global Mint Reimbursement Request (#755)
  [Quick PR][LocalNet] Turn off minimum-gas-prices (#805)
  [GATEWAY POC] A couple helpers to help deploy a PATH gateway (#801)
  [Documentation] Cosmovisor  (#768)
  [CI] Add cosmovisor to container images (#796)
  Use a descriptive error if service ID is not found (#787)
  [SessionManager] Implement off-chain proof params usage (#765)
  [SDK] Update shannon sdk dependency (#800)
  [E2E Test] Remove redundant logging (#798)
okdas pushed a commit that referenced this pull request Nov 14, 2024
…782)

## Summary

This PR addresses the following `TODO_BETA`s:

> `TODO_BETA: Call `msg.GetSessionHeader().ValidateBasic()` once its
implemented`

> `TODO_BETA: Ensure this is used everywhere a SessionHeader is
validated.`

> `TODO_TECHDEBT(BETA): Refactor to a `Service#ValidateBasic` method.`

* It ensures that `SessionHeader#ValidateBasic()` is covering all usage
of `SessionHeader` both on-chain and off-chain.
* Implements `Service#ValidateBasic` which is a sub-check of
`SessionHeader#ValidateBasic`
* Refactors some tests to align with the new shape of the errors
returned.


## Type of change

Select one or more:

- [ ] New feature, functionality or library
- [ ] Bug fix
- [x] 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`
- [x] **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: Daniel Olshansky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Cleans up some code consensus-breaking IMPORTANT! If the PR with this tag is merged, next release WILL HAVE TO BE an upgrade. devnet devnet-test-e2e off-chain Off-chain business logic on-chain On-chain business logic push-image CI related - pushes images to ghcr.io service Anything related to general-purpose RPC service support session Changes related to Session management
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants