diff --git a/.github/scripts/seed-internal-testnet.sh b/.github/scripts/seed-internal-testnet.sh new file mode 100755 index 00000000..2a30d2f9 --- /dev/null +++ b/.github/scripts/seed-internal-testnet.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -ex + +# configure kava binary to talk to the desired chain endpoint +kava config node ${CHAIN_API_URL} +kava config chain-id ${CHAIN_ID} + +# use the test keyring to allow scriptng key generation +kava config keyring-backend test + +# wait for transactions to be committed per CLI command +kava config broadcast-mode block + +# setup dev wallet +echo "${DEV_WALLET_MNEMONIC}" | kava keys add --recover dev-wallet + +# setup kava etherum comptabile account for deploying +# erc20 contracts to the kava chain +echo "sweet ocean blush coil mobile ten floor sample nuclear power legend where place swamp young marble grit observe enforce lake blossom lesson upon plug" | kava keys add --recover --eth dev-erc20-deployer-wallet + +# fund evm-contract-deployer account (using issuance) +yes y | kava tx issuance issue 200000000ukava kava1van3znl6597xgwwh46jgquutnqkwvwszjg04fz --from dev-wallet --gas-prices 0.5ukava + +# deploy and fund USDC ERC20 contract +USD_CONTRACT_DEPLOY=$(npx hardhat --network demonet deploy-erc20 "USD Coin" USDC 6) +USD_CONTRACT_ADDRESS=${USD_CONTRACT_DEPLOY: -42} +npx hardhat --network demonet mint-erc20 "$USD_CONTRACT_ADDRESS" 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000 + +# # deploy and fund wKava ERC20 contract +wKAVA_CONTRACT_DEPLOY=$(npx hardhat --network demonet deploy-erc20 "Wrapped Kava" wKava 6) +wKAVA_CONTRACT_ADDRESS=${wKAVA_CONTRACT_DEPLOY: -42} +npx hardhat --network demonet mint-erc20 "$wKAVA_CONTRACT_ADDRESS" 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000 + +# deploy and fund BNB contract +BNB_CONTRACT_DEPLOY=$(npx hardhat --network demonet deploy-erc20 "Binance" BNB 8) +BNB_CONTRACT_ADDRESS=${BNB_CONTRACT_DEPLOY: -42} +npx hardhat --network demonet mint-erc20 "$BNB_CONTRACT_ADDRESS" 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000 + +# deploy and fund USDT contract +USDT_CONTRACT_DEPLOY=$(npx hardhat --network demonet deploy-erc20 "USDT" USDT 6) +USDT_CONTRACT_ADDRESS=${USDT_CONTRACT_DEPLOY: -42} +npx hardhat --network demonet mint-erc20 "$USDT_CONTRACT_ADDRESS" 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000 + +# deploy and fund DAI contract +DAI_CONTRACT_DEPLOY=$(npx hardhat --network demonet deploy-erc20 "DAI" DAI 18) +DAI_CONTRACT_ADDRESS=${DAI_CONTRACT_DEPLOY: -42} +npx hardhat --network demonet mint-erc20 "$DAI_CONTRACT_ADDRESS" 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000 diff --git a/.github/workflows/cd-internal-testnet.yml b/.github/workflows/cd-internal-testnet.yml index b9e382c5..1b5d61c1 100644 --- a/.github/workflows/cd-internal-testnet.yml +++ b/.github/workflows/cd-internal-testnet.yml @@ -5,10 +5,6 @@ on: workflows: [Continuous Integration (Kava Master)] types: - completed - push: - # run CI on any push to the feature branch - branches: - - ls-internal-testnet-cd-pipeline jobs: # in order: @@ -18,7 +14,7 @@ jobs: # download updated binary and genesis # reset application database state (only done on internal testnet) reset-chain-to-zero-state: - # only start cd pipeline if last ci run was successful + # only start cd pipeline if last ci run was successful if: ${{ github.event.workflow_run.conclusion == 'success' }} uses: ./.github/workflows/cd-reset-internal-testnet.yml with: @@ -26,7 +22,7 @@ jobs: chain-id: demo_2221-17000 ssm-document-name: kava-demonet-node-update playbook-name: reset-internal-testnet-playbook.yml - playbook-infrastructure-branch: ls-deploy-testnet-for-cd-prototyping + playbook-infrastructure-branch: master secrets: inherit # start kava with new binary and genesis state on api, peer and seed nodes, place nodes in service once they start and are synched to live @@ -37,12 +33,16 @@ jobs: chain-id: demo_2221-17000 ssm-document-name: kava-demonet-node-update playbook-name: start-chain-api-playbook.yml - playbook-infrastructure-branch: ls-deploy-testnet-for-cd-prototyping + playbook-infrastructure-branch: master secrets: inherit needs: [reset-chain-to-zero-state] # setup test and development accounts and balances, deploy contracts by calling the chain's api seed-chain-state: uses: ./.github/workflows/cd-seed-chain.yml + with: + chain-api-url: https://rpc.data.demonet.us-east.production.kava.io:443 + chain-id: kava_2221-17000 + seed-script-filename: seed-internal-testnet.sh secrets: inherit needs: [start-chain-api] diff --git a/.github/workflows/cd-reset-internal-testnet.yml b/.github/workflows/cd-reset-internal-testnet.yml index bdabd073..4f063176 100644 --- a/.github/workflows/cd-reset-internal-testnet.yml +++ b/.github/workflows/cd-reset-internal-testnet.yml @@ -50,7 +50,7 @@ jobs: repository: Kava-Labs/infrastructure token: ${{ secrets.KAVA_PRIVATE_GITHUB_ACCESS_TOKEN }} path: infrastructure - ref: ls-deploy-testnet-for-cd-prototyping + ref: master - name: set up Go uses: actions/setup-go@v3 with: diff --git a/.github/workflows/cd-seed-chain.yml b/.github/workflows/cd-seed-chain.yml index 8c00305d..a313e464 100644 --- a/.github/workflows/cd-seed-chain.yml +++ b/.github/workflows/cd-seed-chain.yml @@ -2,10 +2,67 @@ name: Seed Chain on: workflow_call: + inputs: + chain-api-url: + required: true + type: string + chain-id: + required: true + type: string + seed-script-filename: + required: true + type: string + secrets: + DEV_WALLET_MNEMONIC: + required: true jobs: - no-op: + seed-chain-state: runs-on: ubuntu-latest steps: - - name: no-op - run: echo "Hello World" + - name: checkout repo from current commit + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.18' + check-latest: true + cache: true + - name: build kava binary + run: make install + - name: checkout go evm tools repo + uses: actions/checkout@v3 + with: + repository: ethereum/go-ethereum + path: go-ethereum + - name: install go evm tools + run: | + make + make devtools + working-directory: go-ethereum + - name: checkout kava bridge repo for deploying evm contracts + uses: actions/checkout@v3 + with: + repository: Kava-Labs/kava-bridge + path: kava-bridge + ref: master + - name: install nodeJS + uses: actions/setup-node@v3 + with: + cache: npm + node-version: 18 + cache-dependency-path: kava-bridge/contract/package.json + - name: "install ERC20 contract deployment dependencies" + run: "npm install" + working-directory: kava-bridge/contract + - name: compile default erc20 contracts + run: make compile-contracts + working-directory: kava-bridge + - name: run seed scripts + run: bash ${GITHUB_WORKSPACE}/.github/scripts/${SEED_SCRIPT_FILENAME} + working-directory: kava-bridge/contract + env: + CHAIN_API_URL: ${{ inputs.chain-api-url }} + CHAIN_ID: ${{ inputs.chain-id }} + DEV_WALLET_MNEMONIC: ${{ secrets.DEV_WALLET_MNEMONIC }} + SEED_SCRIPT_FILENAME: ${{ inputs.seed-script-filename }} diff --git a/.github/workflows/cd-start-chain.yml b/.github/workflows/cd-start-chain.yml index 09980b62..3f48fc6a 100644 --- a/.github/workflows/cd-start-chain.yml +++ b/.github/workflows/cd-start-chain.yml @@ -46,7 +46,7 @@ jobs: repository: Kava-Labs/infrastructure token: ${{ secrets.KAVA_PRIVATE_GITHUB_ACCESS_TOKEN }} path: infrastructure - ref: ls-deploy-testnet-for-cd-prototyping + ref: master - name: set up Go uses: actions/setup-go@v3 with: