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

Use gRPC client connection #257

Closed
wants to merge 25 commits into from
Closed

Use gRPC client connection #257

wants to merge 25 commits into from

Conversation

red-0ne
Copy link
Contributor

@red-0ne red-0ne commented Dec 11, 2023

Summary

Human Summary

  • Add gRPC connection FlagGRPC and FlagGRPCInsecure to AppGateServer and RelayMiner cmd.go to make cosmosClient.Context build a gRPC client.
  • Change AppGateServer config files to accept
    • query_node_grpc_url to be used by QueryClients
    • query_node_rpc_url to be used by BlockClient and EventsQueryClient
    • Adapt its config reader and tests
  • Change RelayMiner config files to accept
    • query_node_grpc_url for QueryClients usage
    • tx_node_grpc_url for transactions usage
    • query_node_rpc_url for BlockClient and EventsQueryClient
    • Adapt its config reader and tests
  • Adapt deps/config/supplier.go to handle these changes

Note: e2e tests for this change need changes from helm-charts repo to enable gRPC connections

AI Summary

Summary generated by Reviewpad on 21 Dec 23 01:11 UTC

This pull request modifies multiple files in the codebase. Here is a summary of the changes:

  1. values-relayminer.yaml:

    • Replaced query_node_url and network_node_url properties with query_node_rpc_url, query_node_grpc_url, and tx_node_grpc_url.
  2. relayminer_config.yaml:

    • Added query_node_rpc_url, query_node_grpc_url, and tx_node_grpc_url properties for Pocket node URLs.
    • Removed network_node_url property.
    • Updated the value of query_node_url property to tcp://poktroll-sequencer:36657.
    • Removed duplicate smt_store_path property.
    • Removed proxied_service_endpoints section.
    • Removed svc1 endpoint from the proxied_service_endpoints section.
  3. RelayMinerConfig structure and its related functionality:

    • Renamed QueryNodeUrl field to QueryNodeRPCUrl.
    • Added new fields QueryNodeGRPCUrl and TxNodeGRPCUrl.
    • Changed ProxiedServiceEndpoints field type from map[string]string to map[string]*url.URL.
    • Added error handling logic for empty or invalid field values.
  4. appgate_configs_reader.go:

    • Added new fields QueryNodeRPCUrl and QueryNodeGRPCUrl of type string to the YAMLAppGateServerConfig struct.
    • Changed the order of fields in the YAMLAppGateServerConfig struct.
    • Added new fields QueryNodeRPCUrl and QueryNodeGRPCUrl of type *url.URL to the AppGateServerConfig struct.
    • Changed the order of fields in the AppGateServerConfig struct.
    • Updated the ParseAppGateServerConfigs function to handle the newly added fields.
    • Added new validation checks for the SigningKey, ListeningEndpoint, and QueryNodeGRPCUrl fields.
    • Removed the QueryNodeUrl field from the AppGateServerConfig struct.
  5. Changes to error variables in errors.go:

    • Renamed ErrRelayMinerConfigInvalidQueryNodeUrl to ErrRelayMinerConfigInvalidQueryNodeGRPCUrl.
    • Renamed ErrRelayMinerConfigInvalidNetworkNodeUrl to ErrRelayMinerConfigInvalidTxNodeGRPCUrl.
    • Renamed ErrRelayMinerConfigInvalidSmtStorePath to ErrRelayMinerConfigInvalidQueryNodeRPCUrl.
    • Added a new error variable ErrRelayMinerConfigInvalidQueryNodeRPCUrl.
    • Added ErrRelayMinerConfigEmpty error.
  6. Changes to error variables in errors.go within the pkg/appgateserver/config directory:

    • Added ErrAppGateConfigInvalidQueryNodeGRPCUrl error for an invalid query node gRPC URL in the AppGateServer config.
    • Added ErrAppGateConfigInvalidQueryNodeRPCUrl error for an invalid query node RPC URL in the AppGateServer config.
    • Added ErrAppGateConfigEmpty error for an empty AppGateServer config.
  7. Summary of overall file diff:

    • Updated the Pocket node URL that exposes CometBFT JSON-RPC API.
    • Added a new field for the Pocket node URL that exposes the Cosmos gRPC service for querying purposes.
    • Changed the signing key for relays.
    • Updated the value for the self_signing field.
    • Removed the query_node_url field.
    • No other changes in the file.
  8. values-appgateserver.yaml:

    • Replaced query_node_url with query_node_rpc_url.
    • Added query_node_grpc_url.
  9. cmd.go:

    • Added a new variable flagAppGateConfig to store the AppGate config filepath.
    • Added two new variables flagNodeRPCURL and flagNodeGRPCURL to store the Cosmos node RPC URL and GRPC URL.
    • Removed the flagCosmosNodeURL variable.
    • Added a new function setupAppGateServerDependencies to override certain config values based on command-line flags.
    • Changed the parameters for various functions to match the new variable names.
  10. Changes to appgate_configs_reader_test.go:

    • Added test cases to validate AppGateServer configurations.
    • Updated test case structures and expected values to reflect new fields.
    • Added new error types for specific validation errors.
  11. Changes to cmd.go:

    • Added a new variable flagRelayMinerConfig for the relay miner config filepath.
    • Added new variables flagNodeRPCURL and flagNodeGRPCURL for the Cosmos node RPC URL and GRPC URL.
    • Removed the flagCosmosNodeURL variable.
    • Added comments to explain the purpose and usage of the new variables.
    • Updated the RelayerCmd function to include the new flag variable assignments.
    • Updated the setupRelayerDependencies function to handle the new flag variable values.
    • Updated function calls to config functions with the new flag variable values.
  12. Changes to pkg/appgateserver/config/depinject.go:

    • Output of each function has been changed to include a required dependency called grpc.ClientConn.
  13. Changes to supplierquerier.go:

    • Changed the NewSupplierQuerier function to include a required dependency called grpc.ClientConn.
  14. Changes to dependencies in go.mod:

    • Removed and added dependencies.

