-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Proxy] feat: implement relayer proxy full workflow #101
Merged
Merged
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
006eb19
feat: add general proxy logic and server builder
red-0ne 63f9467
fix: make var names and comments more consistent
red-0ne 8f899fb
feat: add relay verification and signature
red-0ne 69698c9
fix: interface assignment
red-0ne c81c3f6
feat: implement relayer proxy full workflow
red-0ne edbd628
chore: improve code comments
red-0ne 08e1915
chore: change native terms to proxied
red-0ne 4fd55e9
Merge branch 'feat/only-proxy-implementation' into feat/relayer-proxy
red-0ne 1b835aa
chore: address change requests
red-0ne 776e78c
chore: explain -32000 error code
red-0ne fbba106
chore: add log message on relaying success/failure
red-0ne 2e41656
chore: Update AccountI/any unmarshaling comment
red-0ne 4c6f7d9
Merge branch 'main' into feat/relayer-proxy
red-0ne b9dd8f3
Merge branch 'main' into feat/relayer-proxy
red-0ne b7fd6df
Merge remote-tracking branch 'origin/main' into feat/relayer-proxy
red-0ne 46066a1
chore: update import paths to use GitHub organization
red-0ne 920978d
Merge remote-tracking branch 'origin/main' into feat/relayer-proxy
red-0ne 5041f43
chore: address change requests
red-0ne 6ce1482
chore: add TODO for test implementation
red-0ne cae8969
chore: Refactor relay request & response methods in
red-0ne 75e88c7
chore: Address request changes
red-0ne 67273dd
chore: comment about current proxy signing approach
red-0ne 3c94180
Merge remote-tracking branch 'origin/main' into feat/relayer-proxy
red-0ne 6e30e58
chore: Revert relay request & response signing and
red-0ne 230b74c
Merge remote-tracking branch 'origin/main' into feat/relayer-proxy
red-0ne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package proxy | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
|
||
"github.com/pokt-network/poktroll/x/service/types" | ||
) | ||
|
||
// replyWithError builds a JSONRPCResponseError from the passed in error and writes it to the writer. | ||
// TODO_TECHDEBT: This method should be aware of the request id and use it in the response by having | ||
// the caller pass it along with the error if available. | ||
// TODO_TECHDEBT: This method should be aware of the nature of the error to use the appropriate JSONRPC | ||
// Code, Message and Data. Possibly by augmenting the passed in error with the adequate information. | ||
func (j *jsonRPCServer) replyWithError(writer http.ResponseWriter, err error) { | ||
relayResponse := &types.RelayResponse{ | ||
Payload: &types.RelayResponse_JsonRpcPayload{ | ||
JsonRpcPayload: &types.JSONRPCResponsePayload{ | ||
Id: make([]byte, 0), | ||
Jsonrpc: "2.0", | ||
Error: &types.JSONRPCResponseError{ | ||
// Using conventional error code indicating internal server error. | ||
Code: -32000, | ||
red-0ne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Message: err.Error(), | ||
Data: nil, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
relayResponseBz, err := relayResponse.Marshal() | ||
if err != nil { | ||
log.Printf("ERROR: failed marshaling relay response: %s", err) | ||
return | ||
} | ||
|
||
if _, err = writer.Write(relayResponseBz); err != nil { | ||
log.Printf("ERROR: failed writing relay response: %s", err) | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's kind of confusing that:
I believe it should be one of:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... I'll revert to passing the pointer without returning and mutate it inside the function as I can't clearly foresee the impact of changing the whole workflow to not use pointers. We'll keep that question to when we start implementing the middleware capabilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @bryanchriswhite