Skip to content

Commit

Permalink
Working version with Osmosis testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Chandra committed Oct 9, 2023
1 parent ff802b7 commit 3ef7df5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
13 changes: 13 additions & 0 deletions docker-compose.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
dockerfile: saga.Dockerfile
environment:
- KEYNAME=relayer
- PROVIDER_CHAIN=
- CONSUMER_CHAIN=
- PROVIDER_CHAINID=
- CONSUMER_CHAINID=
- PROVIDER_RLY_MNEMONIC=
Expand All @@ -22,6 +24,17 @@ services:
- RLY_DST_PORT=provider # Do not change unless you know what you are doing
- RLY_ORDERING=ordered # Do not change unless you know what you are doing
- RLY_DEBUG=true # set it to false as needed
- PROVIDER_CHAIN_ADDRESS_PREFIX=
- CONSUMER_CHAIN_ADDRESS_PREFIX=
- PROVIDER_RLY_GASPRICE=
- PROVIDER_RLY_MAXGASAMT=
- PROVIDER_RLY_MINGASAMT=1
- PROVIDER_RLY_BROADCAST_MODE=sync
- CONSUMER_RLY_GASPRICE=
- CONSUMER_RLY_MAXGASAMT=
- CONSUMER_RLY_MINGASAMT=1
- CONSUMER_RLY_BROADCAST_MODE=sync
- RLY_CHANNEL_VERSION= # Use ics20-1 when using source and dst ports as transfer
networks:
- localnet
ports:
Expand Down
18 changes: 12 additions & 6 deletions rly/start-rly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ RLY_DST_PORT=${RLY_DST_PORT:-transfer}
RLY_ORDERING=${RLY_ORDERING:-unordered}
RLY_CHANNEL_VERSION=${RLY_CHANNEL_VERSION:-1}
RLY_DEBUG=${RLY_DEBUG:-false}
PATHNAME=${PATHNAME:-pc}

# Broadcasting
PROVIDER_RLY_BROADCAST_MODE=${PROVIDER_RLY_BROADCAST_MODE:-sync}
CONSUMER_RLY_BROADCAST_MODE=${CONSUMER_RLY_BROADCAST_MODE:-sync}

# Address prefix
PROVIDER_CHAIN_ADDRESS_PREFIX=${PROVIDER_CHAIN_ADDRESS_PREFIX:-saga}
Expand Down Expand Up @@ -112,11 +117,14 @@ ValidateAndEchoEnvVars()
ValidateEnvVar CONSUMER_RLY_CLIENTID
ValidateEnvVar PROVIDER_CHAIN_ADDRESS_PREFIX
ValidateEnvVar CONSUMER_CHAIN_ADDRESS_PREFIX
ValidateEnvVar PROVIDER_RLY_BROADCAST_MODE
ValidateEnvVar CONSUMER_RLY_BROADCAST_MODE
ValidateEnvVar RLY_SRC_PORT
ValidateEnvVar RLY_DST_PORT
ValidateEnvVar RLY_ORDERING
ValidateEnvVar RLY_CHANNEL_VERSION
ValidateEnvVar RLY_DEBUG
ValidateEnvVar PATHNAME
ValidateEnvVar KEYRING
ValidateEnvVar SLEEPTIME 0 1
ValidateEnvVar KEYALGO
Expand Down Expand Up @@ -147,8 +155,8 @@ GenerateChainFiles()
jq --arg ACCTPREFIX $PROVIDER_CHAIN_ADDRESS_PREFIX '.value."account-prefix" = $ACCTPREFIX' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json
jq --argjson MAXGAS $PROVIDER_RLY_MAXGASAMT '.value."max-gas-amount" = $MAXGAS' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json
jq --argjson MINGAS $PROVIDER_RLY_MINGASAMT '.value."min-gas-amount" = $MINGAS' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json
jq --arg BROADCASTMODE $PROVIDER_RLY_BROADCAST_MODE '.value."broadcast-mode" = $BROADCASTMODE' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json


jq --arg KEY $KEYNAME '.value.key = $KEY' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
jq --arg CHAINID $CONSUMER_CHAINID '.value."chain-id" = $CHAINID' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
jq --arg RPCADDR $CONSUMER_RPC_ADDRESS '.value."rpc-addr" = $RPCADDR' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
Expand All @@ -158,14 +166,14 @@ GenerateChainFiles()
jq --arg ACCTPREFIX $CONSUMER_CHAIN_ADDRESS_PREFIX '.value."account-prefix" = $ACCTPREFIX' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
jq --argjson MAXGAS $CONSUMER_RLY_MAXGASAMT '.value."max-gas-amount" = $MAXGAS' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
jq --argjson MINGAS $CONSUMER_RLY_MINGASAMT '.value."min-gas-amount" = $MINGAS' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
jq --arg BROADCASTMODE $CONSUMER_RLY_BROADCAST_MODE '.value."broadcast-mode" = $BROADCASTMODE' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json

Logger "Exiting function GenerateChainFiles"
}

ConfigRelayer()
{
Logger "Starting function ConfigRelayer"
local PATHNAME=pc
rly chains add $PROVIDER_CHAIN --file /root/provider-rly.json --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODE=$?
CheckRetcode $RETCODE 1 "Could not add chain $PROVIDER_CHAINID to relayer config. Return code was $RETCODE. Exiting"
Expand Down Expand Up @@ -214,7 +222,7 @@ LinkRelayer()
Logger "Now connecting $PROVIDER_CHAIN and $CONSUMER_CHAIN. This can take a few minutes..."
until [ $cnt -ge 3 ];
do
(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly transact link pc --home .relayer --src-port $RLY_SRC_PORT --dst-port $RLY_DST_PORT --order $RLY_ORDERING --version $RLY_CHANNEL_VERSION 1>> $LOGFILE 2>> $ERRFILE
(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly transact link $PATHNAME --home .relayer --src-port $RLY_SRC_PORT --dst-port $RLY_DST_PORT --order $RLY_ORDERING --version $RLY_CHANNEL_VERSION 1>> $LOGFILE 2>> $ERRFILE
RETCODE_LNK=$?
Logger "DEBUG RETCODE is $RETCODE_LNK"
if [ $RETCODE_LNK -ne 0 ];
Expand Down Expand Up @@ -278,6 +286,4 @@ GenerateChainFiles
ConfigRelayer
CheckLaunchReadiness
LinkRelayer
# Logger "Debug sleep"
# sleep 600
(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly start pc --home .relayer
(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly start $PATHNAME --home .relayer

0 comments on commit 3ef7df5

Please sign in to comment.