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

[RelayRequest] Don't Unmarshal Request Payloads #186

Closed
wants to merge 0 commits into from

Conversation

h5law
Copy link
Contributor

@h5law h5law commented Nov 14, 2023

Summary

Human Summary

  • replace request payloads with []byte and dont unmarshal them

AI Summary

Summary generated by Reviewpad on 14 Nov 23 22:53 UTC

This pull request introduces a feature that generalizes the parameters in the JSON RPC request to be either maps or lists. It modifies multiple files to implement this feature.

Issue

  • Fixes N/A

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
  • Verify Localnet manually: See the instructions [here](TODO: add link to instructions)

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

@h5law h5law added application Changes related to the Application actor supplier Changes related to the Supplier actor labels Nov 14, 2023
@h5law h5law added this to the Shannon TestNet milestone Nov 14, 2023
@h5law h5law self-assigned this Nov 14, 2023
@h5law h5law changed the base branch from main to relayer/cli November 14, 2023 22:53
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.

Asking a pretty big structural question before moving on.

@@ -13,6 +14,15 @@ import (
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

// InterimJSONRPCRequestPayload is a partial JSON RPC request payload that
// excludes the params field, which is unmarshaled sperately.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// excludes the params field, which is unmarshaled sperately.
// excludes the params field, which is unmarshaled separately.
// This is used because the proto object cannot be unmarshalled directly, so this is a
// temporary object to be used interim.

@@ -13,6 +14,15 @@ import (
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

// InterimJSONRPCRequestPayload is a partial JSON RPC request payload that
// excludes the params field, which is unmarshaled sperately.
type InterimJSONRPCRequestPayload struct {
Copy link
Member

Choose a reason for hiding this comment

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

Does the struct and its types need to be exposed publically?

}

// JSONRPCRequestPayloadParamsList contains the list of parameters for a JSON-RPC request.
// TODO_RESEARCH: Will this always be a string list? Or should we use a more generic type?
Copy link
Member

Choose a reason for hiding this comment

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

I thought about it and realized this could be a string of objects: [obj1, obj2, etc..].

Wdyt of just making prams an Any like you suggested in discord?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Olshansk I think an approach could be storing the payload as its bytes. And just passing these directly. The downside of this is what if we wanted to do compute units?

Answer: we interim unmarshal without the params as compute units should probably only depend on the method being called (params shouldn't affect the method as the method's "weighting" would factor in the types of params it receives) and assign the weighting that way.

The reason I am against using Any in the protobuf is that the protobuf Any isn't 1-1 correspondance with the go any ie we cannot unmarhsal any type into an Any an any needs to be an Any type in go which the unmarhsaling step would again require some interim step of unmarshaling without the params and then a longer type checking.

Overall I think us trying to proto-ify the payload is probably the wrong path. What do we need it to be a protobuf for? Why cant be just directly pass the payload from the request to the service? Personally I think making the payload a protobuf is not for us to deal with - as we dont do anything with it, unlike the other field of the request structure.

WDYT?

@h5law h5law closed this Nov 15, 2023
@h5law h5law force-pushed the feat/json_rpc_structure branch from 8c5ae31 to e58c848 Compare November 15, 2023 21:39
@h5law h5law changed the title [Proto] Enable both maps of params and lists of params in the JSONRPCRequestPayload [RelayRequest] Don't Unmarshal Request Payloads Nov 15, 2023
@h5law h5law deleted the feat/json_rpc_structure branch November 15, 2023 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
application Changes related to the Application actor supplier Changes related to the Supplier actor
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants