Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: script optimizations #99

Merged
merged 8 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ jobs:
"chainId": 31337,
"rpc": "http://127.0.0.1:8545",
"tokenSymbol": "TEST",
"contracts": {}
"contracts": {
"InterchainGovernance": {
"minimumTimeDelay": 3600
},
"AxelarServiceGovernance": {
"minimumTimeDelay": 3600
}
}
}
}
}' > ./axelar-chains-config/info/local.json
Expand All @@ -52,13 +59,58 @@ 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 AxelarServiceGovernance using create
run: node evm/deploy-contract.js -c AxelarServiceGovernance -m create -y

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

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

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

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

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

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

- name: Deploy Operators using create2
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
run: node evm/deploy-contract.js -c Operators -m create2 -y

- name: Deploy TokenDeployer using create2
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
run: node evm/deploy-contract.js -c TokenDeployer -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

- name: Deploy TokenDeployer using create3
run: node evm/deploy-contract.js -c TokenDeployer -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) {

milapsheth marked this conversation as resolved.
Show resolved Hide resolved
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'),
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
);
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));
blockchainguyy marked this conversation as resolved.
Show resolved Hide resolved
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
Loading