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

[Utility] trustless relay e2e happy case (POC PR) #869

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

adshmh
Copy link
Contributor

@adshmh adshmh commented Jul 3, 2023

Description

[POC] This is a POC PR to add E2E happy case for trsutless relays, described in #754. It is not meant to be merged, but used to:

  1. Review the overall approach
  2. Define all the required small PRs for making the E2E test pass.

Summary generated by Reviewpad on 30 Jul 23 21:42 UTC

This pull request includes changes across multiple files.

Here is a summary of the changes:

  • In the PostV1ClientRelay function, a new field ApplicationAddress is added to the relayMeta struct.
  • In the buildJsonRPCRelayPayload function, the field JsonRpc is changed to Jsonrpc for the payload struct. Additionally, the field Id is changed to use a pointer and include the coreTypes.JSONRPCId struct.
  • The field Parameters in the body.Payload struct is changed to Params.
  • Added import statements: crypto/tls, encoding/json.
  • Updated function validateRelayChainSupport: Added a new variable servicerAddrBz and decoded the s.config.Address as a byte array before passing it to readCtx.GetServicer.
  • Updated function executeJsonRPCRelay: Changed the way payload is marshalled to JSON using json.Marshal instead of codec.GetCodec().Marshal.
  • Updated function executeHTTPRelay: Added a new import statement crypto/tls. Added a new variable tr of type http.Transport with TLSClientConfig set to tls.Config{InsecureSkipVerify: true}. Modified the http.Client initialization to include the new transport configuration.
  • In the file shared/core/types/relay.go: In the Validate method of the JSONRPCPayload struct, the p.JsonRpc field has been changed to p.Jsonrpc in the condition and error message. Added a new MarshalJSON method to the JSONRPCId struct to customize the JSON marshalling process.
  • In the servicer.go file in the app/client/cli directory: Line 107 - Added applicationAddr as an argument to the buildRelay function call. Line 145 - Added a check for unmarshalling the relay payload using JSON. Line 267 - Added ApplicationAddress to the relayMeta struct.
  • In the file rpc/v1/openapi.yaml: Added a comment indicating the need for support for string, number, and NULL values as per the JSONRPC spec. Removed the format: byte property from the id field. Added an items property to the params field, specifying that it should be an array of strings. Added the application_address field to the Payload object, which is of type string.
  • In the new file "trustless_relays.feature": Added two scenarios to test the successful response of an application requesting the account balance and the timeout scenario. Also included some comments and TODOs for future improvements and test cases.
  • In the Makefile: Added a new target test_e2e_relay, modified the test_all_with_json_coverage target, and updated the TODO_KEYWORDS variable.
  • In the relay_test.go file in the shared/core/types package: Added an import statement for the encoding/json package. Changed the field JsonRpc of the JSONRPCPayload struct to Jsonrpc in two test functions. Added a new test function to check the MarshalJSON method of the JSONRPCPayload struct.
  • In the file "e2e/tests/steps_init_test.go": Added import statements for "net/http" and "time". Added constant variables and populated maps. Added methods for initialization, sending relays, and checking relay responses. Added a setup function for causing a timeout.
  • In the relay.proto file: Added a new message JSONRPCId, changed types, renamed fields, and added comments.
  • In the "configs.yaml" file: Modified the "chains" field and the "service_url" field for one entry.
  • Added a new file "pocket-servicer-overrides.yaml" with configuration overrides for the Pocket servicer.

Please review these changes carefully and let me know if you need any further assistance.

Issue

Part of work on #754

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other

List of changes

  • happy e2e test case for trustless relays
  • all proto/openapi changes needed to make the test pass
  • all bug fixes needed to make the happy test case pass

Testing

  • make develop_test; if any code changes were made
  • make test_e2e on k8s LocalNet; if any code changes were made
  • e2e-devnet-test passes tests on DevNet; if any code was changed
  • Docker Compose LocalNet; if any major functionality was changed or introduced
  • k8s LocalNet; if any infrastructure or configuration changes were made

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added, or updated, godoc format comments on touched members (see: tip.golang.org/doc/comment)
  • I have tested my changes using the available tooling

If Applicable Checklist

  • I have updated the corresponding README(s); local and/or global
  • I have added tests that prove my fix is effective or that my feature works
  • I have added, or updated, mermaid.js diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@adshmh adshmh added utility Utility specific changes do not merge Prevent merging even with sufficient approvals labels Jul 3, 2023
