From 08fe922c8b39166d2edd2d20f1de0b11541b7486 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Fri, 27 Oct 2023 14:02:59 +0530 Subject: [PATCH 01/11] refactor: update hash of token manager deployed event and address extraction --- .../add-to-project-action/add-to-project/addToProject.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js index ba244a82..da3de7d3 100644 --- a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js +++ b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js @@ -1,7 +1,7 @@ const axios = require('axios').default; const URL = 'https://api.tenderly.co/api/v2/accounts/axelarEng/projects/ITS/contracts'; -const TOKEN_MANAGER_DEPLOYED_TOPIC0 = '0x614cc9db96194a8f405df6fbdd25ebc1df6bb741c1fd196cb927d546c1406c34'; +const TOKEN_MANAGER_DEPLOYED_TOPIC0 = '0x5284c2478b9c1a55e973429331078be39b5fb3eeb9d87d10b34d65a4c89ee4eb'; const addToProjectFn = async (context, event) => { const logs = event.logs; @@ -9,7 +9,7 @@ const addToProjectFn = async (context, event) => { for (let index = 0; index < logs.length; ++index) { if (logs[index].topics[0] === TOKEN_MANAGER_DEPLOYED_TOPIC0) { - const deployedAddress = '0x' + logs[index].data.substring(218, 258); // TODO: can change with final event imp with AXL-2064 + const deployedAddress = '0x' + logs[index].data.substring(26, 66); const name = `TokenManager-${context.metadata.getNetwork()}-${deployedAddress}`; // TokenManager + network + address contracts.push({ From 2b7538f5e3294e397aa27413812ae33863bdc4c3 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Fri, 27 Oct 2023 14:03:49 +0530 Subject: [PATCH 02/11] chore: add EOL, project_slug and account_id --- tenderly-suite/add-to-project-action/tenderly.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tenderly-suite/add-to-project-action/tenderly.yaml b/tenderly-suite/add-to-project-action/tenderly.yaml index 2b887548..0bebf8c6 100644 --- a/tenderly-suite/add-to-project-action/tenderly.yaml +++ b/tenderly-suite/add-to-project-action/tenderly.yaml @@ -1,4 +1,4 @@ -account_id: "" +account_id: "axelarEng" actions: axelareng/its: runtime: v2 @@ -10,4 +10,4 @@ actions: trigger: type: transaction execution_type: sequential -project_slug: "" \ No newline at end of file +project_slug: "ITS" From ad51464c41f9b279eca20ab5b36f115e620e8b54 Mon Sep 17 00:00:00 2001 From: Dean Date: Sat, 28 Oct 2023 23:04:53 -0400 Subject: [PATCH 03/11] feat: integration test gh action (#95) * feat: integration test GH action * feat: check file structure * fix: chain name * fix: artifacts path * fix: artifacts path * fix: skip deployment prompt verification * add yaml to prettier * cleanup other files * address comments * add chains env var * update gh action * move env * refactor --------- Co-authored-by: Dean Amiel Co-authored-by: Milap Sheth --- .github/workflows/lint.yaml | 5 +- .github/workflows/publish-chains-config.yaml | 36 +++++------ .github/workflows/test-chains-config.yaml | 40 ++++++------ .github/workflows/test.yaml | 64 ++++++++++++++++++++ .prettierrc | 6 ++ evm/balances.js | 2 +- evm/deploy-contract.js | 2 +- evm/gateway.js | 2 +- package.json | 2 +- 9 files changed, 115 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3b700a32..8ceb6a8e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,7 +1,6 @@ name: Linting -on: - - pull_request +on: pull_request jobs: lint: @@ -13,7 +12,7 @@ jobs: - ubuntu-latest runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/publish-chains-config.yaml b/.github/workflows/publish-chains-config.yaml index 962fb44f..4613ab6a 100644 --- a/.github/workflows/publish-chains-config.yaml +++ b/.github/workflows/publish-chains-config.yaml @@ -1,23 +1,23 @@ name: 'Publish Axelar Chains Config to NPM' on: - workflow_dispatch: + workflow_dispatch: jobs: - publish-to-npm: - name: 'Publish to NPM' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '18.x' - registry-url: 'https://registry.npmjs.org' - - run: npm ci - working-directory: ./axelar-chains-config - - run: npm run build - working-directory: ./axelar-chains-config - - run: npm publish - working-directory: ./axelar-chains-config - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + publish-to-npm: + name: 'Publish to NPM' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - run: npm ci + working-directory: ./axelar-chains-config + - run: npm run build + working-directory: ./axelar-chains-config + - run: npm publish + working-directory: ./axelar-chains-config + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test-chains-config.yaml b/.github/workflows/test-chains-config.yaml index 7853f41b..5957734b 100644 --- a/.github/workflows/test-chains-config.yaml +++ b/.github/workflows/test-chains-config.yaml @@ -3,25 +3,27 @@ name: Run Axelar Chains Config Tests on: pull_request jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-22.04] - arch: [amd64] - steps: - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 + test: + strategy: + matrix: + node-version: + - 18.x + os: + - ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v4 - - name: Install - run: npm ci - working-directory: axelar-chains-config + - name: Install + run: npm ci + working-directory: axelar-chains-config - - name: Test - run: npm run test - working-directory: axelar-chains-config + - name: Test + run: npm run test + working-directory: axelar-chains-config diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..676f7896 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,64 @@ +name: Test + +on: pull_request + +jobs: + test: + strategy: + matrix: + node-version: + - 18.x + os: + - ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install + run: npm ci + + - name: Spin up Hardhat Network + run: npx hardhat node & + + - name: Prepare local.json + run: | + echo '{ + "chains": { + "test": { + "name": "Test", + "id": "test", + "chainId": 31337, + "rpc": "http://127.0.0.1:8545", + "tokenSymbol": "TEST", + "contracts": {} + } + } + }' > ./axelar-chains-config/info/local.json + + # Create .env file with default hardhat private key that's prefunded + - name: Prepare .env + run: | + echo 'PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' >> .env + echo 'ENV=local' >> .env + echo 'CHAINS=test' >> .env + + - name: Display local.json + run: cat ./axelar-chains-config/info/local.json + + - name: Deploy ConstAddressDeployer + run: node evm/deploy-contract.js -a ../node_modules/@axelar-network/axelar-gmp-sdk-solidity/artifacts/contracts/deploy/ -c ConstAddressDeployer -m create -y + + - name: Deploy Create3Deployer + run: node evm/deploy-contract.js -a ../node_modules/@axelar-network/axelar-gmp-sdk-solidity/artifacts/contracts/deploy/ -c Create3Deployer -m create2 -y + + - name: Deploy AxelarGateway + run: node evm/deploy-gateway-v6.2.x.js -m create3 -s "AxelarGateway v6.2" -g 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -m 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -y + + - name: Call Method on Gateway + run: node evm/gateway.js --action callContract --destinationChain test2 -y diff --git a/.prettierrc b/.prettierrc index a775ca18..a2194d80 100644 --- a/.prettierrc +++ b/.prettierrc @@ -22,6 +22,12 @@ "options": { "tabWidth": 2 } + }, + { + "files": "*.yaml", + "options": { + "tabWidth": 2 + } } ] } diff --git a/evm/balances.js b/evm/balances.js index 0728fe0a..c02b0ce9 100644 --- a/evm/balances.js +++ b/evm/balances.js @@ -33,7 +33,7 @@ if (require.main === module) { .makeOptionMandatory(true) .env('ENV'), ); - program.addOption(new Option('-n, --chainNames ', 'chain names').makeOptionMandatory(true)); + program.addOption(new Option('-n, --chainNames ', 'chain names').makeOptionMandatory(true).env('CHAINS')); program.addOption(new Option('-p, --privateKey ', 'private key').makeOptionMandatory(true).env('PRIVATE_KEY')); program.action((options) => { diff --git a/evm/deploy-contract.js b/evm/deploy-contract.js index 993974b5..d03c77b7 100644 --- a/evm/deploy-contract.js +++ b/evm/deploy-contract.js @@ -349,7 +349,7 @@ program.addOption( ); program.addOption(new Option('-a, --artifactPath ', 'artifact path').makeOptionMandatory(true)); program.addOption(new Option('-c, --contractName ', 'contract name').makeOptionMandatory(true)); -program.addOption(new Option('-n, --chainNames ', 'chain names').makeOptionMandatory(true)); +program.addOption(new Option('-n, --chainNames ', 'chain names').makeOptionMandatory(true).env('CHAINS')); program.addOption(new Option('--skipChains ', 'chains to skip over')); program.addOption( new Option('-m, --deployMethod ', 'deployment method').choices(['create', 'create2', 'create3']).default('create2'), diff --git a/evm/gateway.js b/evm/gateway.js index edac25c4..ec4a68f8 100644 --- a/evm/gateway.js +++ b/evm/gateway.js @@ -339,7 +339,7 @@ program.addOption( ); program.addOption(new Option('-c, --contractName ', 'contract name').default('Multisig')); program.addOption(new Option('-a, --address
', 'override address')); -program.addOption(new Option('-n, --chainNames ', 'chain names').makeOptionMandatory(true)); +program.addOption(new Option('-n, --chainNames ', 'chain names').makeOptionMandatory(true).env('CHAINS')); program.addOption(new Option('--skipChains ', 'chains to skip over')); program.addOption( new Option('--action ', 'gateway action') diff --git a/package.json b/package.json index ae82c3c9..8aecd090 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "lint": "eslint '**/*.js'", - "prettier": "prettier --write '**/*.js' 'axelar-chains-config/info/*.json' 'package.json' 'evm/**/*.json'" + "prettier": "prettier --write '**/*.js' 'axelar-chains-config/info/*.json' 'package.json' 'evm/**/*.json' '.github/**/*.yaml'" }, "repository": { "type": "git", From aab285858837094b5da9abd66faf94dadc581776 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Mon, 30 Oct 2023 02:49:12 -0400 Subject: [PATCH 04/11] chore: use json stringify prettier format (#97) --- .prettierrc | 3 +- axelar-chains-config/info/mainnet.json | 60 +++++++++++++++++++------- evm/.example.keys.json | 5 ++- 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/.prettierrc b/.prettierrc index a2194d80..74eabe89 100644 --- a/.prettierrc +++ b/.prettierrc @@ -20,7 +20,8 @@ { "files": "*.json", "options": { - "tabWidth": 2 + "tabWidth": 2, + "parser": "json-stringify" } }, { diff --git a/axelar-chains-config/info/mainnet.json b/axelar-chains-config/info/mainnet.json index 3132d486..c4e14e50 100644 --- a/axelar-chains-config/info/mainnet.json +++ b/axelar-chains-config/info/mainnet.json @@ -10,7 +10,9 @@ "AxelarGateway": { "address": "0x4F4495243837681061C4743b74B3eEdf548D56A5", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-ethereum-9169970"], + "startingKeyIDs": [ + "evm-ethereum-9169970" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x7d8ba71c940fc633465d77bc7c2b2d7c4d7fcc0d397d8f699d0345fcad136216", "authModule": "0xE3B83f79Fbf01B25659f8A814945aB82186A8AD0", @@ -104,7 +106,9 @@ "tokenDeployer": "0xb28478319B64f8D47e19A120209A211D902F8b8f", "deploymentMethod": "create3", "salt": "AxelarGateway v6.2", - "startingKeyIDs": ["evm-avalanche-9169969"] + "startingKeyIDs": [ + "evm-avalanche-9169969" + ] }, "AxelarGasService": { "salt": "AxelarGasService", @@ -186,7 +190,9 @@ "AxelarGateway": { "address": "0x304acf330bbE08d1e512eefaa92F6a57871fD895", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-fantom-9169993"], + "startingKeyIDs": [ + "evm-fantom-9169993" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x85db006683bdfff99e7e8518d8eb23a89b6174b6c2c4cea2f5e06d66b0e09a9c", "authModule": "0xFcf8b865177c45A86a4977e518B44a1eD90191bd", @@ -277,7 +283,9 @@ "AxelarGateway": { "address": "0x6f015F16De9fC8791b234eF68D486d2bF203FBA8", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-polygon-9170074"], + "startingKeyIDs": [ + "evm-polygon-9170074" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x85db006683bdfff99e7e8518d8eb23a89b6174b6c2c4cea2f5e06d66b0e09a9c", "authModule": "0xFcf8b865177c45A86a4977e518B44a1eD90191bd", @@ -368,7 +376,9 @@ "AxelarGateway": { "address": "0x4F4495243837681061C4743b74B3eEdf548D56A5", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-moonbeam-9169938"], + "startingKeyIDs": [ + "evm-moonbeam-9169938" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x7d8ba71c940fc633465d77bc7c2b2d7c4d7fcc0d397d8f699d0345fcad136216", "authModule": "0xE3B83f79Fbf01B25659f8A814945aB82186A8AD0", @@ -457,7 +467,9 @@ "AxelarGateway": { "address": "0x304acf330bbE08d1e512eefaa92F6a57871fD895", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-binance-9170027"], + "startingKeyIDs": [ + "evm-binance-9170027" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x021b7a78521cc2d80e7010e7b6c0dcb4e1200df45a89f00ee2b88ba60bacccbb", "authModule": "0x242E937CE1B5894bf92c343e56eC63fAe522d627", @@ -548,7 +560,9 @@ "AxelarGateway": { "address": "0xe432150cce91c13a887f7D836923d5597adD8E31", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-arbitrum-9170015"], + "startingKeyIDs": [ + "evm-arbitrum-9170015" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x815c3711b7191c2598de8b4b7d977ac2d1903d20883bd25c26cf2c4a8ca37827", "authModule": "0x96eEE595f0ACD7d232a9B1dE4FCc2a4b2F6b0f3a", @@ -639,7 +653,9 @@ "AxelarGateway": { "address": "0xe432150cce91c13a887f7D836923d5597adD8E31", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-celo-9170074"], + "startingKeyIDs": [ + "evm-celo-9170074" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x815c3711b7191c2598de8b4b7d977ac2d1903d20883bd25c26cf2c4a8ca37827", "authModule": "0x96eEE595f0ACD7d232a9B1dE4FCc2a4b2F6b0f3a", @@ -729,7 +745,9 @@ "AxelarGateway": { "address": "0xe432150cce91c13a887f7D836923d5597adD8E31", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-kava-9169958"], + "startingKeyIDs": [ + "evm-kava-9169958" + ], "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "implementationCodehash": "0x815c3711b7191c2598de8b4b7d977ac2d1903d20883bd25c26cf2c4a8ca37827", "authModule": "0x96eEE595f0ACD7d232a9B1dE4FCc2a4b2F6b0f3a", @@ -819,7 +837,9 @@ "authModule": "0x96eEE595f0ACD7d232a9B1dE4FCc2a4b2F6b0f3a", "tokenDeployer": "0xb28478319B64f8D47e19A120209A211D902F8b8f", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-filecoin-9169887"], + "startingKeyIDs": [ + "evm-filecoin-9169887" + ], "implementationCodehash": "0x815c3711b7191c2598de8b4b7d977ac2d1903d20883bd25c26cf2c4a8ca37827", "deploymentMethod": "create3", "salt": "AxelarGateway v6.2" @@ -911,7 +931,9 @@ "authModule": "0x96eEE595f0ACD7d232a9B1dE4FCc2a4b2F6b0f3a", "tokenDeployer": "0xb28478319B64f8D47e19A120209A211D902F8b8f", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-optimism-9169964"], + "startingKeyIDs": [ + "evm-optimism-9169964" + ], "implementationCodehash": "0x815c3711b7191c2598de8b4b7d977ac2d1903d20883bd25c26cf2c4a8ca37827", "deploymentMethod": "create3", "salt": "AxelarGateway v6.2" @@ -1003,7 +1025,9 @@ "authModule": "0x96eEE595f0ACD7d232a9B1dE4FCc2a4b2F6b0f3a", "tokenDeployer": "0xb28478319B64f8D47e19A120209A211D902F8b8f", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-linea-9169923"], + "startingKeyIDs": [ + "evm-linea-9169923" + ], "implementationCodehash": "0x815c3711b7191c2598de8b4b7d977ac2d1903d20883bd25c26cf2c4a8ca37827", "deploymentMethod": "create3", "salt": "AxelarGateway v6.2" @@ -1091,7 +1115,9 @@ "authModule": "0x96eEE595f0ACD7d232a9B1dE4FCc2a4b2F6b0f3a", "tokenDeployer": "0xb28478319B64f8D47e19A120209A211D902F8b8f", "deployer": "0x6f24A47Fc8AE5441Eb47EFfC3665e70e69Ac3F05", - "startingKeyIDs": ["evm-base-9169992"], + "startingKeyIDs": [ + "evm-base-9169992" + ], "implementationCodehash": "0x815c3711b7191c2598de8b4b7d977ac2d1903d20883bd25c26cf2c4a8ca37827", "deploymentMethod": "create3", "salt": "AxelarGateway v6.2" @@ -1180,7 +1206,9 @@ "implementation": "0x99B5FA03a5ea4315725c43346e55a6A6fbd94098", "authModule": "0x4EC83aE13097EF1Fb1dC9fC98592bf607A22A55D", "tokenDeployer": "0xb28478319B64f8D47e19A120209A211D902F8b8f", - "startingKeyIDs": ["evm-mantle-9169917"], + "startingKeyIDs": [ + "evm-mantle-9169917" + ], "implementationCodehash": "0x44a3e78ebfbd139f4023ba77ffced61aeea29f0a20eec807d260e805e272c5c9", "deploymentMethod": "create3", "salt": "AxelarGateway v6.2" @@ -1274,7 +1302,9 @@ "implementationCodehash": "0xbfae4d9f9280a802bd594ee14e35b2da6bfb5e89d2542c366faaa96702ece420", "authModule": "0xdC46f07661B673Fc262f61FC5b05B10A58a3b7fE", "tokenDeployer": "0xb28478319B64f8D47e19A120209A211D902F8b8f", - "startingKeyIDs": ["evm-scroll-genesis"], + "startingKeyIDs": [ + "evm-scroll-genesis" + ], "deploymentMethod": "create3", "salt": "AxelarGateway v6.2" }, diff --git a/evm/.example.keys.json b/evm/.example.keys.json index e69e60ea..f08c51e9 100644 --- a/evm/.example.keys.json +++ b/evm/.example.keys.json @@ -7,5 +7,8 @@ "api": "EXPLORER_API_KEY" } }, - "accounts": ["private key 1", "private key 2"] + "accounts": [ + "private key 1", + "private key 2" + ] } From 9e87c683d33061014089ff6c1a6856feb5c4d8ef Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Mon, 30 Oct 2023 03:34:45 -0400 Subject: [PATCH 05/11] fix: misc script fixes (#98) --- evm/check-wallet-balance.js | 4 ++-- evm/deploy-contract.js | 2 +- evm/deploy-gateway-v6.2.x.js | 11 ++++++----- evm/governance.js | 9 +++++---- evm/send-tokens.js | 4 ++-- evm/sign-utils.js | 17 +++++++++-------- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/evm/check-wallet-balance.js b/evm/check-wallet-balance.js index 5d65cb2b..8c0553a3 100644 --- a/evm/check-wallet-balance.js +++ b/evm/check-wallet-balance.js @@ -20,8 +20,8 @@ async function processCommand(_, chain, options) { return; } - const gasLimit = BigNumber.from(staticGasOptions.gasLimit); - const gasPrice = BigNumber.from(staticGasOptions.gasPrice); + const gasLimit = BigNumber.from(chain.staticGasOptions.gasLimit); + const gasPrice = BigNumber.from(chain.eip1559 ? staticGasOptions.maxFeePerGas : staticGasOptions.gasPrice); const minRequiredBalance = gasLimit * gasPrice * 1.5; printError(`${chain.name} minimum required Balance`, `${minRequiredBalance / 1e18}`); diff --git a/evm/deploy-contract.js b/evm/deploy-contract.js index d03c77b7..a444ccbf 100644 --- a/evm/deploy-contract.js +++ b/evm/deploy-contract.js @@ -358,7 +358,7 @@ program.addOption(new Option('-p, --privateKey ', 'private key').mak program.addOption(new Option('-s, --salt ', 'salt to use for create2 deployment')); program.addOption(new Option('-v, --verify ', 'verify the deployed contract on the explorer').env('VERIFY')); program.addOption(new Option('-y, --yes', 'skip deployment prompt confirmation').env('YES')); -program.addOption(new Option('-x, --skipExisting', 'skip existing if contract was already deployed on chain').env('YES')); +program.addOption(new Option('-x, --skipExisting', 'skip existing if contract was already deployed on chain')); program.addOption(new Option('--ignoreError', 'ignore errors during deployment for a given chain')); program.action((options) => { diff --git a/evm/deploy-gateway-v6.2.x.js b/evm/deploy-gateway-v6.2.x.js index 5575781d..bcf5145a 100644 --- a/evm/deploy-gateway-v6.2.x.js +++ b/evm/deploy-gateway-v6.2.x.js @@ -97,8 +97,8 @@ async function deploy(config, chain, options) { } const contractConfig = chain.contracts[contractName]; - const governance = options.governance || contractConfig.governance; - const mintLimiter = options.mintLimiter || contractConfig.mintLimiter; + const governance = options.governance || contractConfig.governance || chain.contracts.InterchainGovernance?.address; + const mintLimiter = options.mintLimiter || contractConfig.mintLimiter || chain.contracts.Multisig?.address; if (!reuseProxy) { if (governance === undefined) { @@ -374,8 +374,8 @@ async function upgrade(_, chain, options) { const gateway = new Contract(contractConfig.address, AxelarGateway.abi, wallet); let implementationCodehash = contractConfig.implementationCodehash; - let governance = options.governance || contractConfig.governance; - let mintLimiter = options.mintLimiter || contractConfig.mintLimiter; + let governance = options.governance || contractConfig.governance || chain.contracts.InterchainGovernance?.address; + let mintLimiter = options.mintLimiter || contractConfig.mintLimiter || chain.contracts.Multisig?.address; let setupParams = '0x'; contractConfig.governance = governance; contractConfig.mintLimiter = mintLimiter; @@ -476,7 +476,7 @@ async function main(options) { async function programHandler() { const program = new Command(); - program.name('deploy-gateway-v5.x').description('Deploy gateway v5.x'); + program.name('deploy-gateway-v6.2.x').description('Deploy gateway v6.2.x'); program.addOption( new Option('-e, --env ', 'environment') @@ -510,6 +510,7 @@ async function programHandler() { program.addOption(new Option('-u, --upgrade', 'upgrade gateway').env('UPGRADE')); program.addOption(new Option('--offline', 'Run in offline mode')); program.addOption(new Option('--nonceOffset ', 'The value to add in local nonce if it deviates from actual wallet nonce')); + program.addOption(new Option('-x, --skipExisting', 'skip existing if contract was already deployed on chain')); program.action((options) => { main(options); diff --git a/evm/governance.js b/evm/governance.js index 99e96b72..83953b06 100644 --- a/evm/governance.js +++ b/evm/governance.js @@ -8,6 +8,7 @@ const { utils: { defaultAbiCoder, keccak256, Interface, parseEther }, Contract, BigNumber, + constants: { AddressZero }, } = ethers; const { Command, Option } = require('commander'); const { @@ -41,16 +42,16 @@ async function getGatewaySetupParams(governance, gateway, contracts, options) { printWarn(`Gateway governor ${currGovernance} does not match governance contract: ${governance.address}`); } - let newGovernance = options.newGovernance || contracts.AxelarGateway?.governance; + let newGovernance = options.newGovernance || contracts.InterchainGovernance?.address; if (newGovernance === currGovernance) { - newGovernance = '0x'; + newGovernance = AddressZero; } - let newMintLimiter = options.newMintLimiter || contracts.AxelarGateway?.mintLimiter; + let newMintLimiter = options.newMintLimiter || contracts.Multisig?.address; if (newMintLimiter === `${currMintLimiter}`) { - newMintLimiter = '0x'; + newMintLimiter = AddressZero; } let setupParams = '0x'; diff --git a/evm/send-tokens.js b/evm/send-tokens.js index 5155f213..cf0548f0 100644 --- a/evm/send-tokens.js +++ b/evm/send-tokens.js @@ -15,7 +15,7 @@ const { storeSignedTx, getWallet, signTransaction } = require('./sign-utils.js') async function processCommand(_, chain, options) { const { privateKey, offline, env } = options; - let { amount: amountStr, recipients } = options; + let { amount: amountStr, recipients, nonceOffset } = options; const chainName = chain.name.toLowerCase(); const provider = getDefaultProvider(chain.rpc); @@ -88,7 +88,7 @@ async function processCommand(_, chain, options) { storeSignedTx(filePath, data); - options.nonceOffset = (parseInt(options.nonceOffset) || 0) + 1; + nonceOffset = (parseInt(nonceOffset) || 0) + 1; } } } diff --git a/evm/sign-utils.js b/evm/sign-utils.js index 0ede949e..60ae0c0d 100644 --- a/evm/sign-utils.js +++ b/evm/sign-utils.js @@ -59,14 +59,14 @@ const signTransaction = async (wallet, chain, tx, options = {}) => { throw new Error('Target address is missing/not provided as valid address for the tx in function arguments'); } - if (options.gasOptions) { - tx = { - ...options.gasOptions, - ...tx, // prefer gas options from tx if they were set - }; - } - if (!options.offline) { + if (options.gasOptions) { + tx = { + ...options.gasOptions, + ...tx, // prefer gas options from tx if they were set + }; + } + tx = await wallet.populateTransaction(tx); } else { const address = options.signerAddress || (await wallet.getAddress()); @@ -269,7 +269,8 @@ const updateNonceFileData = (nonceData) => { const getLocalNonce = (env, chainName, signerAddress) => { const nonceData = getNonceFileData(); - return nonceData[env][chainName][signerAddress]; + const chainData = nonceData[env] ? nonceData[env][chainName] : undefined; + return chainData ? chainData[signerAddress] : undefined; }; const updateLocalNonce = (chain, nonce, signerAddress) => { From a3c842a5f42476d65d105d3168c70e2a9ad75795 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Mon, 30 Oct 2023 22:31:00 +0530 Subject: [PATCH 06/11] fix: use custom rpcs instead of tenderly rpcs --- .../handle-failed-tx-action/handle-failed-tx/handleFailedTx.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js index e258c34d..1bf11a06 100644 --- a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js +++ b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js @@ -8,8 +8,7 @@ const PAGER_DUTY_ALERT_URL = 'https://events.pagerduty.com/v2/enqueue'; const handleFailedTxFn = async (context, event) => { const chainName = context.metadata.getNetwork(); - const rpc = context.gateways.getGateway(chainName); - const provider = new ethers.providers.JsonRpcProvider(rpc); + const provider = new ethers.providers.JsonRpcProvider(await context.secrets.get(`RPC_${chainName.toUpperCase()}`)); const tx = await provider.getTransaction(event.hash); const response = await provider.call(tx, tx.blockNumber); From 3d6cf763f2371624172fb45d17de3d7fb7d99d7e Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Wed, 1 Nov 2023 19:58:41 +0530 Subject: [PATCH 07/11] refactor: updated error hashes for edited rolebase errors --- .../handle-failed-tx/handleFailedTx.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js index 1bf11a06..ce3e0722 100644 --- a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js +++ b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js @@ -23,10 +23,10 @@ const handleFailedTxFn = async (context, event) => { case '0xbb6c1639': warningOptions = ['MissingRole', '-']; break; - case '0x90a6e7d6': + case '0x7fa6fbb4': warningOptions = ['MissingAllRoles', '-']; break; - case '0xb94d593e': + case '0x218de251': warningOptions = ['MissingAnyOfRoles', '-']; break; case '0xb078d99c': From b7f31679dea1710d436cb30110706c510fa5f8d7 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Wed, 1 Nov 2023 20:26:44 +0530 Subject: [PATCH 08/11] refactor: resolve PR comments --- .../add-to-project/addToProject.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js index da3de7d3..4dfdada3 100644 --- a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js +++ b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js @@ -7,10 +7,19 @@ const addToProjectFn = async (context, event) => { const logs = event.logs; const contracts = []; + if (!event || !event.logs || !context || !context.metadata) { + throw new Error('INVALID_INPUT_FOR_ACTION'); + } + for (let index = 0; index < logs.length; ++index) { if (logs[index].topics[0] === TOKEN_MANAGER_DEPLOYED_TOPIC0) { + if(logs[index].data.length < 66){ + throw new Error('INVALID_LOG_DATA_LENGTH'); + } + + // log data contains address in first 32 bytes i.e. first 64 chars, here data string is also prefixed with 0x. const deployedAddress = '0x' + logs[index].data.substring(26, 66); - const name = `TokenManager-${context.metadata.getNetwork()}-${deployedAddress}`; // TokenManager + network + address + const name = `TokenManager-${context.metadata.getNetwork()}-${deployedAddress}`; contracts.push({ address: deployedAddress, From 6b566006cd6e8f7c58f8175e9254516022eca6c1 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Wed, 1 Nov 2023 21:47:11 +0530 Subject: [PATCH 09/11] refactor: resolve pr comments --- .../handle-failed-tx/handleFailedTx.js | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js index ce3e0722..fd9f1523 100644 --- a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js +++ b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js @@ -1,9 +1,6 @@ const axios = require('axios').default; const { ethers } = require('ethers'); -const WARNING_THRESHOLD = 10; // TODO: discuss for production -const CRITICAL_THRESHOLD = 20; -const TIME_SPLIT = 5 * 3600 * 1000; // 5 hours in milliseconds const PAGER_DUTY_ALERT_URL = 'https://events.pagerduty.com/v2/enqueue'; const handleFailedTxFn = async (context, event) => { @@ -11,7 +8,20 @@ const handleFailedTxFn = async (context, event) => { const provider = new ethers.providers.JsonRpcProvider(await context.secrets.get(`RPC_${chainName.toUpperCase()}`)); const tx = await provider.getTransaction(event.hash); + const warningThreshold = await context.storage.getStr('WarningThreshold'); + const criticalThreshold = await context.storage.getStr('CriticalThreshold'); + const timeSplit = await context.storage.getStr('TimeSplit'); + + if (!tx.to || !tx.from || !tx.blockNumber || !tx.data) { + throw new Error('INVALID_TX_FORMAT'); + } + const response = await provider.call(tx, tx.blockNumber); + + if (response.length < 10) { + throw new Error('INVALID_RESPONSE_LENGTH'); + } + const errorHash = response.slice(0, 10); console.log('errorHash: ', errorHash); let warningOptions = []; @@ -21,13 +31,13 @@ const handleFailedTxFn = async (context, event) => { warningOptions = ['FlowLimitExceeded', 'TokenManager']; break; case '0xbb6c1639': - warningOptions = ['MissingRole', '-']; + warningOptions = ['MissingRole', event.to]; break; case '0x7fa6fbb4': - warningOptions = ['MissingAllRoles', '-']; + warningOptions = ['MissingAllRoles', event.to]; break; case '0x218de251': - warningOptions = ['MissingAnyOfRoles', '-']; + warningOptions = ['MissingAnyOfRoles', event.to]; break; case '0xb078d99c': warningOptions = ['ReEntrancy', 'TokenManager']; @@ -40,7 +50,7 @@ const handleFailedTxFn = async (context, event) => { } if (warningOptions.length !== 0) { - await sendWarning(event, context, chainName, ...warningOptions, 'info'); + await sendWarning(event, context, chainName, ...warningOptions, Severity.INFO); } const failedTxStartTime = await context.storage.getNumber('FailedTxStartTimestamp'); @@ -48,30 +58,30 @@ const handleFailedTxFn = async (context, event) => { const timeNow = Date.now(); - if (timeNow - failedTxStartTime > TIME_SPLIT) { + if (timeNow - failedTxStartTime > timeSplit) { console.log('Updating Time stamp'); failedTxCount = 1; await context.storage.putNumber('FailedTxStartTimestamp', timeNow); } else { failedTxCount++; - if (failedTxCount >= CRITICAL_THRESHOLD) { + if (failedTxCount >= criticalThreshold) { await sendWarning( event, context, chainName, `Threshold crossed for failed transactions: ${failedTxCount}`, 'ITS_PROJECT', - 'critical', + Severity.CRITICAL, ); - } else if (failedTxCount >= WARNING_THRESHOLD) { + } else if (failedTxCount >= warningThreshold) { await sendWarning( event, context, chainName, `Threshold crossed for failed transactions: ${failedTxCount}`, 'ITS_PROJECT', - 'warning', + Severity.WARNING, ); } } @@ -108,4 +118,11 @@ async function sendWarning(event, context, chainName, summary, source, severity) } } +const Severity = { + INFO: 'info', + CRITICAL: 'critical', + WARNING: 'warning', +}; + + module.exports = { handleFailedTxFn }; From 0649c8adbd3308a0c24105f821cbb7b1d2b86fc6 Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Wed, 1 Nov 2023 22:02:59 +0530 Subject: [PATCH 10/11] refactor: lint --- .../handle-failed-tx-action/handle-failed-tx/handleFailedTx.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js index fd9f1523..b353183b 100644 --- a/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js +++ b/tenderly-suite/handle-failed-tx-action/handle-failed-tx/handleFailedTx.js @@ -124,5 +124,4 @@ const Severity = { WARNING: 'warning', }; - module.exports = { handleFailedTxFn }; From 39876eec8a6a3a7d78a314161fb1c39b85fad90a Mon Sep 17 00:00:00 2001 From: blockchainguyy Date: Wed, 1 Nov 2023 22:13:08 +0530 Subject: [PATCH 11/11] refactor: lint --- .../add-to-project-action/add-to-project/addToProject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js index 4dfdada3..3f6c7e76 100644 --- a/tenderly-suite/add-to-project-action/add-to-project/addToProject.js +++ b/tenderly-suite/add-to-project-action/add-to-project/addToProject.js @@ -13,7 +13,7 @@ const addToProjectFn = async (context, event) => { for (let index = 0; index < logs.length; ++index) { if (logs[index].topics[0] === TOKEN_MANAGER_DEPLOYED_TOPIC0) { - if(logs[index].data.length < 66){ + if (logs[index].data.length < 66) { throw new Error('INVALID_LOG_DATA_LENGTH'); }