fetchai / fetchd

Source code for Fetch.ai blockchain nodes
Other
100 stars 38 forks source link

refactor: New devgenesis.py #312

Closed MissingNO57 closed 5 months ago

MissingNO57 commented 1 year ago

Rewritten devgensis.sh to devgenesis.py

usage: devgenesis.py [-h] [--home_path HOME_PATH]
                     [--validator_key_name VALIDATOR_KEY_NAME]
                     [--staking_denom STAKING_DENOM] [--chain_id CHAIN_ID]
                     [--voting_period VOTING_PERIOD]
                     genesis_export

This script updates an exported genesis from a running chain to be used to run
on a single validator local node. It will take the first validator and jail
all the others and replace the validator pubkey and the nodekey with the one
found in the node_home_dir folder if unspecified, node_home_dir default to the
~/.fetchd/ folder. this folder must exists and contains the files created by
the "fetchd init" command. The updated genesis will be written under
node_home_dir/config/genesis.json, allowing the local chain to be started
with:

positional arguments:
  genesis_export        The path to the genesis export

optional arguments:
  -h, --help            show this help message and exit
  --home_path HOME_PATH
                        The path to the local node data i.e. ~/.fetchd
  --validator_key_name VALIDATOR_KEY_NAME
                        The name of the local key to use for the validator
  --staking_denom STAKING_DENOM
                        The staking denom
  --chain_id CHAIN_ID   New chain ID to be set
  --voting_period VOTING_PERIOD
                        The new voting period to be set

Example:

# Get Dorado genesis file
curl https://storage.googleapis.com/fetch-ai-testnet-genesis/genesis-dorado-827201.json --output dorado_genesis.json

# Prepare fetchd node
rm -rf ~/.fetchd
fetchd init my-first-fetch-node --chain-id test-1
./scripts/devgenesis.py dorado_genesis.json --validator_key_name validator --staking_denom atestfet --chain_id test-1 --voting_period 60s 
fetchd start

Open another terminal

# Create proposal
UPGRADE_HEIGHT=$(fetchd query block | jq '.block.header.height' | tr -d '"' | awk '{print int($0+30)}')
fetchd tx gov submit-proposal software-upgrade "fetchd-v0.10.7" --description somedescription --title sometitle --upgrade-info someinfo --upgrade-height $UPGRADE_HEIGHT --deposit 2048000000000000000000atestfet --chain-id test-1 --from validator 

# Vote on proposal
PROPOSAL_ID=$(fetchd query gov proposals --output json --reverse | jq -r '.proposals[0].proposal_id')
fetchd tx gov vote $PROPOSAL_ID yes --from validator --chain-id test-1

fetchd query gov tally $PROPOSAL_ID
fetchd query gov proposal $PROPOSAL_ID
github-actions[bot] commented 1 year ago

Visit the preview URL for this PR (updated for commit 0c2e43a):

https://fetch-docs-preview--pr312-feature-devgenesis-p-lbafin7i.web.app

(expires Tue, 09 May 2023 10:30:34 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f2de39fd4e81249941960b74fbab0a62d90d69f8