@adshmh adshmh self-assigned this Jul 3, 2023
@reviewpad reviewpad bot added medium Pull request is medium waiting-for-review labels Jul 3, 2023
@adshmh adshmh added this to the M3: Pocket RoS (Relay or Slash) milestone Jul 3, 2023
@adshmh adshmh requested review from dylanlott and Olshansk July 3, 2023 14:29
@adshmh
Copy link
Contributor Author

adshmh commented Jul 3, 2023

@dylanlott and @Olshansk please note this is a POC only PR and not intended to be merged. I have added the list of PRs that will be opened to make the necessary code changes. The review request here is to make sure the overall approach is reasonable.

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

Did a quick initial (partial) review and will do a deeper one on Wednesday

@@ -1699,7 +1699,7 @@ data:
"address": "001022b138896c4c5466ac86b24a9bbe249905c2",
"public_key": "56915c1270bc8d9280a633e0be51647f62388a851318381614877ef2ed84a495",
"chains": ["0001"],
"service_url": "servicer-001-pocket:42069",
"service_url": "http://servicer-001-pocket:50832",
Copy link
Member

Choose a reason for hiding this comment

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

why did we update the port?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Port 50832 is the configured RPC port, so 42069 seems incorrect (encountered this while running the E2E test introduced in this PR)

Copy link
Member

Choose a reason for hiding this comment

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

I think we should update all the RPC ports then to avoid a discrepancy:

Screenshot 2023-07-05 at 4 07 04 PM

If you want to do it in a small separate PR (while this one is being reviewed), I support that!

Copy link
Member

Choose a reason for hiding this comment

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

Is the intention to do it in this PR (given the comment)?

I still think a different small "micro PR" could be simpler & faster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still think a different small "micro PR" could be simpler & faster

Yes, I will open a separate, small PR for this shortly.

charts/pocket/pocket-servicer-overrides.yaml Show resolved Hide resolved
charts/pocket/pocket-servicer-overrides.yaml Show resolved Hide resolved
e2e/tests/steps_init_test.go Outdated Show resolved Hide resolved
e2e/tests/steps_init_test.go Outdated Show resolved Hide resolved
shared/k8s/debug.go Outdated Show resolved Hide resolved
rpc/v1/openapi.yaml Outdated Show resolved Hide resolved
utility/servicer/module.go Outdated Show resolved Hide resolved
e2e/tests/trustless_relays.feature Show resolved Hide resolved
e2e/tests/trustless_relays.feature Outdated Show resolved Hide resolved
@adshmh
Copy link
Contributor Author

adshmh commented Jul 4, 2023

Did a quick initial (partial) review and will do a deeper one on Wednesday

Thank you for the review. I have updated the PR with to address the review comments marked as resolved.

e2e/tests/steps_init_test.go Outdated Show resolved Hide resolved
e2e/tests/steps_init_test.go Outdated Show resolved Hide resolved
@@ -1699,7 +1699,7 @@ data:
"address": "001022b138896c4c5466ac86b24a9bbe249905c2",
"public_key": "56915c1270bc8d9280a633e0be51647f62388a851318381614877ef2ed84a495",
"chains": ["0001"],
"service_url": "servicer-001-pocket:42069",
"service_url": "http://servicer-001-pocket:50832",
Copy link
Member

Choose a reason for hiding this comment

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

I think we should update all the RPC ports then to avoid a discrepancy:

Screenshot 2023-07-05 at 4 07 04 PM

If you want to do it in a small separate PR (while this one is being reviewed), I support that!

charts/pocket/pocket-servicer-overrides.yaml Show resolved Hide resolved
shared/k8s/debug.go Outdated Show resolved Hide resolved
rpc/handlers.go Outdated Show resolved Hide resolved
e2e/tests/trustless_relays.feature Show resolved Hide resolved
e2e/tests/trustless_relays.feature Outdated Show resolved Hide resolved
e2e/tests/trustless_relays.feature Show resolved Hide resolved
utility/servicer/module.go Outdated Show resolved Hide resolved
@adshmh
Copy link
Contributor Author

adshmh commented Jul 6, 2023

I think we should update all the RPC ports then to avoid a discrepancy:

Thank you for the review. Will open a separate PR for this shortly.

@adshmh adshmh requested a review from Olshansk July 6, 2023 12:26
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

  1. Replied to a few previous comments.
  2. Seems like there are related blocking tests
  3. No further action from my end until the IN_THIS_PR comments are addressed

Screenshot 2023-07-06 at 1 41 56 PM

@@ -1699,7 +1699,7 @@ data:
"address": "001022b138896c4c5466ac86b24a9bbe249905c2",
"public_key": "56915c1270bc8d9280a633e0be51647f62388a851318381614877ef2ed84a495",
"chains": ["0001"],
"service_url": "servicer-001-pocket:42069",
"service_url": "http://servicer-001-pocket:50832",
Copy link
Member

