diff --git a/dockers/sedad.Dockerfile b/dockers/sedad.Dockerfile index 3444cc1d..b2df0594 100644 --- a/dockers/sedad.Dockerfile +++ b/dockers/sedad.Dockerfile @@ -16,7 +16,7 @@ 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 @@ -24,5 +24,7 @@ RUN apt-get update && apt-get install ca-certificates -y \ 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"] \ No newline at end of file diff --git a/scripts/validator_setup/validator_setup.sh b/scripts/validator_setup/validator_setup.sh index 1cc3cbc9..557a8275 100755 --- a/scripts/validator_setup/validator_setup.sh +++ b/scripts/validator_setup/validator_setup.sh @@ -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 \ No newline at end of file