Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.0
replace (
// https://github.com/cosmos/cosmos-sdk/blob/v0.47.3/go.mod#L171-L182
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/hyperledger-labs/yui-relayer v0.5.16 => github.com/hyperledger-labs/yui-relayer v0.5.18-0.20250916103708-f2e9f3c82be9
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,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.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
github.com/hyperledger-labs/yui-relayer v0.5.16 h1:NauHZ08JsfIvkzopafR/5/TbRCAH7JSUgqm7YrUEQ/4=
github.com/hyperledger-labs/yui-relayer v0.5.16/go.mod h1:tGNMIE1y4cGNyRRKhR9rfBtCGLVjgejf3EIXouvdDQc=
github.com/hyperledger-labs/yui-relayer v0.5.18-0.20250916103708-f2e9f3c82be9 h1:oXCl/L0AljE5nbM1EdOQrycIv51URclrdAkRQYu6f8g=
github.com/hyperledger-labs/yui-relayer v0.5.18-0.20250916103708-f2e9f3c82be9/go.mod h1:tGNMIE1y4cGNyRRKhR9rfBtCGLVjgejf3EIXouvdDQc=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
4 changes: 4 additions & 0 deletions relayer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import (

"github.com/datachainlab/ethereum-ibc-relay-chain/pkg/relay/ethereum"
"github.com/datachainlab/ibc-hd-signer/pkg/hd"
debug_chain "github.com/hyperledger-labs/yui-relayer/chains/debug/module"
tendermint "github.com/hyperledger-labs/yui-relayer/chains/tendermint/module"
"github.com/hyperledger-labs/yui-relayer/cmd"
debug_prover "github.com/hyperledger-labs/yui-relayer/provers/debug/module"
mock "github.com/hyperledger-labs/yui-relayer/provers/mock/module"
)

func main() {
if err := cmd.Execute(
tendermint.Module{},
mock.Module{},
debug_chain.Module{},
debug_prover.Module{},
ethereum.Module{},
hd.Module{},
); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/docker-compose-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ services:
container_name: tendermint-chain0-mock
environment:
USE_MOCK_CLIENT: 1
IBC_CHANNEL_UPGRADE_TIMEOUT: 30000000000
IBC_CHANNEL_UPGRADE_TIMEOUT: 480000000000 #480 sec
tendermint-chain1-mock:
<<: *tendermint-chain1
container_name: tendermint-chain1-mock
environment:
USE_MOCK_CLIENT: 1
IBC_CHANNEL_UPGRADE_TIMEOUT: 30000000000
IBC_CHANNEL_UPGRADE_TIMEOUT: 480000000000 #480 sec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dai1975 I think this timeout could be set shorter. What would be a appropriate value?


# Ethereum
ethereum-geth0:
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/tm2eth/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include ../../docker.mk

export USE_FAKELOST ?= yes

.PHONY: network
network:
TAG=${DOCKER_TAG} $(DOCKER_COMPOSE) \
Expand All @@ -15,6 +17,7 @@ test:
./scripts/test-channel-upgrade
./scripts/test-mockapp-packet-relay
./scripts/test-ics20-packet-relay
./scripts/test-service

.PHONY: network-down
network-down:
Expand Down
7 changes: 5 additions & 2 deletions tests/cases/tm2eth/configs/demo/ibc-0.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"max_retry_for_commit": 5
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 0
"@type": "/relayer.provers.debug.config.ProverConfig",
"origin_prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 0
}
}
}
7 changes: 5 additions & 2 deletions tests/cases/tm2eth/configs/template/ibc-1.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"price_bump": 10
},
"prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 0
"@type": "/relayer.provers.debug.config.ProverConfig",
"origin_prover": {
"@type": "/relayer.provers.mock.config.ProverConfig",
"finality_delay": 0
}
}
}
6 changes: 6 additions & 0 deletions tests/cases/tm2eth/scripts/handshake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ RLYKEY=testkey
MOCKAPP_PATH=mockapp-path
ICS20_PATH=ics20-path

if [ "USE_FAKELOST-$USE_FAKELOST" = "USE_FAKELOST-yes" ]; then
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_CHAIN_ibc1="10"
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_PROVER_ibc1="10"
export DEBUG_RELAYER_SHFU_WAIT_ibc0="20"
fi


# add a path between chain0 and chain1
$RLY paths add $CHAINID_ONE $CHAINID_TWO $MOCKAPP_PATH --file=./configs/mockapp-path.json
Expand Down
6 changes: 6 additions & 0 deletions tests/cases/tm2eth/scripts/test-channel-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ RELAYER_CONF="$HOME/.yui-relayer"
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
RLY="${RLY_BINARY} --debug"

if [ "USE_FAKELOST-$USE_FAKELOST" = "USE_FAKELOST-yes" ]; then
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_CHAIN_ibc1="10"
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_PROVER_ibc1="10"
export DEBUG_RELAYER_SHFU_WAIT_ibc0="20"
fi

PATH_NAME=mockapp-path

checkEq() {
Expand Down
6 changes: 6 additions & 0 deletions tests/cases/tm2eth/scripts/test-ics20-packet-relay
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ RELAYER_CONF="$HOME/.yui-relayer"
RLY_BINARY=${SCRIPT_DIR}/../../../../build/yrly
RLY="${RLY_BINARY} --debug"

if [ "USE_FAKELOST-$USE_FAKELOST" = "USE_FAKELOST-yes" ]; then
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_CHAIN_ibc1="10"
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_PROVER_ibc1="10"
export DEBUG_RELAYER_SHFU_WAIT_ibc0="20"
fi

PATH_NAME=ics20-path

TM_ADDRESS=$(${RLY} tendermint keys show ibc0 testkey)
Expand Down
22 changes: 10 additions & 12 deletions tests/cases/tm2eth/scripts/test-mockapp-packet-relay
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
set -eux

SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
source ${SCRIPT_DIR}/utils
FIXTURES_DIR=${SCRIPT_DIR}/../fixtures

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

if [ "USE_FAKELOST-$USE_FAKELOST" = "USE_FAKELOST-yes" ]; then
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_CHAIN_ibc1="10"
export DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_PROVER_ibc1="10"
export DEBUG_RELAYER_SHFU_WAIT_ibc0="20"
fi

PATH_NAME=mockapp-path

ADDRESSES_DIR_B="${FIXTURES_DIR}/ethereum/ibc1/addresses"
Expand All @@ -31,18 +38,9 @@ ${RLY} tx acks $PATH_NAME --dst-seqs 1
sleep ${TX_INTERVAL}

echo "!!! ibc1 -> ibc0 !!!"
BOB_INDEX=2
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" \
--mnemonic-index ${BOB_INDEX} \
$MOCKAPP_CONTRACT_B \
'sendPacket(bytes,string,string,(uint64,uint64),uint64)' \
$(cast from-utf8 'mock packet data') \
$PORT_B \
$CHANNEL_B \
'(0,100000)' \
$(date -d 1hour +%s%N)
TX_INTERVAL=20
sendPacketToEth $PATH_NAME

sleep ${TX_INTERVAL}
${RLY} tx relay $PATH_NAME --dst-seqs 1
sleep ${TX_INTERVAL}
Expand Down
55 changes: 55 additions & 0 deletions tests/cases/tm2eth/scripts/test-service
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

: <<'END_COMMENT'
* relay-interval = 20s
* src-relay-optimize-interval = 30s
* src-relay-optimize-count = 3
* dst-relay-optimize-interval = 30s
* dst-relay-optimize-count = 3
END_COMMENT

set -eux

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

if [ "USE_FAKELOST-$USE_FAKELOST" = "USE_FAKELOST-yes" ]; then
export DEBUG_RELAYER_MISSING_TRIE_NODE_HEIGHT_ibc1="10"
export DEBUG_RELAYER_MISSING_TRIE_NODE_HEIGHT_PROVER_ibc1="10"
export DEBUG_RELAYER_SHFU_WAIT_ibc0="20"
fi

PATH_NAME=mockapp-path
TM_ADDRESS0=$(${RLY} tendermint keys show ibc0 testkey)

expectUnrelayedCount $PATH_NAME "unrelayed-packets" "src" 0
expectUnrelayedCount $PATH_NAME "unrelayed-packets" "dst" 0
expectUnrelayedCount $PATH_NAME "unrelayed-acknowledgements" "src" 0
expectUnrelayedCount $PATH_NAME "unrelayed-acknowledgements" "dst" 0

sendPacketToEth $PATH_NAME
waitUnrelayedCount $PATH_NAME "unrelayed-packets" "dst" 1 300

docker exec tendermint-chain0-mock sh -c "simd --home /root/data/ibc0 tx --keyring-backend=test --from ${TM_ADDRESS0} --chain-id ibc0 mockapp send mockapp channel-0 'mock packet data' --yes"
waitUnrelayedCount $PATH_NAME "unrelayed-packets" "src" 1 30

date; echo " yyyyyyyy Now is @0, Server has started. Both chains already have a message to relay which will be ready after optimize-interval(30s)."

${RLY} service start $PATH_NAME --relay-interval 20s --src-relay-optimize-interval 30s --src-relay-optimize-count 3 --dst-relay-optimize-interval 30s --dst-relay-optimize-count 3 &
RLY_PID=$!

echo "Waiting dst->src packets are relayed. Not that src chain(tendermint) has fast confirmation time"
waitUnrelayedCount $PATH_NAME "unrelayed-packets" "dst" 0 300
echo "Waiting src->dst packets are relayed"
waitUnrelayedCount $PATH_NAME "unrelayed-packets" "src" 0 300

echo "Waiting dst->src ack is relayed. Not that the time of src->dst->src relay and dst->src->dst relay takes nearly same time"
waitUnrelayedCount $PATH_NAME "unrelayed-acknowledgements" "dst" 0 300
echo "Waiting src->dst ack is relayed"
waitUnrelayedCount $PATH_NAME "unrelayed-acknowledgements" "src" 0 300

echo "Finished"

kill $RLY_PID
83 changes: 83 additions & 0 deletions tests/cases/tm2eth/scripts/utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
expectUnrelayedCount() {
local PATH_NAME=$1
local query_type=$2
local filter=".$3 | length"
local expect_count=$4
unrelayed_count=$(${RLY} query ${query_type} $PATH_NAME | jq "${filter}")
if [ "$unrelayed_count" -ne "${expect_count}" ]; then
echo "$query_type: $unrelayed_count"
test -z "$RLY_PID" || kill $RLY_PID
exit 1
fi
}

waitUnrelayedCount() {
local PATH_NAME=$1
local query_type=$2
local chain=$3
local filter=".$chain | length"
local expect_count=$4
timeout=$(( $(date +%s) + $5 ))
unrelayed_count=999
until [ "$unrelayed_count" -eq "$expect_count" ]; do
unrelayed_count=$(${RLY} query ${query_type} $PATH_NAME | jq "${filter}")
date
echo "$0 ${query_type} is $unrelayed_count"
t=$(date +%s)
if [ $t -gt $timeout ]; then
echo "TIMEOUT waitUnrelayedCount: $query_type $chain expect $expect_count but $unrelayed_count"
exit 1
fi
sleep 10
done
}

sendPacketToEth() {
local PATH_NAME=$1
local MOCKAPP_CONTRACT_B=$(cat $(dirname $0)/../fixtures/ethereum/ibc1/addresses/AppV1)
local RPC_ADDRESS_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.rpc_addr')
local PORT_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."port-id"')
local CHANNEL_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."channel-id"')

local MNEMONIC_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.signer.mnemonic')
local SENDER=$(cast wallet address --mnemonic "$MNEMONIC_B" --mnemonic-index 2)

cast balance $SENDER --rpc-url $RPC_ADDRESS_B
cast nonce $SENDER --rpc-url $RPC_ADDRESS_B
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" --mnemonic-index 2 \
--legacy \
$MOCKAPP_CONTRACT_B \
'sendPacket(bytes,string,string,(uint64,uint64),uint64)' \
$(cast from-utf8 'mock packet data') \
$PORT_B \
$CHANNEL_B \
'(0,100000)' \
$(date -d 1hour +%s%N) || exit 1
}

xsendPacketToEth() {
local PATH_NAME=$1
local MOCKAPP_CONTRACT_B=$(cat $(dirname $0)/../fixtures/ethereum/ibc1/addresses/AppV1)
local RPC_ADDRESS_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.rpc_addr')
local PORT_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."port-id"')
local CHANNEL_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."channel-id"')

local MNEMONIC_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.signer.mnemonic')
local SENDER=$(cast wallet address --mnemonic "$MNEMONIC_B" --mnemonic-index 2)

cast balance $SENDER --rpc-url $RPC_ADDRESS_B
cast nonce $SENDER --rpc-url $RPC_ADDRESS_B
echo test: cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" --mnemonic-index 2 \
--legacy \
$MOCKAPP_CONTRACT_B \
'sendPacket(bytes,string,string,(uint64,uint64),uint64)' \
$(cast from-utf8 'mock packet data') \
$PORT_B \
$CHANNEL_B \
'(0,100000)' \
$(date -d 1hour +%s%N) || exit 1
}
3 changes: 3 additions & 0 deletions tests/chains/ethereum/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ down-scaffold:
docker-commit:
$(SCRIPT_DIR)/docker/commitImage.sh $(DOCKER_REPO) $(DOCKER_TAG) ethereum-geth0 ethereum-geth0-scaffold $(CHAIN_ID0)
$(SCRIPT_DIR)/docker/commitImage.sh $(DOCKER_REPO) $(DOCKER_TAG) ethereum-geth1 ethereum-geth1-scaffold $(CHAIN_ID1)

clean:
rm -rf contracts/addresses contracts/artifacts contracts/cache contracts/.openzeppelin