Skip to content

Commit

Permalink
chore(scripts): expedited voting period flag
Browse files Browse the repository at this point in the history
  • Loading branch information
desislavva authored and Lockwarr committed Jul 12, 2024
1 parent 59225f5 commit aec4f56
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
10 changes: 9 additions & 1 deletion scripts/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ __print_usage() {
[--validator-stake <tokens_validator_stakes>]
[--gov-voting-period <voting_period>]
[--gov-max-deposit-period <max_deposit_period - XXs>]
[--gov-expedited-voting-period <gov_expedited_voting_period>]
[--staking-max-validators <staking_max_validators>]
[--feerefunder-ack-fee-min <feerefunder_ack_fee_min_amount>]
[--feerefunder-timeout-fee-min <feerefunder_timeout_fee_min_amount>]
Expand All @@ -50,6 +51,7 @@ VAL_STAKE="1000000""$NATIVE_CURRENCY"
OUTPUT_FILE=""
GOV_VOTING_PERIOD="43200s"
GOV_MAX_DEPOSIT_PERIOD="43200s"
GOV_EXPEDITED_VOTING_PERIOD="2m"
STAKING_MAX_VALIDATORS="40"
FEEREFUNDER_ACK_FEE_MIN="1"
FEEREFUNDER_TIMEOUT_FEE_MIN="1"
Expand Down Expand Up @@ -147,6 +149,12 @@ while [[ $# -gt 0 ]]; do
shift
;;

--gov-expedited-voting-period)
GOV_EXPEDITED_VOTING_PERIOD="$2"
shift
shift
;;

--staking-max-validators)
STAKING_MAX_VALIDATORS="$2"
shift
Expand Down Expand Up @@ -206,7 +214,7 @@ if [[ "$COMMAND" == "$COMMAND_FULL_GEN" ]]; then
"$VAL_ACCOUNTS_DIR" "$ACCOUNTS_SPEC" "$WASM_SCRIPT_PATH" \
"$WASM_CODE_PATH" "$TREASURY_INIT_TOKENS_U128" \
"$VAL_NODE_URLS_AND_VAL_PUBKEYS" "$GOV_VOTING_PERIOD" \
"$GOV_MAX_DEPOSIT_PERIOD" "$STAKING_MAX_VALIDATORS" \
"$GOV_MAX_DEPOSIT_PERIOD" "$GOV_EXPEDITED_VOTING_PERIOD" "$STAKING_MAX_VALIDATORS" \
"$FEEREFUNDER_ACK_FEE_MIN" "$FEEREFUNDER_TIMEOUT_FEE_MIN" \
"$DEX_ADMIN_MNEMONIC" "$STORE_CODE_PRIVILEGED_ACCOUNT_MNEMONIC" \
"$ADMINS_TOKENS")
Expand Down
9 changes: 8 additions & 1 deletion scripts/init-local-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ RESERVE_NAME="reserve"
RESERVE_TOKENS="1000000000""$NATIVE_CURRENCY"
GOV_VOTING_PERIOD="300s"
GOV_MAX_DEPOSIT_PERIOD="43200s"
GOV_EXPEDITED_VOTING_PERIOD="2m"
STAKING_MAX_VALIDATORS="40"
FEEREFUNDER_ACK_FEE_MIN="1"
FEEREFUNDER_TIMEOUT_FEE_MIN="1"
Expand Down Expand Up @@ -89,6 +90,7 @@ while [[ $# -gt 0 ]]; do
[--reserve-tokens <initial_reserve_tokens>]
[--gov-voting-period <voting_period>]
[--gov-max-deposit-period <max_deposit_period - XXs>]
[--gov-expedited-voting-period <expedited_voting_period>]
[--staking-max-validators <staking_max_validators>]
[--feerefunder-ack-fee-min <feerefunder_ack_fee_min_amount>]
[--feerefunder-timeout-fee-min <feerefunder_timeout_fee_min_amount>]
Expand Down Expand Up @@ -207,6 +209,11 @@ while [[ $# -gt 0 ]]; do
shift 2
;;

--gov-expedited-voting-period)
GOV_EXPEDITED_VOTING_PERIOD="$2"
shift 2
;;

--staking-max-validators)
STAKING_MAX_VALIDATORS="$2"
shift 2
Expand Down Expand Up @@ -349,7 +356,7 @@ init_setup_validator_local_sh "$INIT_LOCAL_NETWORK_SCRIPT_DIR" "$VALIDATORS_ROOT
source "$INIT_LOCAL_NETWORK_SCRIPT_DIR"/internal/init-network.sh
init_network "$VAL_ACCOUNTS_DIR" "$VALIDATORS" "$MINIMUM_GAS_PRICE" "$QUERY_GAS_LIMIT" "$CHAIN_ID" "$NATIVE_CURRENCY" \
"$VAL_TOKENS" "$VAL_STAKE" "$accounts_spec" "$WASM_SCRIPT_PATH" "$WASM_CODE_ARTIFACTS_PATH_PLATFORM" \
"$TREASURY_NLS_U128" "$GOV_VOTING_PERIOD" "$GOV_MAX_DEPOSIT_PERIOD" "$STAKING_MAX_VALIDATORS" \
"$TREASURY_NLS_U128" "$GOV_VOTING_PERIOD" "$GOV_MAX_DEPOSIT_PERIOD" "$GOV_EXPEDITED_VOTING_PERIOD" "$STAKING_MAX_VALIDATORS" \
"$FEEREFUNDER_ACK_FEE_MIN" "$FEEREFUNDER_TIMEOUT_FEE_MIN" \
"$DEX_ADMIN_MNEMONIC" "$STORE_CODE_PRIVILEGED_ACCOUNT_MNEMONIC" "$ADMINS_BALANCE"

Expand Down
10 changes: 9 additions & 1 deletion scripts/init-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ FAUCET_MNEMONIC=""
FAUCET_TOKENS="100000000000""$NATIVE_CURRENCY"
GOV_VOTING_PERIOD="3600s"
GOV_MAX_DEPOSIT_PERIOD="43200s"
GOV_EXPEDITED_VOTING_PERIOD="2m"
STAKING_MAX_VALIDATORS="40"
FEEREFUNDER_ACK_FEE_MIN="1"
FEEREFUNDER_TIMEOUT_FEE_MIN="1"
Expand Down Expand Up @@ -78,6 +79,7 @@ while [[ $# -gt 0 ]]; do
[--faucet-tokens <initial_balance>]
[--gov-voting-period <voting_period>]
[--gov-max-deposit-period <max_deposit_period - XXs>]
[--gov-expedited-voting-period <expedited_voting_period>]
[--staking-max-validators <staking_max_validators>]
[--feerefunder-ack-fee-min <feerefunder_ack_fee_min_amount>]
[--feerefunder-timeout-fee-min <feerefunder_timeout_fee_min_amount>]
Expand Down Expand Up @@ -206,6 +208,12 @@ while [[ $# -gt 0 ]]; do
shift
;;

--gov-expedited-voting-period)
GOV_EXPEDITED_VOTING_PERIOD="$2"
shift
shift
;;

--staking-max-validators)
STAKING_MAX_VALIDATORS="$2"
shift
Expand Down Expand Up @@ -277,7 +285,7 @@ setup_services "$VALIDATORS"
source "$SCRIPT_DIR"/internal/init-network.sh
init_network "$VAL_ACCOUNTS_DIR" "$VALIDATORS" "$MINIMUM_GAS_PRICE" "$QUERY_GAS_LIMIT" "$CHAIN_ID" "$NATIVE_CURRENCY" \
"$VAL_TOKENS" "$VAL_STAKE" "$accounts_spec" "$WASM_SCRIPT_PATH" "$WASM_CODE_PATH" \
"$TREASURY_NLS_U128" "$GOV_VOTING_PERIOD" "$GOV_MAX_DEPOSIT_PERIOD" "$STAKING_MAX_VALIDATORS" \
"$TREASURY_NLS_U128" "$GOV_VOTING_PERIOD" "$GOV_MAX_DEPOSIT_PERIOD" "$GOV_EXPEDITED_VOTING_PERIOD" "$STAKING_MAX_VALIDATORS" \
"$FEEREFUNDER_ACK_FEE_MIN" "$FEEREFUNDER_TIMEOUT_FEE_MIN" \
"$DEX_ADMIN_MNEMONIC" "$STORE_CODE_PRIVILEGED_ACCOUNT_MNEMONIC" "$ADMINS_TOKENS"

Expand Down
30 changes: 16 additions & 14 deletions scripts/internal/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ generate_genesis() {
local -r node_id_and_val_pubkeys="${10}"
local -r gov_voting_period="${11}"
local -r gov_max_deposit_period="${12}"
local -r staking_max_validators="${13}"
local -r feerefunder_ack_fee_min="${14}"
local -r feerefunder_timeout_fee_min="${15}"
local -r dex_admin_mnemonic="${16}"
local -r store_code_privileged_account_mnemonic="${17}"
local -r admins_tokens="${18}"
local -r gov_expedited_voting_period="${13}"
local -r staking_max_validators="${14}"
local -r feerefunder_ack_fee_min="${15}"
local -r feerefunder_timeout_fee_min="${16}"
local -r dex_admin_mnemonic="${17}"
local -r store_code_privileged_account_mnemonic="${18}"
local -r admins_tokens="${19}"


local -r treasury_init_tokens="$treasury_init_tokens_u128$native_currency"
Expand All @@ -73,7 +74,7 @@ generate_genesis() {
# use the below pattern to let the pipefail dump the failed command output
_=$(__generate_proto_genesis_no_wasm "$chain_id" "$native_currency" \
"$accounts_spec" "$treasury_contract_addr" "$treasury_init_tokens_u128" "$admin_contract_addr" "$gov_voting_period" \
"$gov_max_deposit_period" "$staking_max_validators" "$feerefunder_ack_fee_min" "$feerefunder_timeout_fee_min" "$store_code_privileged_addr")
"$gov_max_deposit_period" "$gov_expedited_voting_period" "$staking_max_validators" "$feerefunder_ack_fee_min" "$feerefunder_timeout_fee_min" "$store_code_privileged_addr")
_=$(add_wasm_messages "$genesis_home_dir" "$wasm_code_path" "$treasury_init_tokens" "$dex_admin_address")

create_validator_txs="$(__gen_val_txns "$genesis_file" "$node_id_and_val_pubkeys" "$val_stake")"
Expand Down Expand Up @@ -133,10 +134,11 @@ __generate_proto_genesis_no_wasm() {
local -r admin_contract_addr="$6"
local -r gov_voting_period="$7"
local -r gov_max_deposit_period="$8"
local -r staking_max_validators="$9"
local -r feerefunder_ack_fee_min="${10}"
local -r feerefunder_timeout_fee_min="${11}"
local -r store_code_privileged_addr="${12}"
local -r gov_expedited_voting_period="$9"
local -r staking_max_validators="${10}"
local -r feerefunder_ack_fee_min="${11}"
local -r feerefunder_timeout_fee_min="${12}"
local -r store_code_privileged_addr="${13}"

local -a wasm_allowed_addresses=("$admin_contract_addr" "$store_code_privileged_addr")

Expand All @@ -147,7 +149,7 @@ __generate_proto_genesis_no_wasm() {
__set_token_denominations "$genesis_file" "$native_currency"
__set_tax_recipient "$genesis_file" "$treasury_addr"
__set_wasm_permission_params "$genesis_file" "${wasm_allowed_addresses[@]}"
__set_gov_parameters "$genesis_file" "$gov_voting_period" "$gov_max_deposit_period"
__set_gov_parameters "$genesis_file" "$gov_voting_period" "$gov_max_deposit_period" "$gov_expedited_voting_period"
__modify_slashing_and_staking_params "$genesis_file" "$staking_max_validators"
__modify_neutron_modules_params "$genesis_file" "$feerefunder_ack_fee_min" "$feerefunder_timeout_fee_min" "$native_currency"

Expand Down Expand Up @@ -226,14 +228,14 @@ __set_gov_parameters() {
local genesis_file="$1"
local -r voting_period="$2"
local -r max_deposit_period="$3"
local -r expedited_voting_period="$4"

local genesis_tmp_file="$genesis_file".tmp

# TODO: use a variable for expedited_voting_period
< "$genesis_file" \
jq '.app_state["gov"]["deposit_params"]["max_deposit_period"]="'"$max_deposit_period"'"' \
| jq '.app_state["gov"]["params"]["voting_period"]="'"$voting_period"'"' \
| jq '.app_state["gov"]["params"]["expedited_voting_period"]="2m"' \
| jq '.app_state["gov"]["params"]["expedited_voting_period"]="'"$expedited_voting_period"'"' \
| jq '.app_state["gov"]["voting_params"]["voting_period"]="'"$voting_period"'"' > "$genesis_tmp_file"
mv "$genesis_tmp_file" "$genesis_file"
}
Expand Down
15 changes: 8 additions & 7 deletions scripts/internal/init-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ init_network() {
local -r treasury_init_tokens_u128="${12}"
local -r gov_voting_period="${13}"
local -r gov_max_deposit_period="${14}"
local -r staking_max_validators="${15}"
local -r feerefunder_ack_fee_min="${16}"
local -r feerefunder_timeout_fee_min="${17}"
local -r dex_admin_mnemonic="${18}"
local -r store_code_privileged_account_mnemonic="${19}"
local -r admins_tokens="${20}"
local -r gov_expedited_voting_period="${15}"
local -r staking_max_validators="${16}"
local -r feerefunder_ack_fee_min="${17}"
local -r feerefunder_timeout_fee_min="${18}"
local -r dex_admin_mnemonic="${19}"
local -r store_code_privileged_account_mnemonic="${20}"
local -r admins_tokens="${21}"

node_id_and_val_pubkeys="$(setup_validators "$validators" "$minimum_gas_price" "$query_gas_limit")"
local final_genesis_file;
Expand All @@ -38,7 +39,7 @@ init_network() {
"$wasm_script_path" "$wasm_code_path" \
"$treasury_init_tokens_u128" \
"$node_id_and_val_pubkeys" \
"$gov_voting_period" "$gov_max_deposit_period" "$staking_max_validators" \
"$gov_voting_period" "$gov_max_deposit_period" "$gov_expedited_voting_period" "$staking_max_validators" \
"$feerefunder_ack_fee_min" "$feerefunder_timeout_fee_min" \
"$dex_admin_mnemonic" "$store_code_privileged_account_mnemonic" "$admins_tokens")
propagate_genesis "$final_genesis_file" "$validators"
Expand Down

0 comments on commit aec4f56

Please sign in to comment.