ibc demo
This commit is contained in:
parent
1ffe00def6
commit
a9408aa3b1
|
@ -0,0 +1,13 @@
|
|||
#! /bin/bash
|
||||
|
||||
killall -9 basecoin tendermint
|
||||
TMROOT=./data/chain1/tendermint tendermint unsafe_reset_all
|
||||
TMROOT=./data/chain2/tendermint tendermint unsafe_reset_all
|
||||
|
||||
rm -rf ./data/chain1/basecoin/merkleeyes.db
|
||||
rm -rf ./data/chain2/basecoin/merkleeyes.db
|
||||
|
||||
rm ./*.log
|
||||
|
||||
rm ./data/chain1/tendermint/*.bak
|
||||
rm ./data/chain2/tendermint/*.bak
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
"base/chainID", "test_chain_1",
|
||||
"base/account", {
|
||||
"pub_key": [1, "B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF"],
|
||||
"coins": [
|
||||
{
|
||||
"denom": "blank",
|
||||
"amount": 9007199254740992
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"address": "D397BC62B435F3CF50570FBAB4340FE52C60858F",
|
||||
"last_height": 0,
|
||||
"last_round": 0,
|
||||
"last_signature": null,
|
||||
"last_signbytes": "",
|
||||
"last_step": 0,
|
||||
"priv_key": [
|
||||
1,
|
||||
"39E75AA1CF7BC710585977EFC375CD1730519186BD231478C339F2819C3C26E7B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF"
|
||||
],
|
||||
"pub_key": [
|
||||
1,
|
||||
"B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# This is a TOML config file.
|
||||
# For more information, see https://github.com/toml-lang/toml
|
||||
|
||||
proxy_app = "tcp://127.0.0.1:46658"
|
||||
moniker = "anonymous"
|
||||
node_laddr = "tcp://0.0.0.0:46656"
|
||||
seeds = ""
|
||||
fast_sync = true
|
||||
db_backend = "leveldb"
|
||||
log_level = "notice"
|
||||
rpc_laddr = "tcp://0.0.0.0:46657"
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"app_hash": "",
|
||||
"chain_id": "test-chain-AtzVUw",
|
||||
"genesis_time": "0001-01-01T00:00:00.000Z",
|
||||
"validators": [
|
||||
{
|
||||
"amount": 10,
|
||||
"name": "",
|
||||
"pub_key": [
|
||||
1,
|
||||
"D6EBB92440CF375054AA59BCF0C99D596DEEDFFB2543CAE1BA1908B72CF9676A"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"address": "EBB0B4A899973C524A6BB18A161056A55F590F41",
|
||||
"last_height": 0,
|
||||
"last_round": 0,
|
||||
"last_signature": null,
|
||||
"last_signbytes": "",
|
||||
"last_step": 0,
|
||||
"priv_key": [
|
||||
1,
|
||||
"5FFDC1EA5FA2CA4A0A5503C86D2D348C5B401AD80FAA1899508F1ED00D8982E8D6EBB92440CF375054AA59BCF0C99D596DEEDFFB2543CAE1BA1908B72CF9676A"
|
||||
],
|
||||
"pub_key": [
|
||||
1,
|
||||
"D6EBB92440CF375054AA59BCF0C99D596DEEDFFB2543CAE1BA1908B72CF9676A"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
"base/chainID", "test_chain_2",
|
||||
"base/account", {
|
||||
"pub_key": [1, "0628C8E6C2D50B15764B443394E06C6A64F3082CE966A2A8C1A55A4D63D0FC5D"],
|
||||
"coins": [
|
||||
{
|
||||
"denom": "blank",
|
||||
"amount": 9007199254740992
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"address": "053BA0F19616AFF975C8756A2CBFF04F408B4D47",
|
||||
"last_height": 0,
|
||||
"last_round": 0,
|
||||
"last_signature": null,
|
||||
"last_signbytes": "",
|
||||
"last_step": 0,
|
||||
"priv_key": [
|
||||
1,
|
||||
"22920C428043D869987F253D7C9B2305E7010642C40CE88A52C9F6CE5ACC42080628C8E6C2D50B15764B443394E06C6A64F3082CE966A2A8C1A55A4D63D0FC5D"
|
||||
],
|
||||
"pub_key": [
|
||||
1,
|
||||
"0628C8E6C2D50B15764B443394E06C6A64F3082CE966A2A8C1A55A4D63D0FC5D"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
# This is a TOML config file.
|
||||
# For more information, see https://github.com/toml-lang/toml
|
||||
|
||||
proxy_app = "tcp://127.0.0.1:46658"
|
||||
moniker = "anonymous"
|
||||
node_laddr = "tcp://0.0.0.0:46656"
|
||||
seeds = ""
|
||||
fast_sync = true
|
||||
db_backend = "leveldb"
|
||||
log_level = "notice"
|
||||
rpc_laddr = "tcp://0.0.0.0:46657"
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"app_hash": "",
|
||||
"chain_id": "test-chain-cLhwLM",
|
||||
"genesis_time": "0001-01-01T00:00:00.000Z",
|
||||
"validators": [
|
||||
{
|
||||
"amount": 10,
|
||||
"name": "",
|
||||
"pub_key": [
|
||||
1,
|
||||
"9A76DDE4CA4EE660C073D288DBE4F8A128F23857881A95F18167682D47E7058F"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"address": "D42CFCB9C42DF9A73143EEA89255D1DF027B6240",
|
||||
"last_height": 0,
|
||||
"last_round": 0,
|
||||
"last_signature": null,
|
||||
"last_signbytes": "",
|
||||
"last_step": 0,
|
||||
"priv_key": [
|
||||
1,
|
||||
"6353FAF4ADEB03EA496A9EAE5BE56C4C6A851CB705401788184FDC9198413C2C9A76DDE4CA4EE660C073D288DBE4F8A128F23857881A95F18167682D47E7058F"
|
||||
],
|
||||
"pub_key": [
|
||||
1,
|
||||
"9A76DDE4CA4EE660C073D288DBE4F8A128F23857881A95F18167682D47E7058F"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
#! /bin/bash
|
||||
set -eu
|
||||
|
||||
cd $GOPATH/src/github.com/tendermint/basecoin/demo
|
||||
|
||||
function removeQuotes() {
|
||||
temp="${1%\"}"
|
||||
temp="${temp#\"}"
|
||||
echo "$temp"
|
||||
}
|
||||
|
||||
# grab the chain ids
|
||||
CHAIN_ID1=$(cat ./data/chain1/basecoin/genesis.json | jq .[1])
|
||||
CHAIN_ID1=$(removeQuotes $CHAIN_ID1)
|
||||
CHAIN_ID2=$(cat ./data/chain2/basecoin/genesis.json | jq .[1])
|
||||
CHAIN_ID2=$(removeQuotes $CHAIN_ID2)
|
||||
echo "CHAIN_ID1: $CHAIN_ID1"
|
||||
echo "CHAIN_ID2: $CHAIN_ID2"
|
||||
|
||||
# make reusable chain flags
|
||||
CHAIN_FLAGS1="--chain_id $CHAIN_ID1 --from ./data/chain1/basecoin/priv_validator.json"
|
||||
CHAIN_FLAGS2="--chain_id $CHAIN_ID2 --from ./data/chain2/basecoin/priv_validator.json --node tcp://localhost:36657"
|
||||
|
||||
echo ""
|
||||
echo "... starting chains"
|
||||
echo ""
|
||||
# start the first node
|
||||
TMROOT=./data/chain1/tendermint tendermint node &> chain1_tendermint.log &
|
||||
basecoin start --ibc-plugin --dir ./data/chain1/basecoin &> chain1_basecoin.log &
|
||||
|
||||
# start the second node
|
||||
TMROOT=./data/chain2/tendermint tendermint node --node_laddr tcp://localhost:36656 --rpc_laddr tcp://localhost:36657 --proxy_app tcp://localhost:36658 &> chain2_tendermint.log &
|
||||
basecoin start --address tcp://localhost:36658 --ibc-plugin --dir ./data/chain2/basecoin &> chain2_basecoin.log &
|
||||
|
||||
echo ""
|
||||
echo "... waiting for chains to start"
|
||||
echo ""
|
||||
sleep 5
|
||||
|
||||
echo "... registering chain1 on chain2"
|
||||
echo ""
|
||||
# register chain1 on chain2
|
||||
basecoin ibc --amount 10 $CHAIN_FLAGS2 register --chain_id $CHAIN_ID1 --genesis ./data/chain1/tendermint/genesis.json
|
||||
|
||||
echo ""
|
||||
echo "... creating egress packet on chain1"
|
||||
echo ""
|
||||
# create a packet on chain1 destined for chain2
|
||||
PAYLOAD="DEADBEEF" #TODO
|
||||
basecoin ibc --amount 10 $CHAIN_FLAGS1 packet create --from $CHAIN_ID1 --to $CHAIN_ID2 --type coin --payload $PAYLOAD --sequence 1
|
||||
|
||||
echo ""
|
||||
echo "... querying for packet data"
|
||||
echo ""
|
||||
# query for the packet data and proof
|
||||
QUERY_RESULT=$(basecoin query ibc,egress,$CHAIN_ID1,$CHAIN_ID2,1)
|
||||
HEIGHT=$(echo $QUERY_RESULT | jq .height)
|
||||
PACKET=$(echo $QUERY_RESULT | jq .value)
|
||||
PROOF=$(echo $QUERY_RESULT | jq .proof)
|
||||
echo "QUERY_RESULT: $QUERY_RESULT"
|
||||
echo "HEIGHT: $HEIGHT"
|
||||
echo "PACKET: $PACKET"
|
||||
echo "PROOF: $PROOF"
|
||||
|
||||
echo ""
|
||||
echo "... querying for block data"
|
||||
echo ""
|
||||
# get the header and commit for the height
|
||||
HEADER_AND_COMMIT=$(basecoin block $HEIGHT)
|
||||
HEADER=$(echo $HEADER_AND_COMMIT | jq.hex.header)
|
||||
COMMIT=$(echo $HEADER_AND_COMMIT | jq.hex.commit)
|
||||
echo "HEADER_AND_COMMIT: $HEADER_AND_COMMIT"
|
||||
echo "HEADER: $HEADER"
|
||||
echo "COMMIT: $COMMIT"
|
||||
|
||||
echo ""
|
||||
echo "... updating state of chain1 on chain2"
|
||||
echo ""
|
||||
# update the state of chain1 on chain2
|
||||
basecoin ibc --amount 10 $CHAIN_FLAGS2 update --header 0x$HEADER --commit 0x$COMMIT
|
||||
|
||||
echo ""
|
||||
echo "... posting packet from chain1 on chain2"
|
||||
echo ""
|
||||
# post the packet from chain1 to chain2
|
||||
basecoin ibc --amount 10 $CHAIN_FLAGS2 packet post --from $CHAIN_ID1 --height $HEIGHT --packet $PACKET --proof $PROOF
|
Loading…
Reference in New Issue