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

refactor state based relaying (fixes update client bug on retries) #435

Merged
merged 15 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Release Relayer"
name: "(WARNING: ALPHA SOFTWARE)"

on:
push:
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,10 @@ build-wasmd:
delete-chains:
@echo "Removing the ./chain-code/ directory..."
@rm -rf ./chain-code

check-swagger:
which swagger || (GO111MODULE=off go get -u github.com/go-swagger/go-swagger/cmd/swagger)

update-swagger-docs: check-swagger
swagger generate spec -o ./docs/swagger-ui/swagger.yaml

6 changes: 5 additions & 1 deletion cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,15 @@ func getAPICmd() *cobra.Command {
// Data for this should be stored in the ServicesManager struct
r.HandleFunc("/listen/{path}/{strategy}/{name}", PostRelayerListenHandler(sm)).Methods("POST")

fs := http.FileServer(http.Dir("./docs/swagger-ui"))
r.PathPrefix("/").Handler(fs)

fmt.Println("listening on", config.Global.APIListenPort)

if err := http.ListenAndServe(config.Global.APIListenPort, r); err != nil {
return err
}

fmt.Println("listening on", config.Global.APIListenPort)
return nil
},
}
Expand Down
11 changes: 9 additions & 2 deletions cmd/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,10 @@ type addChainRequest struct {
GasAdjustment string `json:"gas-adjustment"`
GasPrices string `json:"gas-prices"`
TrustingPeriod string `json:"trusting-period"`
FilePath string `json:"file"`
URL string `json:"url"`
// required: false
FilePath string `json:"file"`
// required: false
URL string `json:"url"`
}

// PostChainHandler handles the route
Expand Down Expand Up @@ -678,6 +680,11 @@ func PutChainHandler(w http.ResponseWriter, r *http.Request) {
// DeleteChainHandler handles the route
func DeleteChainHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
_, err := config.Chains.Get(vars["name"])
if err != nil {
helpers.WriteErrorResponse(http.StatusBadRequest, err, w)
return
}
if err := overWriteConfig(config.DeleteChain(vars["name"])); err != nil {
helpers.WriteErrorResponse(http.StatusInternalServerError, err, w)
return
Expand Down
12 changes: 8 additions & 4 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ func newDefaultGlobalConfig() GlobalConfig {

// AddChain adds an additional chain to the config
func (c *Config) AddChain(chain *relayer.Chain) (err error) {
if chain.ChainID == "" {
return fmt.Errorf("chain ID cannot be empty")
}
chn, err := c.Chains.Get(chain.ChainID)
if chn == nil || err == nil {
return fmt.Errorf("chain with ID %s already exists in config", chain.ChainID)
Expand Down Expand Up @@ -564,15 +567,16 @@ func (c *Config) ValidatePathEnd(pe *relayer.PathEnd) error {
return err
}

chain, err := c.Chains.Get(pe.ChainID)
if err != nil {
return err
}

// if the identifiers are empty, don't do any validation
if pe.ClientID == "" && pe.ConnectionID == "" && pe.ChannelID == "" {
return nil
}

chain, err := c.Chains.Get(pe.ChainID)
if err != nil {
return err
}
// NOTE: this is just to do validation, the path
// is not written to the config file
if err = chain.SetPath(pe); err != nil {
Expand Down
Loading