diff --git a/protocol/scripts/genesis/prod_pregenesis.sh b/protocol/scripts/genesis/prod_pregenesis.sh index f0d5e936ce..c54e373306 100755 --- a/protocol/scripts/genesis/prod_pregenesis.sh +++ b/protocol/scripts/genesis/prod_pregenesis.sh @@ -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 } diff --git a/protocol/testing/containertest/containertest.sh b/protocol/testing/containertest/containertest.sh index 6f3166b073..619eb01f1c 100755 --- a/protocol/testing/containertest/containertest.sh +++ b/protocol/testing/containertest/containertest.sh @@ -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" diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index ac1cc7f505..da3c29f904 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -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" @@ -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 @@ -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 "{}" diff --git a/protocol/testing/testnet-dev/dev.sh b/protocol/testing/testnet-dev/dev.sh index bfafd40534..1d2ff614b9 100755 --- a/protocol/testing/testnet-dev/dev.sh +++ b/protocol/testing/testnet-dev/dev.sh @@ -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" diff --git a/protocol/testing/testnet-external/pregenesis.sh b/protocol/testing/testnet-external/pregenesis.sh index 491c390417..b7b746f84b 100755 --- a/protocol/testing/testnet-external/pregenesis.sh +++ b/protocol/testing/testnet-external/pregenesis.sh @@ -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" diff --git a/protocol/testing/testnet-local/local.sh b/protocol/testing/testnet-local/local.sh index 2a57f9236c..edb7112c18 100755 --- a/protocol/testing/testnet-local/local.sh +++ b/protocol/testing/testnet-local/local.sh @@ -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" diff --git a/protocol/testing/testnet-staging/staging.sh b/protocol/testing/testnet-staging/staging.sh index 8dfe55b8ee..2c3302bde2 100755 --- a/protocol/testing/testnet-staging/staging.sh +++ b/protocol/testing/testnet-staging/staging.sh @@ -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"