From c9c7504f29f6119f58d86bd0e158361789d21b8e Mon Sep 17 00:00:00 2001 From: DeepakBomjan <44976635+DeepakBomjan@users.noreply.github.com> Date: Mon, 17 Jul 2023 11:54:37 +0545 Subject: [PATCH 1/2] ci: add workflow to test deployment of relay locally (#92) * ci: add workflow to test deployment of relay locally * temp: hotfix for nil pointer dereference * fix: seq number issue in archway module * chore: add separate relay start script * ci: add node repos as git submodules * fix: channel mock --------- Co-authored-by: viveksharmapoudel --- .github/scripts/IBC-Integration | 1 + .github/scripts/archway | 1 + .github/scripts/gochain-btp | 1 + .github/scripts/icon-ibc-setup | 1 + .github/scripts/start_relay.sh | 112 ++++++++++++++++++++++++++ .github/workflows/docker-publish.yaml | 38 +++------ .github/workflows/relay-codecov.yml | 4 +- .github/workflows/test-relay.yaml | 89 ++++++++++++++++++++ .gitmodules | 20 +++++ docker-compose.yaml | 15 ++++ relayer/chains/archway/provider.go | 6 +- relayer/chains/archway/tx.go | 47 +++++++++-- 12 files changed, 295 insertions(+), 40 deletions(-) create mode 160000 .github/scripts/IBC-Integration create mode 160000 .github/scripts/archway create mode 160000 .github/scripts/gochain-btp create mode 160000 .github/scripts/icon-ibc-setup create mode 100755 .github/scripts/start_relay.sh create mode 100644 .github/workflows/test-relay.yaml create mode 100644 .gitmodules create mode 100644 docker-compose.yaml diff --git a/.github/scripts/IBC-Integration b/.github/scripts/IBC-Integration new file mode 160000 index 000000000..1f59cf9a9 --- /dev/null +++ b/.github/scripts/IBC-Integration @@ -0,0 +1 @@ +Subproject commit 1f59cf9a9411075a5825e74ef229dfdc37ee4c2a diff --git a/.github/scripts/archway b/.github/scripts/archway new file mode 160000 index 000000000..fd95e42dd --- /dev/null +++ b/.github/scripts/archway @@ -0,0 +1 @@ +Subproject commit fd95e42dd02d96feab9d3c02c12558962ab9cf95 diff --git a/.github/scripts/gochain-btp b/.github/scripts/gochain-btp new file mode 160000 index 000000000..4c7d229c4 --- /dev/null +++ b/.github/scripts/gochain-btp @@ -0,0 +1 @@ +Subproject commit 4c7d229c4ec366d04d1c70b4dd09d70b901f06ef diff --git a/.github/scripts/icon-ibc-setup b/.github/scripts/icon-ibc-setup new file mode 160000 index 000000000..ebf04b0bd --- /dev/null +++ b/.github/scripts/icon-ibc-setup @@ -0,0 +1 @@ +Subproject commit ebf04b0bd44aeaed2a815d2e4b26a2efbb17d210 diff --git a/.github/scripts/start_relay.sh b/.github/scripts/start_relay.sh new file mode 100755 index 000000000..d8be09b0d --- /dev/null +++ b/.github/scripts/start_relay.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +SCRIPT=$(readlink -f $0) +SUBMODULE_DIR=$(dirname $SCRIPT) + +GPG_FINGERPRINT="C787AB518A0C08B7AE1E1ADA2809A1A84E32159A" + +ARCHWAY_CONTAINER='archway-node-1' + +cd $SUBMODULE_DIR + +# Correct path +sed -i "s|^CONTRACTS_DIR=.*|CONTRACTS_DIR=$PWD/IBC-Integration|" ./icon-ibc-setup/consts.sh +sed -i "s|^ICON_WALLET=.*|ICON_WALLET=$PWD/gochain-btp/data/godWallet.json|" ./icon-ibc-setup/consts.sh +sed -i "s|^ARCHWAY_WALLET=.*|ARCHWAY_WALLET=default|" ./icon-ibc-setup/consts.sh + +# Import fd account +pass init $GPG_FINGERPRINT + +echo "### Create default wallet" + +wallet=$(archwayd keys add default --keyring-backend test | awk -F\: '/address/ {print $2}' | tr -d '[:space:]') +echo $wallet +archwayd keys list + +echo "==> Starting icon node ..." +cd $SUBMODULE_DIR/gochain-btp +make ibc-ready + +echo "==> Starting archway node ..." +cd ${SUBMODULE_DIR}/archway + +sed -i '/^archwayd add-genesis-account.*/a archwayd add-genesis-account "'"$wallet"'" 1000000000stake --keyring-backend=test' contrib/localnet/localnet.sh +sed -i 's/latest/v0.4.0/' docker-compose.yaml +docker compose -f docker-compose.yaml up -d +sleep 60 + +echo "### Check archwayd start script content" +cat contrib/localnet/localnet.sh +docker ps + +echo "### Check archwayd genesis file" +docker exec $ARCHWAY_CONTAINER cat /root/.archway/config/genesis.json + +echo "### Check archwayd keys list on node" +docker exec $ARCHWAY_CONTAINER archwayd keys list + +echo "### Check archwayd keys list on local" +archwayd keys list --keyring-backend os + +echo "### Get fd wallet address" +fdwallet=$(docker exec $ARCHWAY_CONTAINER archwayd keys list --keyring-backend test | awk -F\: '/address/ {print $2}' | tr -d '[:space:]') + +echo "default: $wallet" +echo "fd: $fdwallet" + +echo "### Checking docker logs" +docker logs $ARCHWAY_CONTAINER +echo "### Query balance of account" +echo "default:" +archwayd query bank balances $wallet +echo "fd:" +docker exec $ARCHWAY_CONTAINER archwayd query bank balances $fdwallet + +cd $SUBMODULE_DIR/icon-ibc-setup + +sed -i 's/ARCHWAY_NETWORK=localnet/ARCHWAY_NETWORK=docker/' consts.sh +mkdir -p ~/.relayer/config +echo "==> Setting up icon ..." +make icon +echo "==> Setting up archway ..." +make archway +echo "### Updating config ..." +make config + +cat ~/.relayer/config/config.yaml + +echo -e "\nCopy default key to relayer keyring ======" +mkdir -p /home/runner/.relayer/keys/localnet/keyring-test +cp ~/.archway/keyring-test/default.info ~/.relayer/keys/localnet/keyring-test/default.info + + +echo "### all archwayd keys:" +archwayd keys list +echo "### keyring: os" +archwayd keys list --keyring-backend os +echo "### keyring: test" +archwayd keys list --keyring-backend test + +echo "### Checking keys inside archway docker node:" +docker exec $ARCHWAY_CONTAINER archwayd keys list --keyring-backend os +docker exec $ARCHWAY_CONTAINER archwayd keys list --keyring-backend test + + +echo "+++++++++++++++++++++" +echo "==> Starting link..." +rly tx link icon-archway --client-tp=10000m --src-port mock --dst-port mock -d +# Enable when debug is required +# rly tx link icon-archway --client-tp=10000m --src-port mock --dst-port mock --order=ordered -d +# for txhash in $(cat log.txt | grep 'Submitted transaction" provider_type=archway chain_id=localnet txHash=' | awk -F\= '{print $NF}') +# do + # echo -e "\n+++ Checking $txhash ...\n" + # archwayd query tx $txhash +# done +echo +echo +docker ps +echo "### Checking relay config" +cat ~/.relayer/config/config.yaml +echo "==> Starting relayer..." +rly start icon-archway & sleep 60s; echo "* Stopping relay ..."; kill $! + diff --git a/.github/workflows/docker-publish.yaml b/.github/workflows/docker-publish.yaml index 6c6cd8164..a220d3147 100644 --- a/.github/workflows/docker-publish.yaml +++ b/.github/workflows/docker-publish.yaml @@ -5,19 +5,12 @@ on: tags: - '**' branches: - - '**' - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + - 'main' + - '82-run-relay-node-locally-on-pr-merge-to-main' jobs: build-and-push-image: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - name: Checkout repository uses: actions/checkout@v2 @@ -28,27 +21,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Log in to the Container registry - uses: docker/login-action@v1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v2 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push Docker image - uses: docker/build-push-action@v2.7.0 + uses: docker/build-push-action@v3 with: - context: . - platforms: linux/amd64,linux/arm64 - file: Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + repository: ${{ secrets.DOCKERHUB_USERNAME }}/relay-node + tag: latest diff --git a/.github/workflows/relay-codecov.yml b/.github/workflows/relay-codecov.yml index 970344ee3..15f4d4ba8 100644 --- a/.github/workflows/relay-codecov.yml +++ b/.github/workflows/relay-codecov.yml @@ -4,8 +4,8 @@ on: push: tags: - '**' - branches: - - '**' + # branches: + # - '**' pull_request: branches: - main diff --git a/.github/workflows/test-relay.yaml b/.github/workflows/test-relay.yaml new file mode 100644 index 000000000..4c2189c04 --- /dev/null +++ b/.github/workflows/test-relay.yaml @@ -0,0 +1,89 @@ +name: Deploy Relayer Locally + +on: + push: + branches: + - "main" + +jobs: + relay-local-deployment: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Pull & update submodules recursively + run: | + git submodule update --init --recursive + git submodule update --recursive --remote + + # Install and setup go + - name: Set up Go 1.19 + uses: actions/setup-go@v2 + with: + go-version: 1.19 + + # setup gopath + - name: Set PATH + run: | + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + shell: bash + + # Install rust toolchain + - name: Install rust stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.69.0 + target: wasm32-unknown-unknown + override: true + profile: minimal + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + + # Build relay + - name: Build relayer + run: make install + + # Install goloop + - name: Install goloop + run: go install github.com/icon-project/goloop/cmd/goloop@latest + + # Build archwayd + - name: Build archwayd + working-directory: .github/scripts/archway + run: | + echo $PWD + echo $GITHUB_WORKSPACE + make install + + # Build comsmwasm + - name: Compile WASM + working-directory: .github/scripts/IBC-Integration + run: | + rustup component add rustfmt --toolchain 1.69.0-x86_64-unknown-linux-gnu + rustup component add clippy --toolchain 1.69.0-x86_64-unknown-linux-gnu + bash ./optimize_build.sh + + - name: Build javascore + working-directory: .github/scripts/IBC-Integration/contracts/javascore + run: | + ./gradlew clean build + ./gradlew optimizedJar + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + fingerprint: "C787AB518A0C08B7AE1E1ADA2809A1A84E32159A" + trust_level: 5 + + + - name: start relay + working-directory: .github/scripts + run: bash ./start_relay.sh + + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..e7cb4e321 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,20 @@ +[submodule "contracts/javascore/gochain-btp"] + path = contracts/javascore/gochain-btp + url = https://github.com/izyak/gochain-btp.git + +[submodule "contracts/cosmwasm-vm/archway"] + path = contracts/cosmwasm-vm/archway + url = https://github.com/archway-network/archway.git + +[submodule ".github/scripts/IBC-Integration"] + path = .github/scripts/IBC-Integration + url = https://github.com/icon-project/IBC-Integration.git +[submodule ".github/scripts/archway"] + path = .github/scripts/archway + url = https://github.com/archway-network/archway.git +[submodule ".github/scripts/gochain-btp"] + path = .github/scripts/gochain-btp + url = https://github.com/izyak/gochain-btp.git +[submodule ".github/scripts/icon-ibc-setup"] + path = .github/scripts/icon-ibc-setup + url = https://github.com/izyak/icon-ibc-setup.git diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..5f4dadcaa --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,15 @@ +version: "3.7" +services: + ibc-relayer: + container_name: relayer01 + image: docker.io/18cr314y/relay-node:latest + environment: + - PATH_NAME="icon-archway" + entrypoint: + - sh + - /opt/start-relay.sh + volumes: + - ~/.relayer:/home/relayer/.relayer:rw + - ./scripts:/opt + ports: + - "5183:5183" diff --git a/relayer/chains/archway/provider.go b/relayer/chains/archway/provider.go index c4faf750a..4bad698b2 100644 --- a/relayer/chains/archway/provider.go +++ b/relayer/chains/archway/provider.go @@ -17,6 +17,8 @@ import ( itm "github.com/icon-project/IBC-Integration/libraries/go/common/tendermint" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + prov "github.com/cometbft/cometbft/light/provider/http" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -313,7 +315,9 @@ func (ap *ArchwayProvider) Init(ctx context.Context) error { WithTxConfig(app.MakeEncodingConfig().TxConfig). WithSkipConfirmation(true). WithBroadcastMode("sync"). - WithCodec(ap.Cdc.Marshaler) + WithCodec(ap.Cdc.Marshaler). + WithInterfaceRegistry(ap.Cdc.InterfaceRegistry). + WithAccountRetriever(authtypes.AccountRetriever{}) addr, _ := ap.GetKeyAddress() if addr != nil { diff --git a/relayer/chains/archway/tx.go b/relayer/chains/archway/tx.go index ab354b5d2..2893d31fc 100644 --- a/relayer/chains/archway/tx.go +++ b/relayer/chains/archway/tx.go @@ -679,6 +679,12 @@ func (ap *ArchwayProvider) SendMessages(ctx context.Context, msgs []provider.Rel ) callback := func(rtr *provider.RelayerTxResponse, err error) { + callbackErr = err + + if err != nil { + wg.Done() + return + } for i, e := range rtr.Events { if startsWithWasm(e.EventType) { @@ -686,7 +692,6 @@ func (ap *ArchwayProvider) SendMessages(ctx context.Context, msgs []provider.Rel } } rlyResp = rtr - callbackErr = err wg.Done() } @@ -751,21 +756,27 @@ func (ap *ArchwayProvider) SendMessagesToMempool( if err != nil { return err } - ap.updateNextAccountSequence(sequence + 1) if msg.Type() == MethodUpdateClient { - err := ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, true) - if err != nil { - return fmt.Errorf("Archway: failed during updateClient ") + if err := ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, true); err != nil { + if strings.Contains(err.Error(), sdkerrors.ErrWrongSequence.Error()) { + ap.handleAccountSequenceMismatchError(err) + } + return fmt.Errorf("Archway: failed during updateClient %v", err) } + ap.updateNextAccountSequence(sequence + 1) continue } - ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, false) + if err := ap.BroadcastTx(cliCtx, txBytes, []provider.RelayerMessage{msg}, asyncCtx, defaultBroadcastWaitTimeout, asyncCallback, false); err != nil { + if strings.Contains(err.Error(), sdkerrors.ErrWrongSequence.Error()) { + ap.handleAccountSequenceMismatchError(err) + } + } + ap.updateNextAccountSequence(sequence + 1) } - //uncomment for saving msg + //TODO: comment this on production SaveMsgToFile(ArchwayDebugMessagePath, msgs) - return nil } @@ -1254,6 +1265,26 @@ func (cc *ArchwayProvider) QueryABCI(ctx context.Context, req abci.RequestQuery) return result.Response, nil } +func (cc *ArchwayProvider) handleAccountSequenceMismatchError(err error) { + + clientCtx := cc.ClientContext() + fmt.Println("client context is ", clientCtx.GetFromAddress()) + + _, seq, err := cc.ClientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, clientCtx.GetFromAddress()) + + // sequences := numRegex.FindAllString(err.Error(), -1) + // if len(sequences) != 2 { + // return + // } + // nextSeq, err := strconv.ParseUint(sequences[0], 10, 64) + if err != nil { + return + } + + fmt.Printf("the next sequence is %d \n", seq) + cc.nextAccountSeq = seq +} + func sdkErrorToGRPCError(resp abci.ResponseQuery) error { switch resp.Code { case sdkerrors.ErrInvalidRequest.ABCICode(): From d63f79b9b7bad7ce631d75baf8192eff6b2622a4 Mon Sep 17 00:00:00 2001 From: viveksharmapoudel Date: Mon, 17 Jul 2023 11:55:04 +0545 Subject: [PATCH 2/2] fix: first block try after issue (#106) * fix: first block try after issue * fix: implement block retry in channel and packet as well --------- Co-authored-by: izyak <76203436+izyak@users.noreply.github.com> --- relayer/chains/archway/provider.go | 48 ++++++++++++++++----------- relayer/chains/cosmos/provider.go | 4 +++ relayer/chains/icon/provider.go | 32 +++++++++++------- relayer/chains/icon/tx.go | 2 +- relayer/chains/penumbra/provider.go | 4 +++ relayer/processor/path_end_runtime.go | 9 +++++ relayer/processor/path_processor.go | 2 +- relayer/provider/provider.go | 1 + 8 files changed, 68 insertions(+), 34 deletions(-) diff --git a/relayer/chains/archway/provider.go b/relayer/chains/archway/provider.go index 4bad698b2..ade4acca1 100644 --- a/relayer/chains/archway/provider.go +++ b/relayer/chains/archway/provider.go @@ -44,26 +44,27 @@ var ( ) type ArchwayProviderConfig struct { - KeyDirectory string `json:"key-directory" yaml:"key-directory"` - Key string `json:"key" yaml:"key"` - ChainName string `json:"-" yaml:"-"` - ChainID string `json:"chain-id" yaml:"chain-id"` - RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"` - AccountPrefix string `json:"account-prefix" yaml:"account-prefix"` - KeyringBackend string `json:"keyring-backend" yaml:"keyring-backend"` - GasAdjustment float64 `json:"gas-adjustment" yaml:"gas-adjustment"` - GasPrices string `json:"gas-prices" yaml:"gas-prices"` - MinGasAmount uint64 `json:"min-gas-amount" yaml:"min-gas-amount"` - Debug bool `json:"debug" yaml:"debug"` - Timeout string `json:"timeout" yaml:"timeout"` - BlockTimeout string `json:"block-timeout" yaml:"block-timeout"` - OutputFormat string `json:"output-format" yaml:"output-format"` - SignModeStr string `json:"sign-mode" yaml:"sign-mode"` - ExtraCodecs []string `json:"extra-codecs" yaml:"extra-codecs"` - Modules []module.AppModuleBasic `json:"-" yaml:"-"` - Slip44 int `json:"coin-type" yaml:"coin-type"` - Broadcast provider.BroadcastMode `json:"broadcast-mode" yaml:"broadcast-mode"` - IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"` + KeyDirectory string `json:"key-directory" yaml:"key-directory"` + Key string `json:"key" yaml:"key"` + ChainName string `json:"-" yaml:"-"` + ChainID string `json:"chain-id" yaml:"chain-id"` + RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"` + AccountPrefix string `json:"account-prefix" yaml:"account-prefix"` + KeyringBackend string `json:"keyring-backend" yaml:"keyring-backend"` + GasAdjustment float64 `json:"gas-adjustment" yaml:"gas-adjustment"` + GasPrices string `json:"gas-prices" yaml:"gas-prices"` + MinGasAmount uint64 `json:"min-gas-amount" yaml:"min-gas-amount"` + Debug bool `json:"debug" yaml:"debug"` + Timeout string `json:"timeout" yaml:"timeout"` + BlockTimeout string `json:"block-timeout" yaml:"block-timeout"` + OutputFormat string `json:"output-format" yaml:"output-format"` + SignModeStr string `json:"sign-mode" yaml:"sign-mode"` + ExtraCodecs []string `json:"extra-codecs" yaml:"extra-codecs"` + Modules []module.AppModuleBasic `json:"-" yaml:"-"` + Slip44 int `json:"coin-type" yaml:"coin-type"` + Broadcast provider.BroadcastMode `json:"broadcast-mode" yaml:"broadcast-mode"` + IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"` + FirstRetryBlockAfter uint64 `json:"first-retry-block-after" yaml:"first-retry-block-after"` } type ArchwayIBCHeader struct { @@ -455,6 +456,13 @@ func (app *ArchwayProvider) MsgRegisterCounterpartyPayee(portID, channelID, rela return nil, fmt.Errorf("Not implemented for Icon") } +func (cc *ArchwayProvider) FirstRetryBlockAfter() uint64 { + if cc.PCfg.FirstRetryBlockAfter != 0 { + return cc.PCfg.FirstRetryBlockAfter + } + return 3 +} + // keysDir returns a string representing the path on the local filesystem where the keystore will be initialized. func keysDir(home, chainID string) string { return path.Join(home, "keys", chainID) diff --git a/relayer/chains/cosmos/provider.go b/relayer/chains/cosmos/provider.go index 4fbea4d0e..dd459cdb6 100644 --- a/relayer/chains/cosmos/provider.go +++ b/relayer/chains/cosmos/provider.go @@ -310,6 +310,10 @@ func (cc *CosmosProvider) legacyEncodedEvents(log *zap.Logger, version string) b return semver.Compare("v"+version, cometEncodingThreshold) < 0 } +func (cc *CosmosProvider) FirstRetryBlockAfter() uint64 { + return 1 +} + // keysDir returns a string representing the path on the local filesystem where the keystore will be initialized. func keysDir(home, chainID string) string { return path.Join(home, "keys", chainID) diff --git a/relayer/chains/icon/provider.go b/relayer/chains/icon/provider.go index 9b42c1031..6e51bdf42 100644 --- a/relayer/chains/icon/provider.go +++ b/relayer/chains/icon/provider.go @@ -48,18 +48,19 @@ var ( ) type IconProviderConfig struct { - Key string `json:"key" yaml:"key"` - ChainName string `json:"-" yaml:"-"` - ChainID string `json:"chain-id" yaml:"chain-id"` - RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"` - Timeout string `json:"timeout" yaml:"timeout"` - Keystore string `json:"keystore" yaml:"keystore"` - Password string `json:"password" yaml:"password"` - ICONNetworkID int64 `json:"icon-network-id" yaml:"icon-network-id" default:"3"` - BTPNetworkID int64 `json:"btp-network-id" yaml:"btp-network-id"` - BTPNetworkTypeID int64 `json:"btp-network-type-id" yaml:"btp-network-type-id"` - BTPHeight int64 `json:"start-btp-height" yaml:"start-btp-height"` - IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"` + Key string `json:"key" yaml:"key"` + ChainName string `json:"-" yaml:"-"` + ChainID string `json:"chain-id" yaml:"chain-id"` + RPCAddr string `json:"rpc-addr" yaml:"rpc-addr"` + Timeout string `json:"timeout" yaml:"timeout"` + Keystore string `json:"keystore" yaml:"keystore"` + Password string `json:"password" yaml:"password"` + ICONNetworkID int64 `json:"icon-network-id" yaml:"icon-network-id" default:"3"` + BTPNetworkID int64 `json:"btp-network-id" yaml:"btp-network-id"` + BTPNetworkTypeID int64 `json:"btp-network-type-id" yaml:"btp-network-type-id"` + BTPHeight int64 `json:"start-btp-height" yaml:"start-btp-height"` + IbcHandlerAddress string `json:"ibc-handler-address" yaml:"ibc-handler-address"` + FirstRetryBlockAfter uint64 `json:"first-retry-block-after" yaml:"first-retry-block-after"` } func (pp *IconProviderConfig) Validate() error { @@ -567,3 +568,10 @@ func (icp *IconProvider) GetCurrentBtpNetworkStartHeight() (int64, error) { func (icp *IconProvider) MsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayeeAddr string) (provider.RelayerMessage, error) { return nil, fmt.Errorf("Not implemented for Icon") } + +func (cc *IconProvider) FirstRetryBlockAfter() uint64 { + if cc.PCfg.FirstRetryBlockAfter != 0 { + return cc.PCfg.FirstRetryBlockAfter + } + return 8 +} diff --git a/relayer/chains/icon/tx.go b/relayer/chains/icon/tx.go index abea8b860..1ec832e2e 100644 --- a/relayer/chains/icon/tx.go +++ b/relayer/chains/icon/tx.go @@ -770,7 +770,7 @@ func (icp *IconProvider) SendIconTransaction( if err != nil { return err } - icp.log.Debug("Submitted Icon Transaction", zap.String("chain_id", icp.ChainId()), zap.String("method", m.Method), zap.String("tx_hash", string(txParam.TxHash))) + icp.log.Info("Submitted Transaction", zap.String("chain_id", icp.ChainId()), zap.String("method", m.Method), zap.String("tx_hash", string(txParam.TxHash))) // If update fails, the subsequent txn will fail, result of update not being fetched concurrently switch m.Method { diff --git a/relayer/chains/penumbra/provider.go b/relayer/chains/penumbra/provider.go index 4079f4d87..023e668be 100644 --- a/relayer/chains/penumbra/provider.go +++ b/relayer/chains/penumbra/provider.go @@ -331,6 +331,10 @@ func (cc *PenumbraProvider) legacyEncodedEvents(log *zap.Logger, version string) return semver.Compare("v"+version, cometEncodingThreshold) < 0 } +func (cc *PenumbraProvider) FirstRetryBlockAfter() uint64 { + return 1 +} + // keysDir returns a string representing the path on the local filesystem where the keystore will be initialized. func keysDir(home, chainID string) string { return path.Join(home, "keys", chainID) diff --git a/relayer/processor/path_end_runtime.go b/relayer/processor/path_end_runtime.go index df5acf5da..f11145851 100644 --- a/relayer/processor/path_end_runtime.go +++ b/relayer/processor/path_end_runtime.go @@ -492,6 +492,9 @@ func (pathEnd *pathEndRuntime) shouldSendPacketMessage(message packetIBCMessage, // this message was sent less than blocksToRetrySendAfter ago, do not attempt to send again yet. return false } + if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.FirstRetryBlockAfter() { + return false + } } else { if blocksSinceLastProcessed < blocksToRetryAssemblyAfter { // this message was sent less than blocksToRetryAssemblyAfter ago, do not attempt assembly again yet. @@ -577,6 +580,9 @@ func (pathEnd *pathEndRuntime) shouldSendConnectionMessage(message connectionIBC // this message was sent less than blocksToRetrySendAfter ago, do not attempt to send again yet. return false } + if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.FirstRetryBlockAfter() { + return false + } } else { if blocksSinceLastProcessed < blocksToRetryAssemblyAfter { // this message was sent less than blocksToRetryAssemblyAfter ago, do not attempt assembly again yet. @@ -654,6 +660,9 @@ func (pathEnd *pathEndRuntime) shouldSendChannelMessage(message channelIBCMessag // this message was sent less than blocksToRetrySendAfter ago, do not attempt to send again yet. return false } + if inProgress.retryCount <= 1 && blocksSinceLastProcessed < pathEnd.chainProvider.FirstRetryBlockAfter() { + return false + } } else { if blocksSinceLastProcessed < blocksToRetryAssemblyAfter { // this message was sent less than blocksToRetryAssemblyAfter ago, do not attempt assembly again yet. diff --git a/relayer/processor/path_processor.go b/relayer/processor/path_processor.go index 2b295d4ce..5289f5a23 100644 --- a/relayer/processor/path_processor.go +++ b/relayer/processor/path_processor.go @@ -37,7 +37,7 @@ const ( // If the message was assembled successfully, but sending the message failed, // how many blocks should pass before retrying. - blocksToRetrySendAfter = 5 + blocksToRetrySendAfter = 1 // How many times to retry sending a message before giving up on it. maxMessageSendRetries = 5 diff --git a/relayer/provider/provider.go b/relayer/provider/provider.go index 5facc342e..e16ecdfaf 100644 --- a/relayer/provider/provider.go +++ b/relayer/provider/provider.go @@ -423,6 +423,7 @@ type QueryProvider interface { QueryTx(ctx context.Context, hashHex string) (*RelayerTxResponse, error) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*RelayerTxResponse, error) QueryLatestHeight(ctx context.Context) (int64, error) + FirstRetryBlockAfter() uint64 // QueryIBCHeader returns the IBC compatible block header at a specific height. QueryIBCHeader(ctx context.Context, h int64) (IBCHeader, error)