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

Add tm2eth #18

Merged
merged 12 commits into from
Nov 8, 2023
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
50 changes: 50 additions & 0 deletions .github/workflows/v0.4-tm2eth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: [email protected]
on: [push, pull_request]

env:
CACHE_BIN_RELAYER_KEY: bin-relayer
CACHE_BIN_RELAYER_PATH: ./build/yrly
CACHE_DOCKER_TENDERMINT_KEY: docker-tendermint
CACHE_DOCKER_TENDERMINT_DIR: /tmp/tendermint
CACHE_DOCKER_ETHEREUM_KEY: docker-ethereum
CACHE_DOCKER_ETHEREUM_DIR: /tmp/ethereum

jobs:
tm2eth-test:
name: tm2eth-test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Wait for build to succeed
uses: lewagon/[email protected]
with:
ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.sha }}
check-regexp: '(relayer|tendermint)-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 Tendermint docker image cache
uses: actions/cache@v3
with:
path: ${{ env.CACHE_DOCKER_TENDERMINT_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_DOCKER_TENDERMINT_KEY }}-${{ hashFiles('tests/chains/tendermint/**', '!**/.git/**') }}
- name: Restore Ethereum docker image cache
uses: actions/cache@v3
with:
path: ${{ env.CACHE_DOCKER_ETHEREUM_DIR }}
key: ${{ runner.os }}-${{ env.CACHE_DOCKER_ETHEREUM_KEY }}-${{ hashFiles('tests/chains/ethereum/**', '!**/.git/**') }}
- name: Load Tendermint docker images
working-directory: ./tests/scripts
run: |
./load_docker_images $CACHE_DOCKER_TENDERMINT_DIR tendermint-chain0:latest
siburu marked this conversation as resolved.
Show resolved Hide resolved
./load_docker_images $CACHE_DOCKER_ETHEREUM_DIR ethereum-ganache0:latest
- name: Run Test
working-directory: ./tests/cases/tm2eth
run: |
make network
make test
make network-down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ replace (
)

require (
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.3
github.com/hyperledger-labs/yui-relayer v0.4.7
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.7
github.com/hyperledger-labs/yui-relayer v0.4.17
)

require (
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ 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.3 h1:cib07hGm41YyssO3oz38BiHTX6K5iquo0INZ9yBS9hU=
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.3/go.mod h1:Rbn+hsaEaYz7154ckk3blm5df9T0mMccWK26id6JcJs=
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.7 h1:8se6ilNleijA+kO0yQe+nWyaBoGdTQHA9Qs/zvL9FAM=
github.com/datachainlab/ethereum-ibc-relay-chain v0.2.7/go.mod h1:Y+N8eThA6jBz6TrwwhliDDRxhd6UwT3M3gMLu2YvbNA=
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 @@ -740,8 +740,8 @@ github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXM
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
github.com/hyperledger-labs/yui-relayer v0.4.7 h1:cAzaptjIIskhST+fLBihmGp7l9UFZQoKknyAq+2GDao=
github.com/hyperledger-labs/yui-relayer v0.4.7/go.mod h1:1+JWE6Z1NML9dp54NTDUwPtqV9IrqO0+eS9FmC79J1Q=
github.com/hyperledger-labs/yui-relayer v0.4.17 h1:cjXYvfkTFiJEpXLtaMPQ7Q6Kd3vFvwQ0FAZ3JncoEz0=
github.com/hyperledger-labs/yui-relayer v0.4.17/go.mod h1:Hdc/ERCPDhbipri45/U6+/3kDH7EttIWGdql+Rd3tZg=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
Expand Down
12 changes: 10 additions & 2 deletions tests/cases/docker-compose-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ networks:

services:
# Tendermint
tendermint-chain0:
tendermint-chain0: &tendermint-chain0
container_name: tendermint-chain0
image: tendermint-chain0:${TAG}
ports:
Expand All @@ -21,7 +21,7 @@ services:
retries: 5
networks:
- *network-common
tendermint-chain1:
tendermint-chain1: &tendermint-chain1
container_name: tendermint-chain1
image: tendermint-chain1:${TAG}
ports:
Expand All @@ -36,6 +36,14 @@ services:
retries: 5
networks:
- *network-common
tendermint-chain0-mock:
<<: *tendermint-chain0
environment:
USE_MOCK_CLIENT: 1
tendermint-chain1-mock:
<<: *tendermint-chain1
environment:
USE_MOCK_CLIENT: 1

# Ethereum
ethereum-ganache0:
Expand Down
7 changes: 5 additions & 2 deletions tests/cases/eth2eth/configs/chains/ibc-0.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
"rpc_addr": "http://localhost:8645",
"hdw_mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"hdw_path": "m/44'/60'/0'/0/0",
"ibc_address": "0x702E40245797c5a2108A566b3CE2Bf14Bc6aF841",
"ibc_address": "0x9eBF3956EE45B2b9F1fC85FB8990ce6be52F47a6",
"initial_send_checkpoint": 1,
"initial_recv_checkpoint": 1
"initial_recv_checkpoint": 1,
"enable_debug_trace": true,
"average_block_time_msec": 1000,
"max_retry_for_inclusion": 5
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
Expand Down
7 changes: 5 additions & 2 deletions tests/cases/eth2eth/configs/chains/ibc-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
"rpc_addr": "http://localhost:8745",
"hdw_mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"hdw_path": "m/44'/60'/0'/0/0",
"ibc_address": "0x702E40245797c5a2108A566b3CE2Bf14Bc6aF841",
"ibc_address": "0x9eBF3956EE45B2b9F1fC85FB8990ce6be52F47a6",
"initial_send_checkpoint": 1,
"initial_recv_checkpoint": 1
"initial_recv_checkpoint": 1,
"enable_debug_trace": true,
"average_block_time_msec": 1000,
"max_retry_for_inclusion": 5
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/eth2eth/configs/path.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"channel-id": "channel-0",
"port-id": "transfer",
"order": "unordered",
"version": "transfer-1"
"version": "ics20-1"
},
"dst": {
"chain-id": "ibc1",
Expand All @@ -15,7 +15,7 @@
"channel-id": "channel-0",
"port-id": "transfer",
"order": "unordered",
"version": "transfer-1"
"version": "ics20-1"
},
"strategy": {
"type": "naive"
Expand Down
10 changes: 5 additions & 5 deletions tests/cases/eth2eth/scripts/test-tx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ if ! which ${ICS20_CLI} > /dev/null 2>&1; then
fi
git clone https://github.com/datachainlab/ethereum-ics20-cli.git ${TMP_DIR}/ethereum-ics20-cli
cd ${TMP_DIR}/ethereum-ics20-cli
git checkout v0.0.4
git checkout v0.0.5
go install
export PATH=$PATH:$(go env GOPATH)/bin
fi

SIMPLE_TOKEN_ADDRESS="0xff77d90d6aa12db33d3ba50a34fb25401f6e4c4f"
ICS20_TRANSFER_BANK_ADDRESS="0xaE1C9125BbcF63bf51294C4D15CBD472782E330D"
ICS20_BANK_ADDRESS="0x2F5703804E29F4252FA9405B8D357220d11b3bd9"
ERC20_TOKEN_ADDRESS="0x702E40245797c5a2108A566b3CE2Bf14Bc6aF841"
ICS20_TRANSFER_BANK_ADDRESS="0xff77D90D6aA12db33d3Ba50A34fB25401f6e4c4F"
ICS20_BANK_ADDRESS="0xaa43d337145E8930d01cb4E60Abf6595C692921E"

DENOM=$(echo "$SIMPLE_TOKEN_ADDRESS" | tr '[:upper:]' '[:lower:]')
DENOM=$(echo "$ERC20_TOKEN_ADDRESS" | tr '[:upper:]' '[:lower:]')

CHAIN_A_JSON=${CONF_DIR}/chains/ibc-0.json
CHAIN_B_JSON=${CONF_DIR}/chains/ibc-1.json
Expand Down
1 change: 1 addition & 0 deletions tests/cases/tm2eth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixtures/
21 changes: 21 additions & 0 deletions tests/cases/tm2eth/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
include ../../docker.mk

.PHONY: network
network:
TAG=${DOCKER_TAG} $(DOCKER_COMPOSE) \
-f ../docker-compose-test.yaml \
up -d \
tendermint-chain0-mock ethereum-ganache0

.PHONY: test
test:
./scripts/fixture
./scripts/init-rly
./scripts/handshake
./scripts/test-tx

.PHONY: network-down
network-down:
TAG=${DOCKER_TAG} $(DOCKER_COMPOSE) \
-f ../docker-compose-test.yaml \
down -v --remove-orphans
17 changes: 17 additions & 0 deletions tests/cases/tm2eth/configs/demo/ibc-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"chain": {
"@type": "/relayer.chains.tendermint.config.ChainConfig",
"key": "testkey",
"chain_id": "ibc0",
"rpc_addr": "http://localhost:26657",
"account_prefix": "cosmos",
"gas_adjustment": 1.5,
"gas_prices": "0.025stake",
"average_block_time_msec": 1000,
"max_retry_for_commit": 5
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 0
}
}
20 changes: 20 additions & 0 deletions tests/cases/tm2eth/configs/demo/ibc-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"chain": {
"@type": "/relayer.chains.ethereum.config.ChainConfig",
"chain_id": "ibc1",
"eth_chain_id": 2018,
"rpc_addr": "http://localhost:8645",
"hdw_mnemonic": "math razor capable expose worth grape metal sunset metal sudden usage scheme",
"hdw_path": "m/44'/60'/0'/0/0",
"ibc_address": "0x9eBF3956EE45B2b9F1fC85FB8990ce6be52F47a6",
"initial_send_checkpoint": 1,
"initial_recv_checkpoint": 1,
"enable_debug_trace": true,
"average_block_time_msec": 1000,
"max_retry_for_inclusion": 5
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 0
}
}
23 changes: 23 additions & 0 deletions tests/cases/tm2eth/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"
}
}
16 changes: 16 additions & 0 deletions tests/cases/tm2eth/scripts/fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eux

DOCKER=docker
SCRIPT_DIR=$(cd $(dirname $0); pwd)
FIXTURES_DIR=${SCRIPT_DIR}/../fixtures

# Setup test fixtures

set +x
rm -rf ${FIXTURES_DIR}
mkdir -p ${FIXTURES_DIR}/tendermint/ibc0
set -x

# retrieve the mnemonic from the container to the local
${DOCKER} cp tendermint-chain0:/root/data/ibc0/key_seed.json ${FIXTURES_DIR}/tendermint/ibc0/key_seed.json
21 changes: 21 additions & 0 deletions tests/cases/tm2eth/scripts/handshake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -eux

source $(cd $(dirname "$0"); pwd)/../../../scripts/util

SCRIPT_DIR=$(cd $(dirname $0); pwd)
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
RLY="${RLY_BINARY} --debug"

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

# add a path between chain0 and chain1
$RLY paths add $CHAINID_ONE $CHAINID_TWO $PATH_NAME --file=./configs/path.json

retry 5 $RLY tx clients $PATH_NAME
retry 5 $RLY tx connection $PATH_NAME
retry 5 $RLY tx channel $PATH_NAME
28 changes: 28 additions & 0 deletions tests/cases/tm2eth/scripts/init-rly
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -eux

SCRIPT_DIR=$(cd $(dirname $0); pwd)

RELAYER_CONF="$HOME/.yui-relayer"
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
RLY="${RLY_BINARY} --debug"
FIXTURES_DIR=${SCRIPT_DIR}/../fixtures

echo "Generating ${RLY_BINARY} configurations..."

# Ensure ${RLY_BINARY} is installed
if ! [ -x ${RLY_BINARY} ]; then
echo "Error: ${RLY_BINARY} is not installed." >&2
exit 1
fi

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

${RLY} config init
${RLY} chains add-dir configs/demo/

# A setup for tendermint client

SEED0=$(jq -r '.mnemonic' < ${FIXTURES_DIR}/tendermint/ibc0/key_seed.json)
echo "Key $(${RLY} tendermint keys restore ibc0 testkey "$SEED0") imported from ibc0 to relayer..."
Loading