Let me know if you need any further assistance with this code review.

Type of change

Select one or more:

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Documentation
  • Other (specify)

Testing

  • Run all unit tests: make go_develop_and_test
  • Run E2E tests locally: make test_e2e
  • **Run E2E tests on DevNet: Add the devnet-test-e2e` label to the PR. This is VERY expensive, o only do it after all the reviews are complete.

Sanity Checklist

  • I have tested my changes using the available tooling
  • I have performed a self-review of my own code
  • I have commented my code, updated documentation and left TODOs throughout the codebase

@red-0ne red-0ne added off-chain Off-chain business logic code health Cleans up some code labels Dec 11, 2023
@red-0ne red-0ne added this to the Shannon TestNet milestone Dec 11, 2023
@red-0ne red-0ne self-assigned this Dec 11, 2023
@Olshansk
Copy link
Member

Discussed offline. Going to wait for this PR to be split per the discussion here: pokt-network/helm-charts#15 (comment)

Copy link
Contributor

@h5law h5law left a comment

Choose a reason for hiding this comment

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

Overall great PR, love to see this is a possibility great discovery! Mostly some spelling errors, overall looks good. Let's see how it goes once the helm charts are updated

pkg/appgateserver/cmd/cmd.go Outdated Show resolved Hide resolved
pkg/appgateserver/cmd/cmd.go Outdated Show resolved Hide resolved
pkg/appgateserver/cmd/cmd.go Outdated Show resolved Hide resolved
pkg/appgateserver/cmd/cmd.go Outdated Show resolved Hide resolved
pkg/appgateserver/config/appgate_configs_reader_test.go Outdated Show resolved Hide resolved
pkg/relayer/cmd/cmd.go Outdated Show resolved Hide resolved
pkg/relayer/config/relayminer_configs_reader_test.go Outdated Show resolved Hide resolved
pkg/relayer/config/relayminer_configs_reader_test.go Outdated Show resolved Hide resolved
pkg/relayer/config/relayminer_configs_reader_test.go Outdated Show resolved Hide resolved
pkg/sdk/deps_builder.go Outdated Show resolved Hide resolved
@red-0ne red-0ne changed the base branch from main to feat/sdk-grpc-client December 12, 2023 15:50
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 @red-0ne! 🙌

I had a few suggestions and questions but otherwise, this is looking really good, thanks for the improvements. 🦾

@red-0ne red-0ne changed the base branch from feat/sdk-grpc-client to main December 13, 2023 22:07
@red-0ne
Copy link
Contributor Author

red-0ne commented Dec 13, 2023

Thanks for the review @bryanchriswhite, having a stricter assertion on the test errors helped spotting a missing case

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.

Preemptively approving; I had a couple questions/assumptions, and a few NITs but otherwise let's 🚢!

Copy link
Contributor

@h5law h5law left a comment

Choose a reason for hiding this comment

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

Left one comment, after Bryan's comments are addressed I think this is good to go! 🔥

localnet/poktrolld/config/appgate_server_config.yaml Outdated Show resolved Hide resolved
pkg/appgateserver/cmd/cmd.go Outdated Show resolved Hide resolved
pkg/deps/config/suppliers.go Outdated Show resolved Hide resolved
pkg/deps/config/suppliers.go Show resolved Hide resolved
localnet/poktrolld/config/relayminer_config.yaml Outdated Show resolved Hide resolved
pkg/relayer/cmd/cmd.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.

@red-0ne Left a couple last-minute comments so PTAL before merging but otherwise approving!

@red-0ne
Copy link
Contributor Author

red-0ne commented Jan 4, 2024

Closing this one as it's already handled by #284

@red-0ne red-0ne closed this Jan 4, 2024
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 off-chain Off-chain business logic
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants