From ad03a756792469fd21e03b1a05661dc5b95dfb94 Mon Sep 17 00:00:00 2001 From: Levi Schoen Date: Thu, 8 Feb 2024 15:32:44 -0800 Subject: [PATCH] emulate block broadcast mode in seed scripts (#1824) --- .github/scripts/seed-internal-testnet.sh | 21 +++++++++++++++++++++ .github/scripts/seed-protonet.sh | 21 +++++++++++++++++++++ .github/workflows/cd-seed-chain.yml | 4 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/scripts/seed-internal-testnet.sh b/.github/scripts/seed-internal-testnet.sh index 9a4fa653..bde9c5cf 100755 --- a/.github/scripts/seed-internal-testnet.sh +++ b/.github/scripts/seed-internal-testnet.sh @@ -1,6 +1,14 @@ #!/bin/bash set -ex +# by sleeping 1 block in between tx's +# we can emulate the behavior of the +# the deprecated and now removed (as of Kava 16) +# broadcast mode of `block` in order to +# minimize the chance tx's fail due to an +# account sequence number mismatch +AVG_SECONDS_BETWEEN_BLOCKS=6.5 + # configure kava binary to talk to the desired chain endpoint kava config node "${CHAIN_API_URL}" kava config chain-id "${CHAIN_ID}" @@ -23,6 +31,8 @@ echo "sweet ocean blush coil mobile ten floor sample nuclear power legend where # fund evm-contract-deployer account (using issuance) kava tx issuance issue 200000000ukava kava1van3znl6597xgwwh46jgquutnqkwvwszjg04fz --from dev-wallet --gas-prices 0.5ukava -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # deploy and fund USDC ERC20 contract MULTICHAIN_USDC_CONTRACT_DEPLOY=$(npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" deploy-erc20 "USD Coin" USDC 6) MULTICHAIN_USDC_CONTRACT_ADDRESS=${MULTICHAIN_USDC_CONTRACT_DEPLOY: -42} @@ -96,6 +106,8 @@ npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" mint-erc20 "$TETHER_USDT_ kava tx issuance issue 6000000000ukava kava1vlpsrmdyuywvaqrv7rx6xga224sqfwz3fyfhwq \ --from dev-wallet --gas-prices 0.5ukava -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # parse space seperated list of validators # into bash array read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<<"$GENESIS_VALIDATOR_ADDRESSES" @@ -103,11 +115,14 @@ read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<<"$GENESIS_VALIDATOR_ADDRESSES" # delegate 300KAVA to each validator for validator in "${GENESIS_VALIDATOR_ADDRESS_ARRAY[@]}"; do kava tx staking delegate "${validator}" 300000000ukava --from dev-wallet --gas-prices 0.5ukava -y + sleep $AVG_SECONDS_BETWEEN_BLOCKS 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 +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # setup god's wallet echo "${KAVA_TESTNET_GOD_MNEMONIC}" | kava keys add --recover god @@ -159,9 +174,13 @@ printf "original evm util module params\n %s" , "$originalEvmUtilParams" # committee 1 is the stability committee. on internal testnet, this has only one member. kava tx committee submit-proposal 1 "$proposalFileName" --gas 2000000 --gas-prices 0.01ukava --from god -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # vote on the proposal. this assumes no other committee proposal has ever been submitted (id=1) kava tx committee vote 1 yes --gas 2000000 --gas-prices 0.01ukava --from god -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # 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" @@ -172,3 +191,5 @@ kava tx evmutil convert-cosmos-coin-to-erc20 \ "$DEV_TEST_WALLET_ADDRESS" \ 1000000hard \ --from dev-wallet --gas 2000000 --gas-prices 0.001ukava -y + +sleep $AVG_SECONDS_BETWEEN_BLOCKS diff --git a/.github/scripts/seed-protonet.sh b/.github/scripts/seed-protonet.sh index 2c996969..4009c3e3 100755 --- a/.github/scripts/seed-protonet.sh +++ b/.github/scripts/seed-protonet.sh @@ -1,6 +1,14 @@ #!/bin/bash set -ex +# by sleeping 1 block in between tx's +# we can emulate the behavior of the +# the deprecated and now removed (as of Kava 16) +# broadcast mode of `block` in order to +# minimize the chance tx's fail due to an +# account sequence number mismatch +AVG_SECONDS_BETWEEN_BLOCKS=6.5 + # configure kava binary to talk to the desired chain endpoint kava config node "${CHAIN_API_URL}" kava config chain-id "${CHAIN_ID}" @@ -23,9 +31,13 @@ echo "sweet ocean blush coil mobile ten floor sample nuclear power legend where # fund evm-contract-deployer account (using issuance) kava tx issuance issue 200000000ukava kava1van3znl6597xgwwh46jgquutnqkwvwszjg04fz --from dev-wallet --gas-prices 0.5ukava -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # fund 5k kava to x/community account kava tx community fund-community-pool 5000000000ukava --from dev-wallet --gas-prices 0.5ukava -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # deploy and fund USDC ERC20 contract MULTICHAIN_USDC_CONTRACT_DEPLOY=$(npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" deploy-erc20 "USD Coin" USDC 6) MULTICHAIN_USDC_CONTRACT_ADDRESS=${MULTICHAIN_USDC_CONTRACT_DEPLOY: -42} @@ -89,6 +101,8 @@ npx hardhat --network "${ERC20_DEPLOYER_NETWORK_NAME}" mint-erc20 "$AXL_USDC_CON kava tx issuance issue 6000000000ukava kava1vlpsrmdyuywvaqrv7rx6xga224sqfwz3fyfhwq \ --from dev-wallet --gas-prices 0.5ukava -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # parse space seperated list of validators # into bash array read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<< "$GENESIS_VALIDATOR_ADDRESSES" @@ -97,11 +111,14 @@ read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<< "$GENESIS_VALIDATOR_ADDRESSES" for validator in "${GENESIS_VALIDATOR_ADDRESS_ARRAY[@]}" do kava tx staking delegate "${validator}" 300000000ukava --from dev-wallet --gas-prices 0.5ukava -y + sleep $AVG_SECONDS_BETWEEN_BLOCKS 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 +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # setup god's wallet echo "${KAVA_TESTNET_GOD_MNEMONIC}" | kava keys add --recover god @@ -150,9 +167,13 @@ printf "original evm util module params\n %s" , "$originalEvmUtilParams" # 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 +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # vote on the proposal. this assumes no other committee proposal has ever been submitted (id=1) kava tx committee vote 1 yes --gas 2000000 --gas-prices 0.01ukava --from god -y +sleep $AVG_SECONDS_BETWEEN_BLOCKS + # 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 a3efb6bd..43cf6e87 100644 --- a/.github/workflows/cd-seed-chain.yml +++ b/.github/workflows/cd-seed-chain.yml @@ -76,8 +76,8 @@ jobs: - name: compile default erc20 contracts run: make compile-contracts working-directory: kava-bridge - - name: download seed script from master - run: wget https://raw.githubusercontent.com/Kava-Labs/kava/master/.github/scripts/${SEED_SCRIPT_FILENAME} && chmod +x ${SEED_SCRIPT_FILENAME} + - name: download seed script from current commit + run: wget https://raw.githubusercontent.com/Kava-Labs/kava/${GITHUB_SHA}/.github/scripts/${SEED_SCRIPT_FILENAME} && chmod +x ${SEED_SCRIPT_FILENAME} working-directory: kava-bridge/contract env: SEED_SCRIPT_FILENAME: ${{ inputs.seed-script-filename }}