Validator/nysa #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gentx checker | |
on: | |
pull_request: | |
types: [ready_for_review] | |
push: | |
paths: | |
- govgen-1/gentx/*.json | |
branches: | |
- "ci/gentx" | |
env: | |
GOVGEND_URL: "https://atomone.fra1.digitaloceanspaces.com/govgen/bin/govgend_linux_amd64_v1/govgend" | |
GENESIS_URL: "https://atomone.fra1.digitaloceanspaces.com/govgen/govgen-1/genesis.json" | |
MUST_STAKED_AMOUNT: "1000000" | |
jobs: | |
check-gentx: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get changed files | |
id: files | |
uses: jitterbit/get-changed-files@v1 | |
- name: Check gentx values | |
run: | | |
for f in ${{ steps.files.outputs.all }}; do | |
echo "file: $f" | |
if [[ "$f" == "govgen-1/gentx/*.json" ]]; then | |
echo "checking file: $f" | |
COMMISSION_RATE=$(cat $f | jq -r '.body.messages[0].commission.rate') | |
COMMISSION_MAX_RATE=$(cat $f | jq -r '.body.messages[0].commission.max_rate') | |
COMMISSION_MAX_CHANGE_RATE=$(cat $f | jq -r '.body.messages[0].commission.max_change_rate') | |
STAKED_AMOUNT=$(cat $f | jq -r '.body.messages[0].value.amount') | |
# bc return 1 when success | |
echo "$COMMISSION_RATE == 0" | bc && echo "commission_rate must be 0" && exit 1 | |
echo "$COMMISSION_MAX_RATE == 0" | bc && echo "commission_max_rate must be 0" && exit 1 | |
echo "$COMMISSION_MAX_CHANGE_RATE == 0" | bc && echo "commission_max_change_rate must be 0" && exit 1 | |
echo "$STAKED_AMOUNT == $MUST_STAKED_AMOUNT | bc" && echo "staked amount must be $MUST_STAKED_AMOUNT" && exit 1 | |
fi | |
done | |
validate-gentx: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download govgend | |
run: | | |
wget -O /usr/bin/govgend ${GOVGEND_URL} | |
chmod +x /usr/bin/govgend | |
- name: Collect gentxs | |
run: | | |
govgend init github-ci --chain-id govgen-1 | |
wget -O /root/.govgen/config/genesis.json $GENESIS_URL | |
for f in "govgen-1/gentx/*.json"; do | |
ADDR=$(cat $f | jq -r '.body.messages[0].delegator_address') | |
govgend add-genesis-account $ADDR 10000000ugovgen | |
done | |
govgend collect-gentx --gentx-dir ./govgen-1/gentx | |
- name: Validate genesis | |
run: | | |
govgend validate-genesis |