Skip to content

Commit

Permalink
feat: script optimizations (#99)
Browse files Browse the repository at this point in the history
* feat: script optimizations

* feat: address comments

* feat: address comments

* feat: add to gh action test

* feat: test different deployment methods in gh action

* feat: address comments

---------

Co-authored-by: Dean Amiel <[email protected]>
  • Loading branch information
deanamiel and Dean Amiel authored Nov 7, 2023
1 parent 05756e3 commit bc7d6c0
Show file tree
Hide file tree
Showing 25 changed files with 557 additions and 548 deletions.
45 changes: 42 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,28 @@ jobs:
"chainId": 31337,
"rpc": "http://127.0.0.1:8545",
"tokenSymbol": "TEST",
"contracts": {}
"contracts": {
"InterchainGovernance": {
"minimumTimeDelay": 3600
},
"AxelarServiceGovernance": {
"minimumTimeDelay": 3600,
"cosigners": [
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
],
"threshold": 2
},
"Multisig": {
"signers": [
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
],
"threshold": 2
}
}
}
}
}' > ./axelar-chains-config/info/local.json
Expand All @@ -52,13 +73,31 @@ jobs:
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
run: node evm/deploy-contract.js -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
run: node evm/deploy-contract.js -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

- name: Deploy InterchainGovernance using create
run: node evm/deploy-contract.js -c InterchainGovernance -m create -y

- name: Deploy InterchainGovernance using create2
run: node evm/deploy-contract.js -c InterchainGovernance -m create2 -y

- name: Deploy InterchainGovernance using create3
run: node evm/deploy-contract.js -c InterchainGovernance -m create3 -y

- name: Deploy AxelarServiceGovernance using create3
run: node evm/deploy-contract.js -c AxelarServiceGovernance -m create3 -y

- name: Deploy Multisig using create3
run: node evm/deploy-contract.js -c Multisig -m create3 -y

- name: Deploy Operators using create3
run: node evm/deploy-contract.js -c Operators -m create3 -y
13 changes: 3 additions & 10 deletions evm/balances.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ require('dotenv').config();

const { ethers } = require('hardhat');
const { getDefaultProvider } = ethers;
const { Command, Option } = require('commander');
const { Command } = require('commander');
const { mainProcessor, printWalletInfo, printInfo } = require('./utils');
const { addBaseOptions } = require('./cli-utils');
const { getWallet } = require('./sign-utils');

async function processCommand(_, chain, options) {
Expand All @@ -26,15 +27,7 @@ if (require.main === module) {

program.name('balances').description('Display balance of the wallet on specified chains.');

program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'stagenet', 'testnet', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
);
program.addOption(new Option('-n, --chainNames <chainNames>', 'chain names').makeOptionMandatory(true).env('CHAINS'));
program.addOption(new Option('-p, --privateKey <privateKey>', 'private key').makeOptionMandatory(true).env('PRIVATE_KEY'));
addBaseOptions(program);

program.action((options) => {
main(options);
Expand Down
28 changes: 12 additions & 16 deletions evm/broadcast-transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
} = ethers;

const { printError, printInfo, printWarn, getConfigByChainId, prompt, loadConfig } = require('./utils');
const { addBaseOptions } = require('./cli-utils');
const { sendTransaction, getSignedTx, storeSignedTx } = require('./sign-utils');

async function processCommand(config, _, options, file) {
Expand Down Expand Up @@ -71,23 +72,18 @@ async function main(options) {
}
}

const program = new Command();
if (require.main === module) {
const program = new Command();

program.name('broadcast-transactions').description('Broadcast all the pending signed transactions of the signer');
program.name('broadcast-transactions').description('Broadcast all the pending signed transactions of the signer');

program.addOption(new Option('--files [files...]', 'The file where the signed tx are stored').makeOptionMandatory(true));
program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'stagenet', 'testnet', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
);
program.addOption(new Option('-r, --rpc <rpc>', 'The chain rpc'));
program.addOption(new Option('-y, --yes', 'skip prompts'));
program.addOption(new Option('--files [files...]', 'The file where the signed tx are stored').makeOptionMandatory(true));
addBaseOptions(program, { ignoreChainNames: true });
program.addOption(new Option('-r, --rpc <rpc>', 'The chain rpc'));

program.action((options) => {
main(options);
});
program.action((options) => {
main(options);
});

program.parse();
program.parse();
}
29 changes: 13 additions & 16 deletions evm/check-wallet-balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { ethers } = require('hardhat');
const { getDefaultProvider, BigNumber } = ethers;

const { printError, mainProcessor } = require('./utils');
const { addBaseOptions } = require('./cli-utils');
const { getNonceFileData } = require('./sign-utils');

async function processCommand(_, chain, options) {
Expand Down Expand Up @@ -47,23 +48,19 @@ async function main(options) {
await mainProcessor(options, processCommand);
}

const program = new Command();
if (require.main === module) {
const program = new Command();

program.name('check-wallet-balance').description('Before offline signing checks if each signer has minimum required wallet balance');
program.name('check-wallet-balance').description('Before offline signing checks if each signer has minimum required wallet balance');

program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'stagenet', 'testnet', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
);
program.addOption(new Option('-n, --chainNames <chainNames>', 'chain names').makeOptionMandatory(true));
program.addOption(new Option('-r, --rpc <rpc>', 'The rpc url for creating a provider to fetch gasOptions'));
program.addOption(new Option('--addresses <addresses>', 'The Array of addresses for which the balance to check').env('ADDRESSES'));
addBaseOptions(program, { ignorePrivateKey: true });

program.action((options) => {
main(options);
});
program.addOption(new Option('-r, --rpc <rpc>', 'The rpc url for creating a provider to fetch gasOptions'));
program.addOption(new Option('--addresses <addresses>', 'The Array of addresses for which the balance to check').env('ADDRESSES'));

program.parse();
program.action((options) => {
main(options);
});

program.parse();
}
64 changes: 64 additions & 0 deletions evm/cli-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'use strict';

const { Option } = require('commander');

const addBaseOptions = (program, options = {}) => {
program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'stagenet', 'testnet', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
);
program.addOption(new Option('-y, --yes', 'skip deployment prompt confirmation').env('YES'));

if (!options.ignoreChainNames) {
program.addOption(
new Option('-n, --chainNames <chainNames>', 'chains to run the script over').makeOptionMandatory(true).env('CHAINS'),
);
program.addOption(new Option('--skipChains <skipChains>', 'chains to skip over'));
}

if (!options.ignorePrivateKey) {
program.addOption(new Option('-p, --privateKey <privateKey>', 'private key').makeOptionMandatory(true).env('PRIVATE_KEY'));
}

if (options.address) {
program.addOption(new Option('-a, --address <address>', 'override address'));
}

return program;
};

