-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Proxy] feat: implement relayer proxy full workflow (#101)
* feat: add general proxy logic and server builder * fix: make var names and comments more consistent * feat: add relay verification and signature * fix: interface assignment * feat: implement relayer proxy full workflow * chore: improve code comments * chore: change native terms to proxied * chore: address change requests * chore: explain -32000 error code * chore: add log message on relaying success/failure * chore: Update AccountI/any unmarshaling comment Co-authored-by: Daniel Olshansky <[email protected]> * chore: update import paths to use GitHub organization name * chore: address change requests * chore: add TODO for test implementation * chore: Refactor relay request & response methods in RelayerProxy * chore: Address request changes * chore: comment about current proxy signing approach * Merge remote-tracking branch 'origin/main' into feat/relayer-proxy * chore: Revert relay request & response signing and verification interface --------- Co-authored-by: Daniel Olshansky <[email protected]>
- Loading branch information
Showing
12 changed files
with
399 additions
and
93 deletions.
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
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, | ||
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 was deleted.
Oops, something went wrong.
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.