Skip to content

Commit

Permalink
Merge branch 'main' of github.com:icon-project/ibc-relay into fix/log…
Browse files Browse the repository at this point in the history
…-rolling
  • Loading branch information
viveksharmapoudel committed Jul 17, 2023
2 parents 693267a + d63f79b commit c4e7e71
Show file tree
Hide file tree
Showing 19 changed files with 362 additions and 72 deletions.
1 change: 1 addition & 0 deletions .github/scripts/IBC-Integration
Submodule IBC-Integration added at 1f59cf
1 change: 1 addition & 0 deletions .github/scripts/archway
Submodule archway added at fd95e4
1 change: 1 addition & 0 deletions .github/scripts/gochain-btp
Submodule gochain-btp added at 4c7d22
1 change: 1 addition & 0 deletions .github/scripts/icon-ibc-setup
Submodule icon-ibc-setup added at ebf04b
112 changes: 112 additions & 0 deletions .github/scripts/start_relay.sh
Original file line number Diff line number Diff line change
@@ -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 $!

38 changes: 9 additions & 29 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/relay-codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
tags:
- '**'
branches:
- '**'
# branches:
# - '**'
pull_request:
branches:
- main
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/test-relay.yaml
Original file line number Diff line number Diff line change
@@ -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


20 changes: 20 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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"
54 changes: 33 additions & 21 deletions relayer/chains/archway/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -42,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 {
Expand Down Expand Up @@ -313,7 +316,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 {
Expand Down Expand Up @@ -451,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

Check warning on line 463 in relayer/chains/archway/provider.go

View check run for this annotation

Codecov / codecov/patch

relayer/chains/archway/provider.go#L459-L463

Added lines #L459 - L463 were not covered by tests
}

// 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)
Expand Down
Loading

0 comments on commit c4e7e71

Please sign in to comment.