Choose a reason for hiding this comment

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

Is the intention to do it in this PR (given the comment)?

I still think a different small "micro PR" could be simpler & faster

rpc/handlers.go Outdated Show resolved Hide resolved
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

@adshmh Seems like there are some broken tests in shared/core/types/relay_test.go that need to be updated as well

Olshansk added a commit that referenced this pull request Jul 14, 2023
## Description

<!-- reviewpad:summarize:start -->
### Summary generated by Reviewpad on 14 Jul 23 23:17 UTC
This pull request includes a series of patches that make changes to the file `debug.go` in the `shared/k8s` directory. 

Patch 1/5: The patch retrieves keys for all actors from k8s secrets. It adds support for retrieving private keys for validators, servicers, fisherman, and applications.

Patch 2/5: This patch fixes a linter error in the `fetchPrivateKeys` function by updating the function signature to use a single string parameter for `resourceName` and `actor`.

Patch 3/5: This patch further fixes linter errors in the same function and shortens the code by removing unnecessary switch cases.

Patch 4/5: This patch updates the constant for the secret resource name from `privateKeysSecretResourceNameFisherman` to `privateKeysSecretResourceNameFishermen`.

Patch 5/5: This patch fixes a typo in the function name `FetchFishermanPrivateKeys` by updating the privateKeysSecretResourceName to `privateKeysSecretResourceNameFishermen`.

Please review these changes and ensure they are appropriate.
<!-- reviewpad:summarize:end -->

## Issue

Added as a TODO in #869:

<img width="1548" alt="Screenshot 2023-07-12 at 5 10 03 PM" src="https://github.com/pokt-network/pocket/assets/1892194/b1409bdd-4240-4993-b7dd-6197beae5500">

## Type of change

Please mark the relevant option(s):

- [ ] New feature, functionality or library
- [ ] Bug fix
- [x] Code health or cleanup
- [ ] Major breaking change
- [ ] Documentation
- [ ] Other <!-- add details here if it a different type of change -->

## List of changes

- Fetch keys for all actors from k8s instead of just validators so they can be used in our debug libraries

## Testing

- [x] `make develop_test`; if any code changes were made
- [x] `make test_e2e` on [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any code changes were made
- [ ] `e2e-devnet-test` passes tests on [DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd); if any code was changed
- [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced
- [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made

## Required Checklist

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment))
- [ ] I have tested my changes using the available tooling
- [ ] I have updated the corresponding CHANGELOG

### If Applicable Checklist

- [ ] I have updated the corresponding README(s); local and/or global
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s)
- [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s)


Co-authored-by: Dima Kniazev <[email protected]>
@adshmh adshmh mentioned this pull request Jul 20, 2023
19 tasks
adshmh added a commit that referenced this pull request Jul 21, 2023
## Description

Update servicers' URLs in LocalNet configuration.

## Issue

Part of work on #869 

## Type of change

Please mark the relevant option(s):

- [ ] New feature, functionality or library
- [x] Bug fix
- [ ] Code health or cleanup
- [ ] Major breaking change
- [ ] Documentation
- [ ] Other <!-- add details here if it a different type of change -->

## List of changes

- Updated LocalNet's config in manifests
- Updated Helm charts template

## Testing

- [ ] `make develop_test`; if any code changes were made
- [ ] `make test_e2e` on [k8s
LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md);
if any code changes were made
- [ ] `e2e-devnet-test` passes tests on
[DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd);
if any code was changed
- [ ] [Docker Compose
LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md);
if any major functionality was changed or introduced
- [x] [k8s
LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md);
if any infrastructure or configuration changes were made

## Required Checklist

- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added, or updated, [`godoc` format
comments](https://go.dev/blog/godoc) on touched members (see:
[tip.golang.org/doc/comment](https://tip.golang.org/doc/comment))
- [x] I have tested my changes using the available tooling

### If Applicable Checklist

- [ ] I have updated the corresponding README(s); local and/or global
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added, or updated,
[mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding
README(s)
- [ ] I have added, or updated, documentation and
[mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*`
if I updated `shared/*`README(s)
@Olshansk
Copy link
Member

@adshmh When do you think we'll pick up this work again?

@adshmh
Copy link
Contributor Author

adshmh commented Jul 27, 2023

@adshmh When do you think we'll pick up this work again?

Working on it: I will address any remaining ADD_IN_THIS_PR items in a couple of days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Prevent merging even with sufficient approvals large Pull request is large utility Utility specific changes waiting-for-review
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants