Skip to content

Commit

Permalink
fix: add build setup for validator script
Browse files Browse the repository at this point in the history
  • Loading branch information
JeancarloBarrios committed Oct 17, 2023
1 parent b63c03b commit 3e4c624
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 28 deletions.
6 changes: 4 additions & 2 deletions dockers/sedad.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ CMD ["seda-chaind"]
STOPSIGNAL SIGTERM


RUN apt-get update && apt-get install ca-certificates -y \
RUN apt-get update && apt-get install ca-certificates git jq -y \
&& groupadd seda && useradd -g seda -m seda



COPY --from=builder /go/bin/seda-chaind /usr/local/bin/
COPY --from=builder /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm\@v*/internal/api/libwasmvm.*.so /usr/lib/

COPY scripts/validator_setup/validator_setup.sh /usr/local/bin/validator_setup.sh
RUN chmod +x /usr/local/bin/validator_setup.sh


ENTRYPOINT ["validator_setup.sh"]
73 changes: 47 additions & 26 deletions scripts/validator_setup/validator_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,78 @@
set -e

# Basic Setup Configurations
BIN=$(git rev-parse --show-toplevel)/build/seda-chaind # chain binary executable on your machine
BIN=seda-chaind # chain binary executable on your machine
KEYRING="${KEYRING:-file}"
KEYPASSWD="${KEYPASSWD:-somepassword}"
CHAIN_ID="${CHAIN_ID:-sedachain}"
NETWORK="${NETWORK:-devnet}"
MONIKER="${MONIKER:-node-test}"
MNEMONIC="mixture alone swear radar gate violin subway wink panther slim photo banana robust quarter client piano topic coin wool shove derive august volume alone"
SEDA_NODE="${SEDA_NODE:-http://35.177.180.184:26657}"
KEY_NAME="${KEY_NAME:-default_key}"

$BIN config keyring-backend file # use file backend

KeyName="${KEY_NAME:-default_key}"

# Adds a key to the keyring with the given MNEMONIC and KEYPASSWD (if provided) and KeyName
# or generates a new key if MNEMONIC is not provided.
if [[ -z "${MNEMONIC}" ]]; then
# $BIN
echo $KeyName
(echo $KEYPASSWD; echo $KEYPASSWD) | $BIN keys add $KeyName
echo "Error no mnemonic provided"
# (echo $KEYPASSWD; echo $KEYPASSWD) | $BIN keys add $KeyName
else
(echo $KEYPASSWD; echo $KEYPASSWD; echo $MNEMONIC) | $BIN keys add $KeyName
echo "Recovered key from mnemonic"
(echo $MNEMONIC; echo $KEYPASSWD; echo $KEYPASSWD) | $BIN keys add $KEY_NAME --recover
fi


$BIN init new $MONIKER

cp /Users/jc/Downloads/genesis.json /Users/jc/.seda-chain/config/genesis.json
# Initialize NODE config
echo "Initializing Node ..."
echo $MNEMONIC | $BIN init join ${MONIKER} --network ${NETWORK} --recover
echo "Node Initialized !"
echo "Connecting to Network ..."
echo $SEDA_NODE | $BIN config node $SEDA_NODE
echo "Conected to network !"

# VALIDATOR ENVS
STAKE_AMOUNT="${STAKE_AMOUNT:-100000000000000000seda}"
MONIKER="${MONIKER:-node0}"
COMMISSION_RATE="${COMMISSION_RATE:-0.10}"
COMMISSION_MAX_RATE="${COMMISSION_MAX_RATE:-0.20}"
COMMISSION_MAX_CHANGE_RATE="${COMMISSION_MAX_CHANGE_RATE:-0.01}"
MINIMAL_SELF_DELETAGION="${MINIMAL_SELF_DELETAGION:-10000000000000000seda}"
STAKE_AMOUNT="${STAKE_AMOUNT:-"100000000000000000seda"}"
echo $STAKE_AMOUNT
COMMISSION_RATE="${COMMISSION_RATE:-"0.10"}"
COMMISSION_MAX_RATE="${COMMISSION_MAX_RATE:-"0.20"}"
COMMISSION_MAX_CHANGE_RATE="${COMMISSION_MAX_CHANGE_RATE:"-0.01"}"
MINIMAL_SELF_DELETAGION="${MINIMAL_SELF_DELETAGION:-10}"


# Query for a validator if it does not exist exist create it
echo "Setting up validator ..."
echo "Querying for validator ..."
VALIDATOR=$($BIN query staking validators --output json | jq -r '.validators[] | select(.description.moniker=="'"${MONIKER}"'")')

echo $VALIDATOR
echo "Validator queried !"
if [[ -z "${VALIDATOR}" ]]; then
$BIN tx staking create-validator \
--amount "${STAKE_AMOUNT}seda" \
--moniker "${MONIKER}" \
--pubkey $($BIN tendermint show-validator) \
--commission-rate "${COMMISSION_RATE}" \
--commission-max-rate "$COMMISSION_MAX_RATE" \
--commission-max-change-rate "${COMMISSION_MAX_CHANGE_RATE}" \
--min-self-delegation "${MINIMAL_SELF_DELETAGION}"\
--from "${KEY_NAME}" \
--keyring-backend "${KEYRING}"
echo "Creating validator ..."
# (echo $KEYPASSWD) | $BIN tx staking create-validator --amount 10000000seda --pubkey $($BIN tendermint show-validator) --from $KEY_NAME --moniker $MONIKER --min-self-delegation 1 --chain-id $CHAIN_ID --commission-rate $COMMISSION_RATE --commission-max-change-rate $COMMISSION_MAX_CHANGE_RATE --commission-max-rate $COMMISSION_MAX_RATE
(echo $KEYPASSWD; echo -y) | $BIN tx staking create-validator \
--amount=1000000seda\
--pubkey=$($BIN tendermint show-validator) \
--moniker=$MONIKER \
--chain-id=$CHAIN_ID \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.01" \
--gas="auto" \
--gas-adjustment="1.2" \
--gas-prices="0.0025seda" \
--from=$KEY_NAME \
--min-self-delegation 1 \
--yes
else
echo "Validator already exists"
exit 1
fi

# Start the node
echo "Starting node ..."
$BIN start


#$BIN start

0 comments on commit 3e4c624

Please sign in to comment.