-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ build/ | |
.vscode/ | ||
|
||
dist/ | ||
data/ |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/bin/sh | ||
|
||
# Console log text colour | ||
red=`tput setaf 9` | ||
green=`tput setaf 10` | ||
blue=`tput setaf 12` | ||
reset=`tput sgr0` | ||
|
||
echo_info () { | ||
echo "${blue}" | ||
echo "$1" | ||
echo "${reset}" | ||
} | ||
|
||
echo_error () { | ||
echo "${red}" | ||
echo "$1" | ||
echo "${reset}" | ||
} | ||
|
||
echo_success () { | ||
echo "${green}" | ||
echo "$1" | ||
echo "${reset}" | ||
} | ||
|
||
# Set localnet settings | ||
BINARY=./build/archwayd | ||
CHAIN_ID=localnet-1 | ||
CHAIN_DIR=./data | ||
VALIDATOR_MNEMONIC="guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host" | ||
DEVELOPER_MNEMONIC="friend excite rough reopen cover wheel spoon convince island path clean monkey play snow number walnut pull lock shoot hurry dream divide concert discover" | ||
USER_MNEMONIC="any giant turtle pioneer frequent frown harvest ancient episode junior vocal rent shrimp icon idle echo suspect clean cage eternal sample post heavy enough" | ||
GENESIS_COINS=1000000000000000000000000000000000000stake | ||
|
||
setup_chain () { | ||
# Stop archwayd if it is already running | ||
if pgrep -x "$BINARY" >/dev/null; then | ||
echo_error "Terminating $BINARY..." | ||
killall archwayd | ||
fi | ||
|
||
# Remove previous data | ||
echo_info "Removing previous chain data from $CHAIN_DIR/$CHAIN_ID..." | ||
rm -rf $CHAIN_DIR/$CHAIN_ID | ||
|
||
|
||
# Initialize archwayd with "localnet-1" chain id | ||
echo_info "Initializing $CHAIN_ID..." | ||
if $BINARY --home $CHAIN_DIR/$CHAIN_ID init test --chain-id=$CHAIN_ID; then | ||
echo_success "Successfully initialized $CHAIN_ID" | ||
else | ||
echo_error "Failed to initialize $CHAIN_ID" | ||
fi | ||
|
||
# Modify config for development | ||
config="$CHAIN_DIR/$CHAIN_ID/config/config.toml" | ||
if [ "$(uname)" = "Linux" ]; then | ||
sed -i "s/cors_allowed_origins = \[\]/cors_allowed_origins = [\"*\"]/g" $config | ||
else | ||
sed -i '' "s/cors_allowed_origins = \[\]/cors_allowed_origins = [\"*\"]/g" $config | ||
fi | ||
# modify genesis params for localnet ease of use | ||
genesis="$CHAIN_DIR/$CHAIN_ID/config/genesis.json" | ||
# x/gov params change | ||
# reduce voting period to 2 minutes | ||
contents="$(jq '.app_state.gov.voting_params.voting_period = "120s"' $genesis)" && echo "${contents}" > $genesis | ||
echo_info "Set x/gov voting period to 120 seconds" | ||
# reduce minimum deposit amount to 10stake | ||
contents="$(jq '.app_state.gov.deposit_params.min_deposit[0].amount = "10"' $genesis)" && echo "${contents}" > $genesis | ||
echo_info "Set x/gov proposal min deposit amount to 10 stake" | ||
# reduce deposit period to 20seconds | ||
contents="$(jq '.app_state.gov.deposit_params.max_deposit_period = "20s"' $genesis)" && echo "${contents}" > $genesis | ||
echo_info "Set x/gov proposal max deposit period to 20 seconds" | ||
|
||
|
||
# Adding users | ||
echo_info "Adding genesis accounts..." | ||
echo_info "1. validator" | ||
echo $VALIDATOR_MNEMONIC | $BINARY --home $CHAIN_DIR/$CHAIN_ID keys add validator --recover --keyring-backend test | ||
$BINARY --home $CHAIN_DIR/$CHAIN_ID add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAIN_ID keys show validator --keyring-backend test -a) $GENESIS_COINS | ||
echo_info "2. developer" | ||
echo $DEVELOPER_MNEMONIC | $BINARY --home $CHAIN_DIR/$CHAIN_ID keys add developer --recover --keyring-backend test | ||
$BINARY --home $CHAIN_DIR/$CHAIN_ID add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAIN_ID keys show developer --keyring-backend test -a) $GENESIS_COINS | ||
echo_info "3. user" | ||
echo $USER_MNEMONIC | $BINARY --home $CHAIN_DIR/$CHAIN_ID keys add user --recover --keyring-backend test | ||
$BINARY --home $CHAIN_DIR/$CHAIN_ID add-genesis-account $($BINARY --home $CHAIN_DIR/$CHAIN_ID keys show user --keyring-backend test -a) $GENESIS_COINS | ||
|
||
|
||
# Creating gentx | ||
echo_info "Creating gentx for validator..." | ||
$BINARY --home $CHAIN_DIR/$CHAIN_ID gentx validator 100000000000000000000000stake --chain-id $CHAIN_ID --fees 950000000000000000000stake --keyring-backend test | ||
|
||
|
||
# Collecting gentx | ||
echo_info "Collecting gentx..." | ||
if $BINARY --home $CHAIN_DIR/$CHAIN_ID collect-gentxs; then | ||
echo_success "Successfully collected genesis txs into genesis.json" | ||
else | ||
echo_error "Failed to collect genesis txs" | ||
fi | ||
|
||
|
||
# Validating genesis | ||
echo_info "Validating genesis..." | ||
if $BINARY --home $CHAIN_DIR/$CHAIN_ID validate-genesis; then | ||
echo_success "Successfully validated genesis" | ||
else | ||
echo_error "Failed to validate genesis" | ||
fi | ||
} | ||
|
||
if [ "$1" != "continue" ] ;then | ||
setup_chain | ||
fi | ||
|
||
# Starting chain | ||
echo_info "Starting chain..." | ||
$BINARY --home $CHAIN_DIR/$CHAIN_ID start |
Empty file.