Skip to content

Commit

Permalink
Updates to add various gas parms
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashish Chandra committed Oct 4, 2023
1 parent 2a20514 commit 0bcfddf
Showing 1 changed file with 55 additions and 22 deletions.
77 changes: 55 additions & 22 deletions rly/start-rly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ SLEEPTIME_BLOCKWAIT=${SLEEPTIME_BLOCKWAIT:-1}

PROVIDER_CHAIN=${PROVIDER_CHAIN:-provider}
CONSUMER_CHAIN=${CONSUMER_CHAIN:-consumer}
PROVIDER_RLY_GASPRICE=${PROVIDER_RLY_GASPRICE:-0stake}
CONSUMER_RLY_GASPRICE=${CONSUMER_RLY_GASPRICE:-0stake}
PROVIDER_RLY_CLIENTID=${PROVIDER_RLY_CLIENTID:-07-tendermint-0}
CONSUMER_RLY_CLIENTID=${CONSUMER_RLY_CLIENTID:-07-tendermint-0}
RLY_SRC_PORT=${RLY_SRC_PORT:-transfer}
Expand All @@ -17,6 +15,19 @@ RLY_ORDERING=${RLY_ORDERING:-unordered}
RLY_CHANNEL_VERSION=${RLY_CHANNEL_VERSION:-1}
RLY_DEBUG=${RLY_DEBUG:-false}

# Address prefix
PROVIDER_CHAIN_ADDRESS_PREFIX=${PROVIDER_CHAIN_ADDRESS_PREFIX:-saga}
CONSUMER_CHAIN_ADDRESS_PREFIX=${CONSUMER_CHAIN_ADDRESS_PREFIX:-saga}

#Gas
PROVIDER_RLY_GASPRICE=${PROVIDER_RLY_GASPRICE:-0stake}
CONSUMER_RLY_GASPRICE=${CONSUMER_RLY_GASPRICE:-0stake}
PROVIDER_RLY_MAXGASAMT=${PROVIDER_RLY_MAXGASAMT:-0}
CONSUMER_RLY_MAXGASAMT=${CONSUMER_RLY_MAXGASAMT:-0}
PROVIDER_RLY_MINGASAMT=${PROVIDER_RLY_MINGASAMT:-0}
CONSUMER_RLY_MINGASAMT=${CONSUMER_RLY_MINGASAMT:-0}


KEYRING=${KEYRING:-file}
TESTKEYRING="test"
KEYALGO=${KEYALGO:-"secp256k1"}
Expand Down Expand Up @@ -93,8 +104,14 @@ ValidateAndEchoEnvVars()
ValidateEnvVar CONSUMER_RPC_ADDRESS
ValidateEnvVar PROVIDER_RLY_GASPRICE
ValidateEnvVar CONSUMER_RLY_GASPRICE
ValidateEnvVar PROVIDER_RLY_MAXGASAMT
ValidateEnvVar CONSUMER_RLY_MAXGASAMT
ValidateEnvVar PROVIDER_RLY_MINGASAMT
ValidateEnvVar CONSUMER_RLY_MINGASAMT
ValidateEnvVar PROVIDER_RLY_CLIENTID
ValidateEnvVar CONSUMER_RLY_CLIENTID
ValidateEnvVar PROVIDER_CHAIN_ADDRESS_PREFIX
ValidateEnvVar CONSUMER_CHAIN_ADDRESS_PREFIX
ValidateEnvVar RLY_SRC_PORT
ValidateEnvVar RLY_DST_PORT
ValidateEnvVar RLY_ORDERING
Expand Down Expand Up @@ -127,13 +144,21 @@ GenerateChainFiles()
jq --arg KEYRING $KEYRING '.value."keyring-backend" = $KEYRING' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json
jq --argjson DEBUG $RLY_DEBUG '.value.debug = $DEBUG' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json
jq --arg GAS $PROVIDER_RLY_GASPRICE '.value."gas-prices" = $GAS' /root/provider-rly.json > /root/provider-rly-tmp.json && mv /root/provider-rly-tmp.json /root/provider-rly.json
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 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
jq --arg KEYRING $KEYRING '.value."keyring-backend" = $KEYRING' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
jq --argjson DEBUG $RLY_DEBUG '.value.debug = $DEBUG' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
jq --arg GAS $CONSUMER_RLY_GASPRICE '.value."gas-prices" = $GAS' /root/consumer-rly.json > /root/consumer-rly-tmp.json && mv /root/consumer-rly-tmp.json /root/consumer-rly.json
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

