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

Workaround for successful 202s on REST chains #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Olshansk
Copy link
Contributor

@Olshansk Olshansk commented Aug 21, 2024

Customer support request:

Screenshot 2024-08-21 at 11 02 23 AM

New business logic:

  1. For most JSONRPC chains (result is present)
    • result present -> 200 (success)
    • result not present -> check the status (if available)
  2. For REST chains (no result field)
    • result not present && json is valid -> 200
    • result not present && json is invalid -> extract from response

@Olshansk Olshansk self-assigned this Aug 21, 2024
@Olshansk Olshansk requested a review from adshmh August 21, 2024 15:01
@Olshansk Olshansk added bug Something isn't working enhancement New feature or request labels Aug 21, 2024
@Olshansk Olshansk requested a review from fredteumer August 21, 2024 15:03
@Olshansk Olshansk marked this pull request as ready for review August 21, 2024 15:04
@@ -942,15 +946,24 @@ func parseRelaySuccesfulOutput(bodyBytes []byte, requestStatusCode int) (*RelayO
return &output, err
}

// Check if there's explicitly a result field, if there's on mark it as success, otherwise check what's the potential status.
// for REST chain that doesn't return result in any of the call will be defaulted to 202 in extractStatusFromResponse
isValidJson := json.Valid([]byte(output.Response))

Choose a reason for hiding this comment

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

My only question is an open one for @adshmh : does this impact the Portal logic for handling Pocket Mainnet/Archival and if so, how much of an impact is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 to any insight you have.

I tried to be as backwards compatible as possible with the if/else below, but it only uses logic and not any sort of real testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe there are cases where Pocket returns a non-json response, but those may have the text result in them (we need to verify this)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adshmh so in terms of next step with this PR, which is it?

  1. Merge it in -> Update portal-middleware -> deploy -> test in prod
    OR
  2. Do some sort of investigation for different request/response types?
    OR
  3. 👍 that this is backwards compatible enough and go with option (1) above

I'm opting for option (3) but lmk if you have a better idea for (2).

Please approve/request changes to the PR as needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that option [3] makes the most sense here.
To verify backward compatibility of the change we need to a) review the API docs and b) run a few tests against a Morse node.

Other than potential compatibility issues, the code changes look OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

review the API docs

This is correct: https://docs.pokt.network/reference/api-definition

Here is the source of truth: https://github.com/pokt-network/pocket-core/blob/staging/doc/specs/rpc-spec.yaml

run a few tests against a Morse node.

Sounds good.

  1. Where are the instructions to do this?
  2. Is this something you can do?
  3. Happy to dive into it if (1) does not exist or you don't have the capacity given (2).

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I don't think this has been done/documented before.
  2. Yes: I can build a doc and run the tests.

@Olshansk
Copy link
Contributor Author

Note to team: AFTER (if?) this PR is merged, we'll also need to:

  1. Update the dependency in portal-middleware - cc @adshmh
  2. Manage the deployment - cc @Gustavobelfort

cc @fredteumer

Copy link

@fredteumer fredteumer left a comment

Choose a reason for hiding this comment

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

i prefer this approach since the middleware should just be a passthrough and shouldn't manipulate the return status of a message. ( i believe we should maintain this principle ).

With this change to pocket-go i think this is the best happy medium where the protocol can continue to do its thing but then the SDK can handle the translation. Lmk if this works @adshmh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants