Skip to content
Draft
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
47 changes: 47 additions & 0 deletions .github/workflows/v0.4-bsc2bsc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: bsc2bsc@v0.4
on: [push, pull_request]

env:
CACHE_BIN_RELAYER_KEY: bin-relayer
CACHE_BIN_RELAYER_PATH: ./build/yrly
CACHE_DOCKER_BSC_KEY: docker-bsc
CACHE_DOCKER_BSC_DIR: /tmp/bsc

jobs:
eth2eth-test:
name: bsc2bsc-test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Wait for build to succeed
uses: lewagon/wait-on-check-action@v1.3.1
with:
ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha }}
check-regexp: '(relayer|bsc)-build'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 30
- name: Restore relayer binary cache
uses: actions/cache@v3
with:
path: ${{ env.CACHE_BIN_RELAYER_PATH }}
key: ${{ runner.os }}-${{ env.CACHE_BIN_RELAYER_KEY }}-${{ hashFiles('relayer/**', 'go.sum') }}
- name: Restore BSC docker image cache
uses: actions/cache@v3
with:
path: ${{ env.CACHE_DOCKER_BSC_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_DOCKER_BSC_KEY }}-${{ hashFiles('tests/chains/bsc/**', '!**/.git/**') }}
- name: Load BSC docker images
working-directory: ./tests/scripts
run: |
./load_docker_images $CACHE_DOCKER_BSC_DIR bsc-rpc:latest bsc-bootstrap:latest
- name: Run BSC chain
working-directory: ./tests/chains/bsc
run: |
make bootstrap
make network
make deploy-contract
- name: Run Test
working-directory: ./tests/cases/bsc2bsc
run: |
make init
make replace-test
23 changes: 23 additions & 0 deletions .github/workflows/v0.4-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:
CACHE_DOCKER_TENDERMINT_DIR: /tmp/tendermint
CACHE_DOCKER_ETHEREUM_KEY: docker-ethereum
CACHE_DOCKER_ETHEREUM_DIR: /tmp/ethereum
CACHE_DOCKER_BSC_KEY: docker-bsc
CACHE_DOCKER_BSC_DIR: /tmp/bsc

jobs:
relayer-build:
Expand Down Expand Up @@ -80,3 +82,24 @@ jobs:
working-directory: ./tests/scripts
run: |
./save_docker_images $CACHE_DOCKER_ETHEREUM_DIR ethereum-ganache0:latest ethereum-ganache1:latest

bsc-build:
name: bsc-build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-docker-bsc
with:
path: ${{ env.CACHE_DOCKER_BSC_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_DOCKER_BSC_KEY }}-${{ hashFiles('tests/chains/bsc/**', '!**/.git/**') }}
- name: Build docker images
if: steps.cache-docker-bsc.outputs.cache-hit != 'true'
working-directory: ./tests/chains/bsc
run: |
make docker-images
- name: Save docker images
if: steps.cache-docker-bsc.outputs.cache-hit != 'true'
working-directory: ./tests/scripts
run: |
./save_docker_images $CACHE_DOCKER_BSC_DIR bsc-rpc:latest bsc-bootstrap:latest
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ replace (
)

require (
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.9
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.10
github.com/hyperledger-labs/yui-relayer v0.4.20
)

Expand Down Expand Up @@ -202,3 +202,5 @@ require (
pgregory.net/rapid v0.5.5 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/datachainlab/ethereum-ibc-relay-chain => github.com/yoshidan/ethereum-ibc-relay-chain v0.0.0-20231225072216-f2357c7dc5a2
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,6 @@ github.com/cucumber/common/gherkin/go/v22 v22.0.0 h1:4K8NqptbvdOrjL9DEea6HFjSpbd
github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBhXeoFTJnSrgm9cT/Ts=
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.9 h1:xikiZ7IKhxvcAEVW9vZmGBlTIU8k+nIfqL/9Ki4l0S0=
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.9/go.mod h1:FDKiZNh2r8kz/KAXBG9tNDcoT6jyiUR1EfiE9W7Xjbc=
github.com/datachainlab/ibc-mock-client v0.3.2 h1:SxBkaiuHWQ+1L085m2L35Fku3am7I6YL6B7dwurtDOM=
github.com/datachainlab/ibc-mock-client v0.3.2/go.mod h1:FfqyF+VJKp8jlIG21lTNJJIp8RCaxSrx6vjhNkfwgBM=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -1118,6 +1116,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
github.com/yoshidan/ethereum-ibc-relay-chain v0.0.0-20231225072216-f2357c7dc5a2 h1:VPJa61QHjpG8GG5wnSqXXBEiz2E3XkaCrrFcX2tSNSc=
github.com/yoshidan/ethereum-ibc-relay-chain v0.0.0-20231225072216-f2357c7dc5a2/go.mod h1:z2LO59ewVXH0SFmTFMO3z+YRCfAGAJoZ19bvnCX+gJM=
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
Expand Down
2 changes: 1 addition & 1 deletion relayer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"log"

"github.com/datachainlab/ethereum-ibc-relay-chain/pkg/relay/ethereum"
ethereum "github.com/datachainlab/ethereum-ibc-relay-chain/pkg/relay/ethereum/module"
"github.com/datachainlab/ethereum-ibc-relay-chain/pkg/relay/ethereum/signers/hd"
tendermint "github.com/hyperledger-labs/yui-relayer/chains/tendermint/module"
"github.com/hyperledger-labs/yui-relayer/cmd"
Expand Down
1 change: 1 addition & 0 deletions tests/cases/bsc2bsc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
demo/.urelayer
10 changes: 10 additions & 0 deletions tests/cases/bsc2bsc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include ../../docker.mk

.PHONY: init
init:
./scripts/init-rly
./scripts/handshake

.PHONY: replace-test
replace-test:
./scripts/replace-tx
33 changes: 33 additions & 0 deletions tests/cases/bsc2bsc/configs/chains/ibc-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"chain": {
"@type": "/relayer.chains.ethereum.config.ChainConfig",
"chain_id": "ibc0",
"eth_chain_id": 9999,
"rpc_addr": "http://localhost:8945",
"signer": {
"@type": "/relayer.chains.ethereum.signers.hd.SignerConfig",
"mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"path": "m/44'/60'/0'/0/0"
},
"ibc_address": "0x727A5648832D2b317925CE043eA9b7fE04B4CD55",
"initial_send_checkpoint": 0,
"initial_recv_checkpoint": 0,
"enable_debug_trace": false,
"average_block_time_msec": 3000,
"max_retry_for_inclusion": 5,
"replaceConfig": {
"pendingDurationToReplace" : 10,
"checkInterval" : 3,
"gasPriceInc": "1000000000",
"maxGasPrice": "100000000000",
"gasTipCapInc": "1000000000",
"maxGasTipCap": "100000000000",
"gasFeeCapInc": "1000000000",
"maxGasFeeCap": "100000000000"
}
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 3
}
}
33 changes: 33 additions & 0 deletions tests/cases/bsc2bsc/configs/chains/ibc-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"chain": {
"@type": "/relayer.chains.ethereum.config.ChainConfig",
"chain_id": "ibc1",
"eth_chain_id": 9999,
"rpc_addr": "http://localhost:8845",
"signer": {
"@type": "/relayer.chains.ethereum.signers.hd.SignerConfig",
"mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"path": "m/44'/60'/0'/0/0"
},
"ibc_address": "0x727A5648832D2b317925CE043eA9b7fE04B4CD55",
"initial_send_checkpoint": 0,
"initial_recv_checkpoint": 0,
"enable_debug_trace": false,
"average_block_time_msec": 3000,
"max_retry_for_inclusion": 5,
"replaceConfig": {
"pendingDurationToReplace" : 1,
"checkInterval" : 3,
"gasPriceInc": "1000000000",
"maxGasPrice": "100000000000",
"gasTipCapInc": "1000000000",
"maxGasTipCap": "100000000000",
"gasFeeCapInc": "1000000000",
"maxGasFeeCap": "100000000000"
}
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 3
}
}
23 changes: 23 additions & 0 deletions tests/cases/bsc2bsc/configs/path.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"src": {
"chain-id": "ibc0",
"client-id": "mock-client-0",
"connection-id": "connection-0",
"channel-id": "channel-0",
"port-id": "transfer",
"order": "unordered",
"version": "ics20-1"
},
"dst": {
"chain-id": "ibc1",
"client-id": "mock-client-0",
"connection-id": "connection-0",
"channel-id": "channel-0",
"port-id": "transfer",
"order": "unordered",
"version": "ics20-1"
},
"strategy": {
"type": "naive"
}
}
Empty file.
14 changes: 14 additions & 0 deletions tests/cases/bsc2bsc/scripts/handshake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -eu

SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
source ${SCRIPT_DIR}/util/relayer-util

# handshake
set -x
$RLY tx clients $PATH_NAME
$RLY tx update-clients $PATH_NAME
$RLY tx connection $PATH_NAME
$RLY tx channel $PATH_NAME
set +x
16 changes: 16 additions & 0 deletions tests/cases/bsc2bsc/scripts/init-rly
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -eu

SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
source ${SCRIPT_DIR}/util/relayer-util

rm -rf ${RELAYER_CONF} &> /dev/null

sleep 10

${RLY} config init
${RLY} chains add-dir ${CONF_DIR}/chains/

# add a path between chain0 and chain1
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=${CONF_DIR}/path.json
29 changes: 29 additions & 0 deletions tests/cases/bsc2bsc/scripts/replace-tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -eu

SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
source ${SCRIPT_DIR}/util/relayer-util

docker exec bsc-bsc-validator1-1-1 geth attach /gethipc --exec "miner.stop()"

echo "update-clients (expect tx is pending)"
$RLY tx update-clients $PATH_NAME || true

echo "check tx is pending"
$RLY ethereum pending show $CHAINID_TWO | jq '.maxPriorityFeePerGas' | grep "0x12a05f200"

echo "replace transaction"
$RLY ethereum pending replace $CHAINID_TWO || true

echo "check gasTipCap changed"
$RLY ethereum pending show $CHAINID_TWO | jq '.maxPriorityFeePerGas' | grep "0x165a0bc00"

docker exec bsc-bsc-validator1-1-1 geth attach /gethipc --exec "miner.start()"

sleep 10

echo "check no tx in txpool"
$RLY ethereum pending show $CHAINID_TWO 2>&1 | grep "no pending transaction was found"


50 changes: 50 additions & 0 deletions tests/cases/bsc2bsc/scripts/util/color
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

C_RESET='\033[0m'
C_RED='\033[0;31m'
C_GREEN='\033[0;32m'
C_BLUE='\033[0;34m'
C_YELLOW='\033[1;33m'

# println echos string
function println() {
echo -e "$1"
}

# errorln echos i red color
function errorln() {
println "${C_RED}${1}${C_RESET}"
}

# successln echos in green color
function successln() {
println "${C_GREEN}${1}${C_RESET}"
}

# infoln echos in blue color
function infoln() {
println "${C_BLUE}${1}${C_RESET}"
}

# warnln echos in yellow color
function warnln() {
println "${C_YELLOW}${1}${C_RESET}"
}

# fatalln echos in red color and exits with fail status
function fatalln() {
errorln "$1"
exit 1
}

function verifyResult() {
if [ $1 -ne 0 ]; then
fatalln "$2"
fi
}

export -f errorln
export -f successln
export -f infoln
export -f warnln
export -f verifyResult
37 changes: 37 additions & 0 deletions tests/cases/bsc2bsc/scripts/util/relayer-util
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -eu

source ${SCRIPT_DIR}/util/color

CONF_DIR=${SCRIPT_DIR}/../configs
DEMO_DIR=${SCRIPT_DIR}/../demo
BIN_DIR=${SCRIPT_DIR}/../../../../build

RELAYER_CONF="${DEMO_DIR}/.urelayer"
RLY_BINARY=${BIN_DIR}/yrly
RLY="${RLY_BINARY} --home ${RELAYER_CONF}"
println "Loaded relayer command: $RLY"

CHAINID_ONE=ibc0
CHAINID_TWO=ibc1
RLYKEY=testkey
PATH_NAME=ibc01

RETRY_COUNT=5
RETRY_INTERVAL=1

waitRelay() {
label=$1
query_type=$2
filter=".$3 | length"
for i in `seq $RETRY_COUNT`
do
echo "[try:$i] waiting for ${label} finalization ..."
sleep $RETRY_INTERVAL
unrelayed=$(${RLY} query ${query_type} ${PATH_NAME} | jq "${filter}")
if [ $unrelayed -gt 0 ]; then
break
fi
done
}
2 changes: 1 addition & 1 deletion tests/cases/eth2eth/configs/chains/ibc-0.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"path": "m/44'/60'/0'/0/0"
},
"ibc_address": "0x9eBF3956EE45B2b9F1fC85FB8990ce6be52F47a6",
"ibc_address": "0x727A5648832D2b317925CE043eA9b7fE04B4CD55",
"initial_send_checkpoint": 1,
"initial_recv_checkpoint": 1,
"enable_debug_trace": true,
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/eth2eth/configs/chains/ibc-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"path": "m/44'/60'/0'/0/0"
},
"ibc_address": "0x9eBF3956EE45B2b9F1fC85FB8990ce6be52F47a6",
"ibc_address": "0x727A5648832D2b317925CE043eA9b7fE04B4CD55",
"initial_send_checkpoint": 1,
"initial_recv_checkpoint": 1,
"enable_debug_trace": true,
Expand Down
Loading