Skip to content

Commit

Permalink
fix: put adequate proxied services endpoitns, prevent session republi…
Browse files Browse the repository at this point in the history
…shing
  • Loading branch information
red-0ne committed Nov 13, 2023
1 parent ff4997a commit ac54c24
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,7 @@ localnet_config.yaml
# Relase artifacts produced by `ignite chain build --release`
release

# SMT KVStore files
smt

go.work.sum
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ genesis:
- endpoints:
- configs: []
rpc_type: JSON_RPC
url: http://anvil:8547
url: http://localhost:8548
service:
id: anvil
name: ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/relayer/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func supplyRelayerProxy(
cmd *cobra.Command,
) (depinject.Config, error) {
// TODO_TECHDEBT: this should be populated from some relayerProxy config.
anvilURL, err := url.Parse("ws://anvil:8547/")
anvilURL, err := url.Parse("http://localhost:8547/")
if err != nil {
return nil, err
}
Expand Down
11 changes: 2 additions & 9 deletions pkg/relayer/proxy/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,16 @@ func (jsrv *jsonRPCServer) serveHTTP(ctx context.Context, request *http.Request)

// Build the request to be sent to the native service by substituting
// the destination URL's host with the native service's listen address.
// TODO_HACK: Currently, the native service's listen address is hardcoded to localhost:8547.
// This should be changed to the actual listen address of the native service.
// However, the native service 'ws://anvil:8547' causes errors
log.Printf("DEBUG: Building relay request to native service %s...", jsrv.proxiedServiceEndpoint.String())
destinationURL, err := url.Parse(request.URL.String())
if err != nil {
return nil, err
}
destinationURL.Host = "localhost:8547"
destinationURL.Scheme = "http" // this is not captured and needs to be set
log.Printf("DEBUG: Sending relay request to native service %s...", destinationURL.String())

relayHTTPRequest := &http.Request{
Method: request.Method,
Header: request.Header,
URL: destinationURL,
Host: destinationURL.Host,
URL: &jsrv.proxiedServiceEndpoint,
Host: jsrv.proxiedServiceEndpoint.Host,
Body: requestBodyReader,
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/relayer/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ func (rs *relayerSessionsManager) mapBlockToSessionsToClaim(
// Iterate over the sessionsTrees map to get the ones that end at a block height
// lower than the current block height.
for endBlockHeight, sessionsTreesEndingAtBlockHeight := range rs.sessionsTrees {
if endBlockHeight < block.Height() {
// TODO: We need this to be == instead of <= because we don't want to keep sending
// the same session while waiting the next step. This does not address the case
// where the block client misses the target block which should be handled by the
// retry mechanism.
if endBlockHeight == block.Height() {
// Iterate over the sessionsTrees that end at this block height (or
// less) and add them to the list of sessionTrees to be published.
for _, sessionTree := range sessionsTreesEndingAtBlockHeight {
Expand Down

0 comments on commit ac54c24

Please sign in to comment.