Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/hashicorp/g…
Browse files Browse the repository at this point in the history
…o-getter-1.7.5
  • Loading branch information
jtieri committed Sep 12, 2024
2 parents ac9852e + 83d9c36 commit 029d052
Show file tree
Hide file tree
Showing 49 changed files with 9,684 additions and 3,422 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

# upload resulting binaries
- name: upload binaries
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: rly
path: ./build/rly
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ COPY --from=busybox-min --chown=100:1000 /home/relayer /home/relayer

WORKDIR /home/relayer
USER relayer

ENTRYPOINT ["rly", "start"]
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ldflags := $(strip $(ldflags))

BUILD_FLAGS := -ldflags '$(ldflags)'

#? build: Build the rly binary
build: go.sum
ifeq ($(OS),Windows_NT)
@echo "building rly binary..."
Expand All @@ -34,70 +35,89 @@ else
@go build $(BUILD_FLAGS) -o build/rly main.go
endif

#? build-zip: Build rly binaries for all supported operating systems
build-zip: go.sum
@echo "building rly binaries for windows, mac and linux"
@GOOS=linux GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/linux-amd64-rly main.go
@GOOS=darwin GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/darwin-amd64-rly main.go
@GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/windows-amd64-rly.exe main.go
@tar -czvf release.tar.gz ./build

#? install: Install rly binary to GOBIN
install: go.sum
@echo "installing rly binary..."
@go build -mod=readonly $(BUILD_FLAGS) -o $(GOBIN)/rly main.go

#? build-gaia-docker: Build Docker image for Gaia
build-gaia-docker:
docker build -t cosmos/gaia:$(GAIA_VERSION) --build-arg VERSION=$(GAIA_VERSION) -f ./docker/gaiad/Dockerfile .

#? build-akash-docker: Build Docker image for Akash
build-akash-docker:
docker build -t ovrclk/akash:$(AKASH_VERSION) --build-arg VERSION=$(AKASH_VERSION) -f ./docker/akash/Dockerfile .

#? build-osmosis-docker: Build Docker image for Osmosis
build-osmosis-docker:
docker build -t osmosis-labs/osmosis:$(OSMOSIS_VERSION) --build-arg VERSION=$(OSMOSIS_VERSION) -f ./docker/osmosis/Dockerfile .

###############################################################################
# Tests / CI
###############################################################################

#? test: Run all unit tests
test:
@go test -mod=readonly -race ./...

#? interchaintest: Run interchain TestRelayerInProcess tests
interchaintest:
cd interchaintest && go test -race -v -run TestRelayerInProcess .

#? interchaintest-docker: Run interchain TestRelayerDocker tests
interchaintest-docker:
cd interchaintest && go test -race -v -run TestRelayerDocker .

#? interchaintest-docker-events: Run interchain TestRelayerDockerEventProcessor tests
interchaintest-docker-events:
cd interchaintest && go test -race -v -run TestRelayerDockerEventProcessor .

#? interchaintest-docker-legacy: Run interchain TestRelayerDockerLegacyProcessor tests
interchaintest-docker-legacy:
cd interchaintest && go test -race -v -run TestRelayerDockerLegacyProcessor .

#? interchaintest-events: Run interchain TestRelayerEventProcessor tests
interchaintest-events:
cd interchaintest && go test -race -v -run TestRelayerEventProcessor .

#? interchaintest-legacy: Run interchain TestRelayerLegacyProcessor tests
interchaintest-legacy:
cd interchaintest && go test -race -v -run TestRelayerLegacyProcessor .

#? interchaintest-multiple: Run interchain TestRelayerMultiplePathsSingleProcess tests
interchaintest-multiple:
cd interchaintest && go test -race -v -run TestRelayerMultiplePathsSingleProcess .

#? interchaintest-misbehaviour: Run interchain TestRelayerMisbehaviourDetection tests
interchaintest-misbehaviour:
cd interchaintest && go test -race -v -run TestRelayerMisbehaviourDetection .