const addExtendedOptions = (program, options = {}) => {
addBaseOptions(program, options);

program.addOption(new Option('-v, --verify', 'verify the deployed contract on the explorer').env('VERIFY'));

if (options.artifactPath) {
program.addOption(new Option('-a, --artifactPath <artifactPath>', 'artifact path'));
}

if (options.contractName) {
program.addOption(new Option('-c, --contractName <contractName>', 'contract name').makeOptionMandatory(true));
}

if (options.salt) {
program.addOption(new Option('-s, --salt <salt>', 'salt to use for create2 deployment').env('SALT'));
}

if (options.skipExisting) {
program.addOption(new Option('-x, --skipExisting', 'skip existing if contract was already deployed on chain').env('SKIP_EXISTING'));
}

if (options.upgrade) {
program.addOption(new Option('-u, --upgrade', 'upgrade a deployed contract').env('UPGRADE'));
}

return program;
};

module.exports = {
addBaseOptions,
addExtendedOptions,
};
16 changes: 4 additions & 12 deletions evm/deploy-const-address-deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ const { Command, Option } = require('commander');
const chalk = require('chalk');

const { printInfo, writeJSON, predictAddressCreate, deployCreate } = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const contractJson = require('@axelar-network/axelar-gmp-sdk-solidity/artifacts/contracts/deploy/ConstAddressDeployer.sol/ConstAddressDeployer.json');
const contractName = 'ConstAddressDeployer';

async function deployConstAddressDeployer(wallet, chain, options = null, verifyOptions = null) {
async function deployConstAddressDeployer(wallet, chain, options = {}, verifyOptions = null) {
printInfo('Deployer address', wallet.address);

const contracts = chain.contracts;
Expand Down Expand Up @@ -125,19 +126,10 @@ if (require.main === module) {

program.name('deploy-const-address-deployer').description('Deploy const address deployer');

program.addOption(
new Option('-e, --env <env>', 'environment')
.choices(['local', 'devnet', 'stagenet', 'testnet', 'mainnet'])
.default('testnet')
.makeOptionMandatory(true)
.env('ENV'),
);
program.addOption(new Option('-n, --chainNames <chainNames>', 'chain names').makeOptionMandatory(true));
program.addOption(new Option('-p, --privateKey <privateKey>', 'private key').makeOptionMandatory(true).env('PRIVATE_KEY'));
addExtendedOptions(program);

program.addOption(new Option('-i, --ignore', 'ignore the nonce value check'));
program.addOption(new Option('-v, --verify', 'verify the deployed contract on the explorer').env('VERIFY'));
program.addOption(new Option('-f, --force', 'proceed with contract deployment even if address already returns a bytecode'));
program.addOption(new Option('-y, --yes', 'skip deployment prompt confirmation').env('YES'));

program.action((options) => {
main(options);
Expand Down
Loading

0 comments on commit bc7d6c0

Please sign in to comment.