From 1dda67312e1fd14599c507d7c8170d15afc247d3 Mon Sep 17 00:00:00 2001 From: Levi Schoen Date: Thu, 13 Apr 2023 18:29:25 -0700 Subject: [PATCH] dynamically set default contract addresses for bridged asset in testnet seed scripts --- .../force-update-module-params.sh | 0 .github/scripts/seed-internal-testnet.sh | 52 +++++++++++++++++++ .github/scripts/seed-protonet.sh | 52 +++++++++++++++++++ .github/workflows/cd-seed-chain.yml | 3 ++ 4 files changed, 107 insertions(+) rename .github/scripts/{ => examples}/force-update-module-params.sh (100%) diff --git a/.github/scripts/force-update-module-params.sh b/.github/scripts/examples/force-update-module-params.sh similarity index 100% rename from .github/scripts/force-update-module-params.sh rename to .github/scripts/examples/force-update-module-params.sh diff --git a/.github/scripts/seed-internal-testnet.sh b/.github/scripts/seed-internal-testnet.sh index e409fbb2..eeb7c11b 100755 --- a/.github/scripts/seed-internal-testnet.sh +++ b/.github/scripts/seed-internal-testnet.sh @@ -102,3 +102,55 @@ done # create a text proposal kava tx gov submit-proposal --deposit 1000000000ukava --type "Text" --title "Example Proposal" --description "This is an example proposal" --gas auto --gas-adjustment 1.2 --from dev-wallet --gas-prices 0.01ukava -y + +# setup god's wallet +echo "${KAVA_TESTNET_GOD_MNEMONIC}" | kava keys add --recover god + +# create template string for the proposal we want to enact +# https://kava-labs.atlassian.net/wiki/spaces/ENG/pages/1228537857/Submitting+Governance+Proposals+WIP +PARAM_CHANGE_PROP_TEMPLATE=$(cat <<'END_HEREDOC' +{ + "@type": "/cosmos.params.v1beta1.ParameterChangeProposal", + "title": "Set Initial ERC-20 Contracts", + "description": "Set Initial ERC-20 Contracts", + "changes": [ + { + "subspace": "evmutil", + "key": "EnabledConversionPairs", + "value": "[{\"kava_erc20_address\":\"MULTICHAIN_USDC_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/usdc\"},{\"kava_erc20_address\":\"MULTICHAIN_USDT_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/usdt\"},{\"kava_erc20_address\":\"MULTICHAIN_wBTC_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/btc\"},{\"kava_erc20_address\":\"AXL_USDC_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/usdc\"},{\"kava_erc20_address\":\"wBTC_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/btc\"},{\"kava_erc20_address\":\"wETH_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/eth\"}]" + } + ] +} +END_HEREDOC +) + +# substitute freshly deployed contract addresses +finalProposal=$PARAM_CHANGE_PROP_TEMPLATE + +finalProposal="${finalProposal/MULTICHAIN_USDC_CONTRACT_ADDRESS/$MULTICHAIN_USDC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/MULTICHAIN_USDT_CONTRACT_ADDRESS/$MULTICHAIN_USDT_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/MULTICHAIN_wBTC_CONTRACT_ADDRESS/$MULTICHAIN_wBTC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/AXL_USDC_CONTRACT_ADDRESS/$AXL_USDC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/wBTC_CONTRACT_ADDRESS/$wBTC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/wETH_CONTRACT_ADDRESS/$wETH_CONTRACT_ADDRESS}" + +# create unique proposal filename +proposalFileName="$(date +%s)-proposal.json" +touch $proposalFileName + +# save proposal as file to disk +echo "$finalProposal" > $proposalFileName + +# snapshot original module params +originalEvmUtilParams=$(curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params) +printf "original evm util module params\n %s" , "$originalEvmUtilParams" + +# change the params of the chain like a god - make it so 🖖🏽 +# make sure to update god committee member permissions for the module +# and params being updated (see below for example) +# https://github.com/Kava-Labs/kava/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903 +kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y + +# fetch current module params +updatedEvmUtilParams=$(curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params) +printf "updated evm util module params\n %s" , "$updatedEvmUtilParams" diff --git a/.github/scripts/seed-protonet.sh b/.github/scripts/seed-protonet.sh index b2400287..7e6f2ed9 100755 --- a/.github/scripts/seed-protonet.sh +++ b/.github/scripts/seed-protonet.sh @@ -93,3 +93,55 @@ done # create a text proposal kava tx gov submit-legacy-proposal --deposit 1000000000ukava --type "Text" --title "Example Proposal" --description "This is an example proposal" --gas auto --gas-adjustment 1.2 --from dev-wallet --gas-prices 0.01ukava -y + +# setup god's wallet +echo "${KAVA_TESTNET_GOD_MNEMONIC}" | kava keys add --recover god + +# create template string for the proposal we want to enact +# https://kava-labs.atlassian.net/wiki/spaces/ENG/pages/1228537857/Submitting+Governance+Proposals+WIP +PARAM_CHANGE_PROP_TEMPLATE=$(cat <<'END_HEREDOC' +{ + "@type": "/cosmos.params.v1beta1.ParameterChangeProposal", + "title": "Set Initial ERC-20 Contracts", + "description": "Set Initial ERC-20 Contracts", + "changes": [ + { + "subspace": "evmutil", + "key": "EnabledConversionPairs", + "value": "[{\"kava_erc20_address\":\"MULTICHAIN_USDC_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/usdc\"},{\"kava_erc20_address\":\"MULTICHAIN_USDT_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/usdt\"},{\"kava_erc20_address\":\"MULTICHAIN_wBTC_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/btc\"},{\"kava_erc20_address\":\"AXL_USDC_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/usdc\"},{\"kava_erc20_address\":\"wBTC_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/btc\"},{\"kava_erc20_address\":\"wETH_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/eth\"}]" + } + ] +} +END_HEREDOC +) + +# substitute freshly deployed contract addresses +finalProposal=$PARAM_CHANGE_PROP_TEMPLATE + +finalProposal="${finalProposal/MULTICHAIN_USDC_CONTRACT_ADDRESS/$MULTICHAIN_USDC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/MULTICHAIN_USDT_CONTRACT_ADDRESS/$MULTICHAIN_USDT_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/MULTICHAIN_wBTC_CONTRACT_ADDRESS/$MULTICHAIN_wBTC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/AXL_USDC_CONTRACT_ADDRESS/$AXL_USDC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/wBTC_CONTRACT_ADDRESS/$wBTC_CONTRACT_ADDRESS}" +finalProposal="${finalProposal/wETH_CONTRACT_ADDRESS/$wETH_CONTRACT_ADDRESS}" + +# create unique proposal filename +proposalFileName="$(date +%s)-proposal.json" +touch $proposalFileName + +# save proposal as file to disk +echo "$finalProposal" > $proposalFileName + +# snapshot original module params +originalEvmUtilParams=$(curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params) +printf "original evm util module params\n %s" , "$originalEvmUtilParams" + +# change the params of the chain like a god - make it so 🖖🏽 +# make sure to update god committee member permissions for the module +# and params being updated (see below for example) +# https://github.com/Kava-Labs/kava/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903 +kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y + +# fetch current module params +updatedEvmUtilParams=$(curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params) +printf "updated evm util module params\n %s" , "$updatedEvmUtilParams" diff --git a/.github/workflows/cd-seed-chain.yml b/.github/workflows/cd-seed-chain.yml index e9d13b31..4faa0ee6 100644 --- a/.github/workflows/cd-seed-chain.yml +++ b/.github/workflows/cd-seed-chain.yml @@ -24,6 +24,8 @@ on: secrets: DEV_WALLET_MNEMONIC: required: true + KAVA_TESTNET_GOD_MNEMONIC: + required: true jobs: seed-chain-state: @@ -88,6 +90,7 @@ jobs: CHAIN_API_URL: ${{ inputs.chain-api-url }} CHAIN_ID: ${{ inputs.chain-id }} DEV_WALLET_MNEMONIC: ${{ secrets.DEV_WALLET_MNEMONIC }} + KAVA_TESTNET_GOD_MNEMONIC: ${{ secrets.KAVA_TESTNET_GOD_MNEMONIC }} SEED_SCRIPT_FILENAME: ${{ inputs.seed-script-filename }} ERC20_DEPLOYER_NETWORK_NAME: ${{ inputs.erc20-deployer-network-name }} GENESIS_VALIDATOR_ADDRESSES: ${{ inputs.genesis_validator_addresses }}