2024-02-01 04:48:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
KEY="alice"
|
2024-08-07 11:25:01 +00:00
|
|
|
CHAINID=${CHAINID:-"laconic_9000-1"}
|
|
|
|
MONIKER=${MONIKER:-"localtestnet"}
|
|
|
|
KEYRING=${KEYRING:-"test"}
|
|
|
|
DENOM=${DENOM:-"alnt"}
|
|
|
|
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"}
|
2024-08-08 07:14:36 +00:00
|
|
|
LOGLEVEL=${LOGLEVEL:-"info"}
|
2024-03-07 05:10:41 +00:00
|
|
|
|
2024-08-01 11:52:47 +00:00
|
|
|
input_genesis_file=${GENESIS_FILE}
|
|
|
|
|
2024-10-22 09:54:33 +00:00
|
|
|
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data" ]; then
|
2024-03-07 05:10:41 +00:00
|
|
|
# validate dependencies are installed
|
|
|
|
command -v jq > /dev/null 2>&1 || {
|
|
|
|
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# remove existing daemon and client
|
2024-04-01 09:57:26 +00:00
|
|
|
rm -rf $HOME/.laconicd/*
|
2024-03-07 05:10:41 +00:00
|
|
|
|
|
|
|
if [ -n "`which make`" ]; then
|
|
|
|
make install
|
|
|
|
fi
|
|
|
|
|
2024-04-01 09:57:26 +00:00
|
|
|
laconicd config set client chain-id $CHAINID
|
2024-04-01 12:19:54 +00:00
|
|
|
laconicd config set client keyring-backend $KEYRING
|
2024-03-07 05:10:41 +00:00
|
|
|
|
|
|
|
# if $KEY exists it should be deleted
|
2024-04-01 09:57:26 +00:00
|
|
|
laconicd keys add $KEY --keyring-backend $KEYRING
|
2024-03-07 05:10:41 +00:00
|
|
|
|
2024-10-22 09:54:33 +00:00
|
|
|
# Set moniker and chain-id
|
2024-08-07 11:25:01 +00:00
|
|
|
laconicd init $MONIKER --chain-id $CHAINID --default-denom $DENOM
|
2024-03-07 05:10:41 +00:00
|
|
|
|
2024-08-08 07:14:36 +00:00
|
|
|
if [[ -f ${input_genesis_file} ]]; then
|
2024-08-01 11:52:47 +00:00
|
|
|
# Use provided genesis config
|
|
|
|
cp $input_genesis_file $HOME/.laconicd/config/genesis.json
|
|
|
|
fi
|
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
update_genesis() {
|
2024-04-01 09:57:26 +00:00
|
|
|
jq "$1" $HOME/.laconicd/config/genesis.json > $HOME/.laconicd/config/tmp_genesis.json &&
|
|
|
|
mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
2024-03-07 05:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
|
|
|
|
echo "Setting timers for expiry tests."
|
|
|
|
|
|
|
|
update_genesis '.app_state["registry"]["params"]["record_rent_duration"]="60s"'
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="60s"'
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
|
|
|
|
echo "Enabling auction and setting timers."
|
|
|
|
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true'
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="300s"'
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"'
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"'
|
|
|
|
fi
|
|
|
|
|
2024-07-04 13:40:10 +00:00
|
|
|
if [[ "$ONBOARDING_ENABLED" == "true" ]]; then
|
2024-09-05 07:33:48 +00:00
|
|
|
echo "Enabling onboarding."
|
2024-07-04 13:40:10 +00:00
|
|
|
|
|
|
|
update_genesis '.app_state["onboarding"]["params"]["onboarding_enabled"]=true'
|
|
|
|
fi
|
|
|
|
|
2024-08-08 07:14:36 +00:00
|
|
|
if [[ "$AUTHORITY_AUCTION_ENABLED" == "true" ]]; then
|
|
|
|
echo "Enabling authority auctions."
|
|
|
|
update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $AUTHORITY_AUCTION_COMMITS_DURATION ]]; then
|
|
|
|
echo "Setting authority_auction_commits_duration to $AUTHORITY_AUCTION_COMMITS_DURATION seconds."
|
|
|
|
update_genesis ".app_state[\"registry\"][\"params\"][\"authority_auction_commits_duration\"]=\"${AUTHORITY_AUCTION_COMMITS_DURATION}s\""
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $AUTHORITY_AUCTION_REVEALS_DURATION ]]; then
|
|
|
|
echo "Setting authority_auction_reveals_duration to $AUTHORITY_AUCTION_REVEALS_DURATION seconds."
|
|
|
|
update_genesis ".app_state[\"registry\"][\"params\"][\"authority_auction_reveals_duration\"]=\"${AUTHORITY_AUCTION_REVEALS_DURATION}s\""
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $AUTHORITY_GRACE_PERIOD ]]; then
|
|
|
|
echo "Setting authority_grace_period to $AUTHORITY_GRACE_PERIOD seconds."
|
|
|
|
update_genesis ".app_state[\"registry\"][\"params\"][\"authority_grace_period\"]=\"${AUTHORITY_GRACE_PERIOD}s\""
|
|
|
|
fi
|
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
# increase block time (?)
|
|
|
|
update_genesis '.consensus["params"]["block"]["time_iota_ms"]="1000"'
|
|
|
|
|
|
|
|
# Set gas limit in genesis
|
|
|
|
update_genesis '.consensus["params"]["block"]["max_gas"]="10000000"'
|
|
|
|
|
|
|
|
# disable produce empty block
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
2024-04-01 09:57:26 +00:00
|
|
|
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
2024-03-07 05:10:41 +00:00
|
|
|
else
|
2024-04-01 09:57:26 +00:00
|
|
|
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
2024-03-07 05:10:41 +00:00
|
|
|
fi
|
2024-07-30 11:05:58 +00:00
|
|
|
|
2024-07-17 09:59:59 +00:00
|
|
|
# Run this to allow requests from any origin
|
|
|
|
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml
|
2024-03-07 05:10:41 +00:00
|
|
|
|
2024-04-11 07:56:50 +00:00
|
|
|
# Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus)
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
sed -i '' 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
|
|
|
sed -i '' 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml
|
|
|
|
sed -i '' 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml
|
|
|
|
else
|
|
|
|
sed -i 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
|
|
|
sed -i 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml
|
|
|
|
sed -i 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml
|
|
|
|
fi
|
|
|
|
|
2024-03-07 05:10:41 +00:00
|
|
|
# Allocate genesis accounts (cosmos formatted addresses)
|
2024-07-30 11:05:58 +00:00
|
|
|
# 10^30 alnt | 10^12 lnt
|
2024-08-07 11:25:01 +00:00
|
|
|
laconicd genesis add-genesis-account $KEY 1000000000000000000000000000000$DENOM --keyring-backend $KEYRING
|
2024-03-07 05:10:41 +00:00
|
|
|
|
|
|
|
# Sign genesis transaction
|
2024-08-07 11:25:01 +00:00
|
|
|
# 10^15 alnt
|
|
|
|
laconicd genesis gentx $KEY $STAKING_AMOUNT$DENOM --keyring-backend $KEYRING --chain-id $CHAINID
|
2024-03-07 05:10:41 +00:00
|
|
|
|
|
|
|
# Collect genesis tx
|
2024-04-01 09:57:26 +00:00
|
|
|
laconicd genesis collect-gentxs
|
2024-03-07 05:10:41 +00:00
|
|
|
|
|
|
|
# Run this to ensure everything worked and that the genesis file is setup correctly
|
2024-04-01 09:57:26 +00:00
|
|
|
laconicd genesis validate
|
2024-03-07 05:10:41 +00:00
|
|
|
else
|
2024-04-01 09:57:26 +00:00
|
|
|
echo "Using existing database at $HOME/.laconicd. To replace, run '`basename $0` clean'"
|
2024-03-07 05:10:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
2024-04-01 09:57:26 +00:00
|
|
|
laconicd start \
|
2024-03-07 05:10:41 +00:00
|
|
|
--pruning=nothing \
|
|
|
|
--log_level $LOGLEVEL \
|
2024-08-07 11:25:01 +00:00
|
|
|
--minimum-gas-prices=1$DENOM \
|
2024-03-07 05:10:41 +00:00
|
|
|
--api.enable \
|
2024-03-12 12:06:24 +00:00
|
|
|
--rpc.laddr="tcp://0.0.0.0:26657" \
|
2024-03-07 05:10:41 +00:00
|
|
|
--gql-server --gql-playground
|