forked from cerc-io/laconicd
Integrate go-nitro
- Add nitro server and x/nitro module
- wire go-nitro p2p through cometbft
- Add distsig server, currently WIP
- integrate DKG and DSS schemes into ABCI methods
- Remove deprecated features
- crisis module
- module invariants
- Update to use newer SDK patterns
- upgrade sdk to v0.53.x
- custom address codec
- expand use of depinject
- migrate e2e tests to system tests
- use depinject to set up integration tests
- change reserved protobuf field name `cerc.registry.v1.Record.type`
- Revise & add documentation
- TransferCoinsToModuleAccount: clarify function
- Update init.sh script
This commit is contained in:
1 parent
a8ebc0aceb
commit
5aa2594073
179 files changed
+15631
-3058
No files matched your search
+70
-118
@@ -1,153 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
KEY="alice"
|
||||
LACONIC_BIN=${LACONIC_BIN:-laconicd}
|
||||
LACONIC_HOME="${LACONIC_HOME:-$HOME/.laconicd}"
|
||||
|
||||
KEYNAME="node_key"
|
||||
CHAINID=${CHAINID:-"laconic_9000-1"}
|
||||
MONIKER=${MONIKER:-"localtestnet"}
|
||||
KEYRING=${KEYRING:-"test"}
|
||||
DENOM=${DENOM:-"alnt"}
|
||||
BALANCE=${BALANCE:-"1000000000000000000000000000000"} # 10^32 alnt
|
||||
STAKING_AMOUNT=${STAKING_AMOUNT:-"1000000000000000"} # 10^15 alnt
|
||||
MIN_GAS_PRICE=${MIN_GAS_PRICE:-"0.001"}
|
||||
ALLOCATION_AMOUNT=1000000000000000000000000000000 # 10^30 alnt | 10^12 lnt
|
||||
LOGLEVEL=${LOGLEVEL:-"info"}
|
||||
|
||||
P2P_EXTERNAL_PORT=${P2P_EXTERNAL_PORT:-26656}
|
||||
|
||||
input_genesis_file=${GENESIS_FILE}
|
||||
import_private_key=${PRIVATE_KEY}
|
||||
|
||||
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data" ]; then
|
||||
# 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
|
||||
}
|
||||
laconicd="$LACONIC_BIN --home=$LACONIC_HOME --log_level=$LOGLEVEL"
|
||||
|
||||
# remove existing daemon and client
|
||||
rm -rf $HOME/.laconicd/*
|
||||
set -e
|
||||
|
||||
if [ -n "`which make`" ]; then
|
||||
make install
|
||||
if [ "$1" == "clean" ]; then
|
||||
echo "Clearing existing data directory in $LACONIC_HOME"
|
||||
rm -rf "$LACONIC_HOME"
|
||||
else
|
||||
echo "Using existing database at $LACONIC_HOME. To replace, run '$(basename $0) clean'"
|
||||
fi
|
||||
|
||||
# Create a new home dir if needed
|
||||
if [[ ! -d "$LACONIC_HOME/data/application.db" ]]; then
|
||||
# Import the node key if passed, or generate one
|
||||
if [[ -n "$import_private_key" ]]; then
|
||||
$laconicd keys import-hex $KEYNAME 'b0b0000000000000000000000000000000000000000000000000000000000000'
|
||||
else
|
||||
printf "y\n" | $laconicd keys add $KEYNAME --keyring-backend $KEYRING --no-backup
|
||||
fi
|
||||
|
||||
laconicd config set client chain-id $CHAINID
|
||||
laconicd config set client keyring-backend $KEYRING
|
||||
# Set moniker and chain-id (Moniker can be anything, chain-id must be an integer)
|
||||
$laconicd init $MONIKER --chain-id $CHAINID --default-denom $DENOM
|
||||
else
|
||||
KEYNAME=$($laconicd keys list --list-names --keyring-backend $KEYRING | head -1)
|
||||
fi
|
||||
|
||||
# if $KEY exists it should be deleted
|
||||
laconicd keys add $KEY --keyring-backend $KEYRING
|
||||
|
||||
# Set moniker and chain-id
|
||||
laconicd init $MONIKER --chain-id $CHAINID --default-denom $DENOM
|
||||
if [[ ! -d "$db_path" ]]; then
|
||||
$laconicd config set client chain-id $CHAINID
|
||||
$laconicd config set client keyring-backend $KEYRING
|
||||
|
||||
if [[ -f ${input_genesis_file} ]]; then
|
||||
# Use provided genesis config
|
||||
cp $input_genesis_file $HOME/.laconicd/config/genesis.json
|
||||
cp $input_genesis_file $LACONIC_HOME/config/genesis.json
|
||||
fi
|
||||
|
||||
update_genesis() {
|
||||
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
|
||||
$laconicd genesis validate
|
||||
|
||||
update_comet_config() { # comet config is not supported by confix cli
|
||||
local file="$LACONIC_HOME/config/config.toml"
|
||||
cp -f "$file" "${file}.bak" && tomlq --toml-output ".$1 = $2" "${file}.bak" > "$file"
|
||||
}
|
||||
|
||||
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
|
||||
echo "Setting timers for expiry tests."
|
||||
# disable empty blocks
|
||||
update_comet_config consensus.create_empty_blocks 'false'
|
||||
|
||||
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
|
||||
# Allow requests from any origin
|
||||
update_comet_config rpc.cors_allowed_origins '["*"]'
|
||||
|
||||
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
|
||||
|
||||
if [[ "$ONBOARDING_ENABLED" == "true" ]]; then
|
||||
echo "Enabling onboarding."
|
||||
|
||||
update_genesis '.app_state["onboarding"]["params"]["onboarding_enabled"]=true'
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
# 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"'
|
||||
|
||||
# Set distribution community tax to 1 for disabling staking rewards
|
||||
update_genesis '.app_state["distribution"]["params"]["community_tax"]="1.000000000000000000"'
|
||||
|
||||
echo "Setting high threshold for accepting governance proposal"
|
||||
update_genesis '.app_state["gov"]["params"]["quorum"]="1.000000000000000000"'
|
||||
# Set expedited threshold to 100%
|
||||
update_genesis '.app_state["gov"]["params"]["expedited_threshold"]="1.000000000000000000"'
|
||||
# Set normal threshold to 99% since it needs to be lesser than expedited threshold
|
||||
update_genesis '.app_state["gov"]["params"]["threshold"]="0.990000000000000000"'
|
||||
|
||||
# disable produce empty block
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
else
|
||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
fi
|
||||
|
||||
# Run this to allow requests from any origin
|
||||
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml
|
||||
# Set persistent peers
|
||||
update_comet_config p2p.seeds "\"$P2P_PEERS\""
|
||||
update_comet_config p2p.persistent_peers "\"$P2P_PEERS\""
|
||||
update_comet_config p2p.external_address "\"tcp://127.0.0.1:${P2P_EXTERNAL_PORT}\""
|
||||
update_comet_config p2p.addr_book_strict false
|
||||
|
||||
# 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
|
||||
$laconicd config set app telemetry.enable true
|
||||
$laconicd config set app telemetry.prometheus-retention-time 60
|
||||
update_comet_config instrumentation.prometheus true
|
||||
|
||||
# Allocate genesis accounts (cosmos formatted addresses)
|
||||
laconicd genesis add-genesis-account $KEY ${BALANCE}${DENOM} --keyring-backend $KEYRING
|
||||
# Enable validator distsig
|
||||
$laconicd config set app distsig.enable true
|
||||
$laconicd config set app distsig.longterm-key "$KEYNAME"
|
||||
|
||||
# Sign genesis transaction
|
||||
laconicd genesis gentx $KEY $STAKING_AMOUNT$DENOM --keyring-backend $KEYRING --chain-id $CHAINID
|
||||
|
||||
# Collect genesis tx
|
||||
laconicd genesis collect-gentxs
|
||||
|
||||
# Run this to ensure everything worked and that the genesis file is setup correctly
|
||||
laconicd genesis validate
|
||||
# Nitro config, WIP
|
||||
# $laconicd config set app nitro.use-distsig true # TODO
|
||||
$laconicd config set app nitro.eth-key "$KEYNAME"
|
||||
$laconicd config set app nitro.eth-url "$NITRO_ETH_URL"
|
||||
$laconicd config set app nitro.eth-start-block "$NITRO_ETH_START_BLOCK"
|
||||
$laconicd config set app nitro.eth-na-address "'$NITRO_ADJUDICATOR_ADDRESS'"
|
||||
$laconicd config set app nitro.eth-vpa-address "'$VIRTUAL_PAYMENT_APP_ADDRESS'"
|
||||
$laconicd config set app nitro.eth-ca-address "'$CONSENSUS_APP_ADDRESS'"
|
||||
else
|
||||
echo "Using existing database at $HOME/.laconicd. To replace, run '`basename $0` clean'"
|
||||
echo "Using existing database at $LACONIC_HOME."
|
||||
fi
|
||||
|
||||
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
||||
laconicd start \
|
||||
--pruning=nothing \
|
||||
--log_level $LOGLEVEL \
|
||||
--minimum-gas-prices=$MIN_GAS_PRICE$DENOM \
|
||||
--api.enable \
|
||||
# TODO new pruning config
|
||||
$laconicd start \
|
||||
--server.minimum-gas-prices="1$DENOM" \
|
||||
--rpc.laddr="tcp://0.0.0.0:26657" \
|
||||
--gql-server --gql-playground
|
||||
--grpc.address="127.0.0.1:9091" \
|
||||
--gql.enable --gql.playground
|
||||
Reference in new issue
Block a user