Skip to content

Commit

Permalink
modify genesis scripts to take rewards vester account balance as an a…
Browse files Browse the repository at this point in the history
…rgument and count it towards total supply (#525)

* modify genesis scripts to take rewards vester account balance as an argument and count it towards total supply

* update container and pregenesis scripts

* default rewards vester account to 200 million full coins
  • Loading branch information
tqin7 authored Oct 23, 2023
1 parent ca5bcb4 commit cba238d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion protocol/scripts/genesis/prod_pregenesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ create_pregenesis_file() {
echo "Copying exchange config jsons to $TMP_EXCHANGE_CONFIG_JSON_DIR"
cp -R ./daemons/pricefeed/client/constants/testdata $TMP_EXCHANGE_CONFIG_JSON_DIR

edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "STATUS_INITIALIZING"
edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "STATUS_INITIALIZING" ""
overwrite_genesis_production
}

Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/containertest/containertest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ create_validators() {
# Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..."
# Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..."
# Note: `edit_genesis` must be called before `add-genesis-account` or `update_genesis_use_test_exchange`.
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" ""
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" ""
# Configure the genesis file to only use the test exchange to compute index prices.
update_genesis_use_test_exchange "$VAL_CONFIG_DIR"

Expand Down
25 changes: 18 additions & 7 deletions protocol/testing/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ function edit_genesis() {
INITIAL_CLOB_PAIR_STATUS='STATUS_ACTIVE'
fi

REWARDS_VESTER_ACCOUNT_BALANCE="$7"
if [ -z "$REWARDS_VESTER_ACCOUNT_BALANCE" ]; then
# Default to 200 million full coins.
REWARDS_VESTER_ACCOUNT_BALANCE="200000000$EIGHTEEN_ZEROS"
fi

# Genesis time
dasel put -t string -f "$GENESIS" '.genesis_time' -v "$GENESIS_TIME"

Expand Down Expand Up @@ -984,6 +990,7 @@ function edit_genesis() {
dydx_exchange_config_json=$(cat "$EXCHANGE_CONFIG_JSON_DIR/dydx_exchange_config.json" | jq -c '.')
dasel put -t string -f "$GENESIS" '.app_state.prices.market_params.[34].exchange_config_json' -v "$dydx_exchange_config_json"

# Initialize bridge module account balance as total native token supply.
bridge_module_account_balance=$TOTAL_NATIVE_TOKEN_SUPPLY
total_accounts_quote_balance=0
acct_idx=0
Expand Down Expand Up @@ -1014,13 +1021,17 @@ function edit_genesis() {
next_bank_idx=$(($next_bank_idx+1))
fi

# Initialize bank balance for reward vester account.
dasel put -t json -f "$GENESIS" ".app_state.bank.balances.[]" -v "{}"
dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].address" -v "${REWARDS_VESTER_ACCOUNT_ADDR}"
dasel put -t json -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[]" -v "{}"
dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[0].denom" -v "${REWARD_TOKEN}"
dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[0].amount" -v "10000000$EIGHTEEN_ZEROS" # 10 million full coins
next_bank_idx=$(($next_bank_idx+1))
if [ $(echo "$REWARDS_VESTER_ACCOUNT_BALANCE > 0" | bc -l) -eq 1 ]; then
# Initialize bank balance of reward vester account.
dasel put -t json -f "$GENESIS" ".app_state.bank.balances.[]" -v "{}"
dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].address" -v "${REWARDS_VESTER_ACCOUNT_ADDR}"
dasel put -t json -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[]" -v "{}"
dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[0].denom" -v "${REWARD_TOKEN}"
dasel put -t string -f "$GENESIS" ".app_state.bank.balances.[$next_bank_idx].coins.[0].amount" -v "$REWARDS_VESTER_ACCOUNT_BALANCE"
next_bank_idx=$(($next_bank_idx+1))

bridge_module_account_balance=$(echo "$bridge_module_account_balance - $REWARDS_VESTER_ACCOUNT_BALANCE" | bc)
fi

# Initialize bank balance of bridge module account.
dasel put -t json -f "$GENESIS" ".app_state.bank.balances.[]" -v "{}"
Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/testnet-dev/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ create_validators() {
# Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..."
# Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..."
# Note: `edit_genesis` must be called before `add-genesis-account`.
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" ""
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" ""
update_genesis_use_test_volatile_market "$VAL_CONFIG_DIR"
update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "600"

Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/testnet-external/pregenesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ create_pregenesis_file() {
# Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..."
# Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..."
# Note: `edit_genesis` must be called before `add-genesis-account`.
edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" ""
edit_genesis "$VAL_CONFIG_DIR" "" "" "$TMP_EXCHANGE_CONFIG_JSON_DIR" "./testing/delaymsg_config" "" ""
overwrite_genesis_public_testnet

FAUCET_BALANCE="${FAUCET_NATIVE_TOKEN_BALANCE}$NATIVE_TOKEN"
Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/testnet-local/local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ create_validators() {
# Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..."
# Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..."
# Note: `edit_genesis` must be called before `add-genesis-account`.
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" ""
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" ""
update_genesis_use_test_volatile_market "$VAL_CONFIG_DIR"
update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "30"

Expand Down
2 changes: 1 addition & 1 deletion protocol/testing/testnet-staging/staging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ create_validators() {
# Using "*" as a subscript results in a single arg: "dydx1... dydx1... dydx1..."
# Using "@" as a subscript results in separate args: "dydx1..." "dydx1..." "dydx1..."
# Note: `edit_genesis` must be called before `add-genesis-account`.
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" ""
edit_genesis "$VAL_CONFIG_DIR" "${TEST_ACCOUNTS[*]}" "${FAUCET_ACCOUNTS[*]}" "" "" "" ""
update_genesis_use_test_volatile_market "$VAL_CONFIG_DIR"
update_genesis_complete_bridge_delay "$VAL_CONFIG_DIR" "600"

Expand Down

0 comments on commit cba238d

Please sign in to comment.