|
| 1 | +#!/bin/bash |
| 2 | +# Run this script to quickly install, setup, and run the current version of the network without docker. |
| 3 | +# |
| 4 | +# Push Test Net: |
| 5 | +# pn1: |
| 6 | +# CHAIN_ID="push_501-1" MONIKER=pn1 HOME_DIR="~/.pchain" BLOCK_TIME="1000ms" CLEAN=true ./make_node.sh |
| 7 | +# |
| 8 | +# Examples: |
| 9 | +# CHAIN_ID="push_501-1" MONIKER=pn1 HOME_DIR="~/.pchain" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh |
| 10 | +# CHAIN_ID="localchain_9000-2" HOME_DIR="~/.pchain" CLEAN=true RPC=36657 REST=2317 PROFF=6061 P2P=36656 GRPC=8090 GRPC_WEB=8091 ROSETTA=8081 BLOCK_TIME="500ms" sh scripts/test_node.sh |
| 11 | +shopt -s expand_aliases |
| 12 | +set -eu |
| 13 | + |
| 14 | +export KEY1="acc1" |
| 15 | +export KEY2="acc2" |
| 16 | +export KEY3="acc3" |
| 17 | + |
| 18 | +export CHAIN_ID=${CHAIN_ID:-"localchain_9000-1"} |
| 19 | +export MONIKER=${MONIKER:-"localvalidator"} |
| 20 | +export KEYALGO="eth_secp256k1" |
| 21 | +export KEYRING=${KEYRING:-"test"} |
| 22 | +export HOME_DIR=$(eval echo "${HOME_DIR:-"~/.pchain"}") |
| 23 | +export BINARY=${BINARY:-pchaind} |
| 24 | +export DENOM=${DENOM:-npush} |
| 25 | + |
| 26 | +export CLEAN=${CLEAN:-"false"} |
| 27 | +export RPC=${RPC:-"26657"} |
| 28 | +export REST=${REST:-"1317"} |
| 29 | +export PROFF=${PROFF:-"6060"} |
| 30 | +export P2P=${P2P:-"26656"} |
| 31 | +export GRPC=${GRPC:-"9090"} |
| 32 | +export GRPC_WEB=${GRPC_WEB:-"9091"} |
| 33 | +export ROSETTA=${ROSETTA:-"8080"} |
| 34 | +export BLOCK_TIME=${BLOCK_TIME:-"1s"} |
| 35 | + |
| 36 | +# if which binary does not exist, install it |
| 37 | +if [ -z `which $BINARY` ]; then |
| 38 | + make install |
| 39 | + |
| 40 | + if [ -z `which $BINARY` ]; then |
| 41 | + echo "Ensure $BINARY is installed and in your PATH" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | +fi |
| 45 | + |
| 46 | +alias BINARY="$BINARY --home=$HOME_DIR" |
| 47 | + |
| 48 | +command -v $BINARY > /dev/null 2>&1 || { echo >&2 "$BINARY command not found. Ensure this is setup / properly installed in your GOPATH (make install)."; exit 1; } |
| 49 | +command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; } |
| 50 | + |
| 51 | +set_config() { |
| 52 | + $BINARY config set client chain-id $CHAIN_ID |
| 53 | + $BINARY config set client keyring-backend $KEYRING |
| 54 | +} |
| 55 | +set_config |
| 56 | + |
| 57 | + |
| 58 | +from_scratch () { |
| 59 | + # Fresh install on current branch |
| 60 | +# make install |
| 61 | + |
| 62 | + # remove existing daemon files. |
| 63 | + if [ ${#HOME_DIR} -le 2 ]; then |
| 64 | + echo "HOME_DIR must be more than 2 characters long" |
| 65 | + return |
| 66 | + fi |
| 67 | + rm -rf $HOME_DIR && echo "Removed $HOME_DIR" |
| 68 | + |
| 69 | + # reset values if not set already after whipe |
| 70 | + set_config |
| 71 | + |
| 72 | + add_key() { |
| 73 | + key=$1 |
| 74 | + mnemonic=$2 |
| 75 | + echo $mnemonic | BINARY keys add $key --keyring-backend $KEYRING --algo $KEYALGO --recover |
| 76 | + } |
| 77 | + |
| 78 | + # NOTE: mnemonics can be created via: |
| 79 | + # pushchaind keys add acc1 |
| 80 | + |
| 81 | + # push1ss5j8c8j453uecnczt3ms23lze30kxt4pzfvh9 |
| 82 | + add_key $KEY1 "!!!PUT MNEMONIC1 HERE!!!" |
| 83 | + # push1j55s4vpvmncruakqhj2k2fywnc9mvsuhcap28q |
| 84 | + add_key $KEY2 "!!!PUT MNEMONIC2 HERE!!!" |
| 85 | + # push1fgaewhyd9fkwtqaj9c233letwcuey6dgly9gv9 |
| 86 | + add_key $KEY3 "!!!PUT MNEMONIC3 HERE!!!" |
| 87 | + |
| 88 | + BINARY init $MONIKER --chain-id $CHAIN_ID --default-denom $DENOM |
| 89 | + |
| 90 | + update_test_genesis () { |
| 91 | + cat $HOME_DIR/config/genesis.json | jq "$1" > $HOME_DIR/config/tmp_genesis.json && mv $HOME_DIR/config/tmp_genesis.json $HOME_DIR/config/genesis.json |
| 92 | + } |
| 93 | + |
| 94 | + # === CORE MODULES === |
| 95 | + |
| 96 | + # Block |
| 97 | + update_test_genesis '.consensus_params["block"]["max_gas"]="100000000"' |
| 98 | + |
| 99 | + # Gov |
| 100 | + update_test_genesis `printf '.app_state["gov"]["params"]["min_deposit"]=[{"denom":"%s","amount":"1000000"}]' $DENOM` |
| 101 | + update_test_genesis '.app_state["gov"]["params"]["voting_period"]="30s"' |
| 102 | + update_test_genesis '.app_state["gov"]["params"]["expedited_voting_period"]="15s"' |
| 103 | + |
| 104 | + update_test_genesis `printf '.app_state["evm"]["params"]["evm_denom"]="%s"' $DENOM` |
| 105 | + update_test_genesis '.app_state["evm"]["params"]["active_static_precompiles"]=["0x0000000000000000000000000000000000000100","0x0000000000000000000000000000000000000400","0x0000000000000000000000000000000000000800","0x0000000000000000000000000000000000000801","0x0000000000000000000000000000000000000802","0x0000000000000000000000000000000000000803","0x0000000000000000000000000000000000000804","0x0000000000000000000000000000000000000805"]' |
| 106 | + update_test_genesis '.app_state["erc20"]["params"]["native_precompiles"]=["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"]' # https://eips.ethereum.org/EIPS/eip-7528 |
| 107 | + update_test_genesis `printf '.app_state["erc20"]["token_pairs"]=[{contract_owner:1,erc20_address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",denom:"%s",enabled:true}]' $DENOM` |
| 108 | + update_test_genesis '.app_state["feemarket"]["params"]["no_base_fee"]=true' |
| 109 | + update_test_genesis '.app_state["feemarket"]["params"]["base_fee"]="0.000000000000000000"' |
| 110 | + |
| 111 | + # staking |
| 112 | + update_test_genesis `printf '.app_state["staking"]["params"]["bond_denom"]="%s"' $DENOM` |
| 113 | + update_test_genesis '.app_state["staking"]["params"]["min_commission_rate"]="0.050000000000000000"' |
| 114 | + |
| 115 | + # mint |
| 116 | + update_test_genesis `printf '.app_state["mint"]["params"]["mint_denom"]="%s"' $DENOM` |
| 117 | + |
| 118 | + # crisis |
| 119 | + update_test_genesis `printf '.app_state["crisis"]["constant_fee"]={"denom":"%s","amount":"1000"}' $DENOM` |
| 120 | + |
| 121 | + ## abci |
| 122 | + update_test_genesis '.consensus["params"]["abci"]["vote_extensions_enable_height"]="1"' |
| 123 | + |
| 124 | + # === CUSTOM MODULES === |
| 125 | + # tokenfactory |
| 126 | + update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_fee"]=[]' |
| 127 | + update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_gas_consume"]=100000' |
| 128 | + |
| 129 | + |
| 130 | + # Allocate genesis accounts |
| 131 | + # total: 10 000000000 . 000000000 000000000 |
| 132 | + BINARY genesis add-genesis-account $KEY1 5000000000000000000000000000$DENOM,100000000test --keyring-backend $KEYRING --append |
| 133 | + BINARY genesis add-genesis-account $KEY2 3000000000000000000000000000$DENOM,90000000test --keyring-backend $KEYRING --append |
| 134 | + BINARY genesis add-genesis-account $KEY3 2000000000000000000000000000$DENOM,90000000test --keyring-backend $KEYRING --append |
| 135 | + |
| 136 | + # Sign genesis transaction |
| 137 | + # 10 000 . 000000000 000000000 |
| 138 | + BINARY genesis gentx $KEY1 10000000000000000000000$DENOM --gas-prices 0${DENOM} --keyring-backend $KEYRING --chain-id $CHAIN_ID |
| 139 | + |
| 140 | + BINARY genesis collect-gentxs |
| 141 | + |
| 142 | + BINARY genesis validate-genesis |
| 143 | + err=$? |
| 144 | + if [ $err -ne 0 ]; then |
| 145 | + echo "Failed to validate genesis" |
| 146 | + return |
| 147 | + fi |
| 148 | +} |
| 149 | + |
| 150 | +# check if CLEAN is not set to false |
| 151 | +if [ "$CLEAN" != "false" ]; then |
| 152 | + echo "Starting from a clean state" |
| 153 | + from_scratch |
| 154 | +fi |
| 155 | + |
| 156 | +echo "Starting node..." |
| 157 | + |
| 158 | +# Opens the RPC endpoint to outside connections |
| 159 | +sed -i -e 's/laddr = "tcp:\/\/127.0.0.1:26657"/c\laddr = "tcp:\/\/0.0.0.0:'$RPC'"/g' $HOME_DIR/config/config.toml |
| 160 | +sed -i -e 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["\*"\]/g' $HOME_DIR/config/config.toml |
| 161 | + |
| 162 | +# REST endpoint |
| 163 | +sed -i -e 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:'$REST'"/g' $HOME_DIR/config/app.toml |
| 164 | +sed -i -e 's/enable = false/enable = true/g' $HOME_DIR/config/app.toml |
| 165 | +sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $HOME_DIR/config/app.toml |
| 166 | + |
| 167 | +# peer exchange |
| 168 | +sed -i -e 's/pprof_laddr = "localhost:6060"/pprof_laddr = "localhost:'$PROFF'"/g' $HOME_DIR/config/config.toml |
| 169 | +sed -i -e 's/laddr = "tcp:\/\/0.0.0.0:26656"/laddr = "tcp:\/\/0.0.0.0:'$P2P'"/g' $HOME_DIR/config/config.toml |
| 170 | + |
| 171 | +# GRPC |
| 172 | +sed -i -e 's/address = "localhost:9090"/address = "0.0.0.0:'$GRPC'"/g' $HOME_DIR/config/app.toml |
| 173 | +sed -i -e 's/address = "localhost:9091"/address = "0.0.0.0:'$GRPC_WEB'"/g' $HOME_DIR/config/app.toml |
| 174 | + |
| 175 | +# Rosetta Api |
| 176 | +sed -i -e 's/address = ":8080"/address = "0.0.0.0:'$ROSETTA'"/g' $HOME_DIR/config/app.toml |
| 177 | + |
| 178 | +# Faster blocks |
| 179 | +sed -i -e 's/timeout_commit = "5s"/timeout_commit = "'$BLOCK_TIME'"/g' $HOME_DIR/config/config.toml |
| 180 | + |
| 181 | +BINARY start --pruning=nothing --minimum-gas-prices=0$DENOM --rpc.laddr="tcp://0.0.0.0:$RPC" --json-rpc.api=eth,txpool,personal,net,debug,web3 --chain-id="$CHAIN_ID" |
0 commit comments