#? interchaintest-fee-middleware: Run interchain TestRelayerFeeMiddleware tests
interchaintest-fee-middleware:
cd interchaintest && go test -race -v -run TestRelayerFeeMiddleware .

#? interchaintest-fee-grant: Run interchain TestRelayerFeeGrant tests
interchaintest-fee-grant:
cd interchaintest && go test -race -v -run TestRelayerFeeGrant .

#? interchaintest-scenario: Run interchain TestScenario tests
interchaintest-scenario: ## Scenario tests are suitable for simple networks of 1 validator and no full nodes. They test specific functionality.
cd interchaintest && go test -timeout 30m -race -v -run TestScenario ./...

#? coverage: Generate and view test coverage report
coverage:
@echo "viewing test coverage..."
@go tool cover --html=coverage.out

#? lint: Run linters and gofmt
lint:
@golangci-lint run
@find . -name '*.go' -type f -not -path "*.git*" | xargs gofmt -d -s
Expand All @@ -110,10 +130,12 @@ lint:
CHAIN_CODE := ./chain-code
GAIA_REPO := $(CHAIN_CODE)/gaia

#? get-gaia: Download the Gaia repository
get-gaia:
@mkdir -p $(CHAIN_CODE)/
@git clone --branch $(GAIA_VERSION) --depth=1 https://github.com/cosmos/gaia.git $(GAIA_REPO)

#? build-gaia: Build and install Gaia to GOBIN
build-gaia:
@[ -d $(GAIA_REPO) ] || { echo "Repository for gaia does not exist at $(GAIA_REPO). Try running 'make get-gaia'..." ; exit 1; }
@cd $(GAIA_REPO) && \
Expand All @@ -129,14 +151,17 @@ SYSROOT_DIR ?= sysroots
SYSROOT_ARCHIVE ?= sysroots.tar.bz2

.PHONY: sysroot-pack
#? sysroot-pack: Pack the sysroot directory into an archive
sysroot-pack:
@tar cf - $(SYSROOT_DIR) -P | pv -s $[$(du -sk $(SYSROOT_DIR) | awk '{print $1}') * 1024] | pbzip2 > $(SYSROOT_ARCHIVE)

.PHONY: sysroot-unpack
#? sysroot-unpack: Unpack the sysroot archive
sysroot-unpack:
@pv $(SYSROOT_ARCHIVE) | pbzip2 -cd | tar -xf -

.PHONY: release-dry-run
#? release-dry-run: Perform a dry run of the release process using Docker
release-dry-run:
@docker run \
--rm \
Expand All @@ -149,6 +174,7 @@ release-dry-run:
--rm-dist --skip-validate --skip-publish

.PHONY: release
#? release: Run goreleaser to build and release cross-platform rly binary version
release:
@if [ ! -f ".release-env" ]; then \
echo "\033[91m.release-env is required for release\033[0m";\
Expand All @@ -169,14 +195,24 @@ protoVer=0.11.2
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

#? proto-all: Run proto-format proto-lint proto-gen
proto-all: proto-format proto-lint proto-gen

#? proto-gen: Generate Protobuf files
proto-gen:
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh

#? proto-format: Format Protobuf files using clang-format
proto-format:
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;

#? proto-lint: Lint Protobuf files
proto-lint:
@$(protoImage) buf lint --error-format=json

#? help: Get more info on make commands
help: Makefile
@echo " Available commands:"
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'
.PHONY: help
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ Additional information on how IBC works can be found [here](https://ibc.cosmos.n
[[TROUBLESHOOTING](docs/troubleshooting.md)]
---

## Production deployment recomendations

- Make sure the debug server is disabled in production.

## Security Notice

If you would like to report a security bug related to the relayer repo,
Expand Down
12 changes: 12 additions & 0 deletions cmd/appstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,15 @@ func (a *appState) useRpcAddr(chainName string, rpcAddr string) error {
return nil
})
}