Logger "Exiting function GenerateChainFiles"
}

Expand Down Expand Up @@ -170,11 +195,14 @@ ConfigRelayer()
rly paths new $CONSUMER_CHAINID $PROVIDER_CHAINID $PATHNAME --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODE=$?
CheckRetcode $RETCODE 1 "Could not create a new path for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID. Return code was $RETCODE. Exiting"
Logger "New path $PATHNAME successfully created for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID"
rly paths update $PATHNAME --src-client-id $CONSUMER_RLY_CLIENTID --dst-client-id $PROVIDER_RLY_CLIENTID --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODE=$?
CheckRetcode $RETCODE 1 "Could not update the path with source/destination client-id for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID. Return code was $RETCODE. Exiting"
Logger "Path $PATHNAME successfully updated for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID"
if [[ "$RLY_SRC_PORT" != "transfer" && "$RLY_DST_PORT" != "transfer" ]];
then
Logger "New path $PATHNAME successfully created for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID"
rly paths update $PATHNAME --src-client-id $CONSUMER_RLY_CLIENTID --dst-client-id $PROVIDER_RLY_CLIENTID --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODE=$?
CheckRetcode $RETCODE 1 "Could not update the path with source/destination client-id for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID. Return code was $RETCODE. Exiting"
Logger "Path $PATHNAME successfully updated for chains $PROVIDER_CHAINID and $CONSUMER_CHAINID"
fi
Logger "Exiting function ConfigRelayer"
}

Expand Down Expand Up @@ -221,21 +249,24 @@ CheckLaunchReadiness()
Logger "Waiting for provider chain $PROVIDER_CHAINID and consumer chain $CONSUMER_CHAINID to come online"
sleep $SLEEPTIME
done
Logger "Ensuring both provider and consumer chains are producing blocks"
local BLOCKNUM=3 # Height should be at least 2 in order to link the chains via IBC
while true
do
rly q header $PROVIDER_CHAIN $BLOCKNUM --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODEP=$?
rly q header $CONSUMER_CHAIN $BLOCKNUM --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODEC=$?
if [[ ${RETCODEP} -eq 0 && ${RETCODEC} -eq 0 ]]; then
break
fi
Logger "Waiting for provider chain $PROVIDER_CHAINID and consumer chain $CONSUMER_CHAINID to produce blocks"
sleep $SLEEPTIME
done
Logger "Both provider and consumer chains are online and producing blocks. Continuing"
if [[ "$RLY_SRC_PORT" != "transfer" && "$RLY_DST_PORT" != "transfer" ]];
then
Logger "Ensuring both provider and consumer chains are producing blocks"
local BLOCKNUM=3 # Height should be at least 2 in order to link the chains via IBC
while true
do
rly q header $PROVIDER_CHAIN $BLOCKNUM --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODEP=$?
rly q header $CONSUMER_CHAIN $BLOCKNUM --home .relayer 1>> $LOGFILE 2>> $ERRFILE
RETCODEC=$?
if [[ ${RETCODEP} -eq 0 && ${RETCODEC} -eq 0 ]]; then
break
fi
Logger "Waiting for provider chain $PROVIDER_CHAINID and consumer chain $CONSUMER_CHAINID to produce blocks"
sleep $SLEEPTIME
done
Logger "Both provider and consumer chains are online and producing blocks. Continuing"
fi
Logger "Exiting function CheckLaunchReadiness"
}

Expand All @@ -247,4 +278,6 @@ GenerateChainFiles
ConfigRelayer
CheckLaunchReadiness
LinkRelayer
# Logger "Debug sleep"
# sleep 600
(echo $KEYPASSWD; sleep 1; echo $KEYPASSWD) | rly start pc --home .relayer

0 comments on commit 0bcfddf

Please sign in to comment.