func (a *appState) useBackupRpcAddrs(chainName string, rpcAddrs []string) error {
_, exists := a.config.Chains[chainName]
if !exists {
return fmt.Errorf("chain %s not found in config", chainName)
}

return a.performConfigLockingOperation(context.Background(), func() error {
a.config.Chains[chainName].ChainProvider.SetBackupRpcAddrs(rpcAddrs)
return nil
})
}
42 changes: 37 additions & 5 deletions cmd/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ func chainsCmd(a *appState) *cobra.Command {
chainsAddDirCmd(a),
cmdChainsConfigure(a),
cmdChainsUseRpcAddr(a),
cmdChainsUseBackupRpcAddr(a),
)

return cmd
}

func cmdChainsUseRpcAddr(a *appState) *cobra.Command {
cmd := &cobra.Command{
Use: "set-rpc-addr chain_name valid_rpc_url",
Use: "set-rpc-addr chain_name valid_rpc_url",
Aliases: []string{"rpc"},
Short: "Sets chain's rpc address",
Short: "Sets chain's rpc address",
Args: withUsage(cobra.ExactArgs(2)),
Example: strings.TrimSpace(fmt.Sprintf(`
$ %s chains set-rpc-addr ibc-0 https://abc.xyz.com:443
Expand All @@ -69,6 +70,37 @@ $ %s ch set-rpc-addr ibc-0 https://abc.xyz.com:443`, appName, appName)),
return cmd
}

func cmdChainsUseBackupRpcAddr(a *appState) *cobra.Command {
cmd := &cobra.Command{
Use: "set-backup-rpc-addrs chain_name comma_separated_valid_rpc_urls",
Aliases: []string{"set-backup-rpcs"},
Short: "Sets chain's backup rpc addresses",
Args: withUsage(cobra.ExactArgs(2)),
Example: strings.TrimSpace(fmt.Sprintf(`
$ %s chains set-backup-rpc-addr ibc-0 https://abc.xyz.com:443,https://123.456.com:443
$ %s ch set-backup-rpc-addr ibc-0 https://abc.xyz.com:443,https://123.456.com:443`, appName, appName)),
RunE: func(cmd *cobra.Command, args []string) error {
chainName := args[0]
rpc_addresses := args[1]

// split rpc_addresses by ','
rpc_addresses_list := strings.Split(rpc_addresses, ",")

// loop through and ensure valid
for _, rpc_address := range rpc_addresses_list {
rpc_address := rpc_address
if !isValidURL(rpc_address) {
return invalidRpcAddr(rpc_address)
}
}

return a.useBackupRpcAddrs(chainName, rpc_addresses_list)
},
}

return cmd
}

func chainsAddrCmd(a *appState) *cobra.Command {
cmd := &cobra.Command{
Use: "address chain_name",
Expand Down Expand Up @@ -206,7 +238,7 @@ func chainsRegistryList(a *appState) *cobra.Command {

switch {
case yml && jsn:
return fmt.Errorf("can't pass both --json and --yaml, must pick one")
return errors.New("can't pass both --json and --yaml, must pick one")
case yml:
out, err := yaml.Marshal(chains)
if err != nil {
Expand Down Expand Up @@ -259,7 +291,7 @@ $ %s ch l`, appName, appName)),

switch {
case yml && jsn:
return fmt.Errorf("can't pass both --json and --yaml, must pick one")
return errors.New("can't pass both --json and --yaml, must pick one")
case yml:
out, err := yaml.Marshal(configs)
if err != nil {
Expand Down Expand Up @@ -326,7 +358,7 @@ func chainsAddCmd(a *appState) *cobra.Command {
}

if ok := a.config; ok == nil {
return fmt.Errorf("config not initialized, consider running `rly config init`")
return errors.New("config not initialized, consider running `rly config init`")
}

return a.performConfigLockingOperation(cmd.Context(), func() error {
Expand Down
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ $ %s cfg list`, appName, defaultHome, appName)),
}
switch {
case yml && jsn:
return fmt.Errorf("can't pass both --json and --yaml, must pick one")
return errors.New("can't pass both --json and --yaml, must pick one")
case jsn:
out, err := json.Marshal(a.config.Wrapped())
if err != nil {
Expand Down Expand Up @@ -513,7 +513,7 @@ func newDefaultGlobalConfig(memo string) GlobalConfig {
func (c *Config) AddChain(chain *relayer.Chain) (err error) {
chainId := chain.ChainProvider.ChainId()
if chainId == "" {
return fmt.Errorf("chain ID cannot be empty")
return errors.New("chain ID cannot be empty")
}
chn, err := c.Chains.Get(chainId)
if chn != nil || err == nil {
Expand Down
11 changes: 11 additions & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
flagDstPort = "dst-port"
flagOrder = "order"
flagVersion = "version"
flagEnableDebugServer = "enable-debug-server"
flagDebugAddr = "debug-addr"
flagOverwriteConfig = "overwrite"
flagLimit = "limit"
Expand Down Expand Up @@ -429,6 +430,16 @@ func debugServerFlags(v *viper.Viper, cmd *cobra.Command) *cobra.Command {
panic(err)
}

cmd.Flags().Bool(
flagEnableDebugServer,
false,
"enables debug server. By default, the debug server is disabled due to security concerns.",
)

if err := v.BindPFlag(flagEnableDebugServer, cmd.Flags().Lookup(flagEnableDebugServer)); err != nil {
panic(err)
}

return cmd
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ $ %s pth l`, appName, appName, appName)),
yml, _ := cmd.Flags().GetBool(flagYAML)
switch {
case yml && jsn:
return fmt.Errorf("can't pass both --json and --yaml, must pick one")
return errors.New("can't pass both --json and --yaml, must pick one")
case yml:
out, err := yaml.Marshal(a.config.Paths)
if err != nil {
Expand Down Expand Up @@ -148,7 +148,7 @@ $ %s pth s path-name`, appName, appName, appName)),
pathWithStatus := p.QueryPathStatus(cmd.Context(), chains[p.Src.ChainID], chains[p.Dst.ChainID])
switch {
case yml && jsn:
return fmt.Errorf("can't pass both --json and --yaml, must pick one")
return errors.New("can't pass both --json and --yaml, must pick one")
case yml:
out, err := yaml.Marshal(pathWithStatus)
if err != nil {
Expand Down Expand Up @@ -348,7 +348,7 @@ $ %s paths update demo-path --src-connection-id connection-02 --dst-connection-i
}

if !actionTaken {
return fmt.Errorf("at least one flag must be provided")
return errors.New("at least one flag must be provided")
}

return nil
Expand Down
8 changes: 7 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ $ %s start demo-path2 --max-tx-size 10`, appName, appName, appName, appName)),
debugAddr = debugAddrFlag
}

if debugAddr == "" {
flagEnableDebugServer, err := cmd.Flags().GetBool(flagEnableDebugServer)
if err != nil {
return err
}

if flagEnableDebugServer == false || debugAddr == "" {
a.log.Info("Skipping debug server due to empty debug address flag")
} else {
a.log.Warn("SECURITY WARNING! Debug server is enabled. It should only be used for non-production deployments.")
ln, err := net.Listen("tcp", debugAddr)
if err != nil {
a.log.Error(
Expand Down
2 changes: 1 addition & 1 deletion cmd/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ func ensureKeysExist(chains map[string]*relayer.Chain) error {
return nil
}

// MsgRegisterCounterpartyPayee registers the counterparty_payee
// registerCounterpartyCmd registers the counterparty_payee
func registerCounterpartyCmd(a *appState) *cobra.Command {
cmd := &cobra.Command{
Use: "register-counterparty chain_name channel_id port_id relay_addr counterparty_payee",
Expand Down
Loading

0 comments on commit 029d052

Please sign in to comment.