Skip to content

Commit

Permalink
Merge branch 'main' into its-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Dec 4, 2023
2 parents 52dcd7d + c915436 commit 0654570
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 79 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ jobs:

- name: InterchainTokenService deploy interchain token on current chain
run: node evm/its.js --action deployInterchainToken --name "test" --symbol "TST" --decimals 18 --distributor 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 --destinationChain '' --gasValue 0 --salt "salt" -y

- name: Add gasOptions to local.json
run: |
jq '.chains.test += {"gasOptions": {"gasLimit": 8000000}} | .chains.test.contracts.AxelarGateway += {"gasOptions": {"gasLimit": 8000000}}' ./axelar-chains-config/info/local.json > temp.json && mv temp.json ./axelar-chains-config/info/local.json
- name: Redeploy AxelarGateway with gasOptions
run: node evm/deploy-gateway-v6.2.x.js -m create3 -s "AxelarGateway v6.2" --governance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --mintLimiter 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --keyID 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -y

- name: Redeploy ITS with gasOptions in Chain Config
run: node evm/deploy-its.js -s "ITS v1.0.0" -f "ITS v1.0.0 Factory" -m create2 -y
9 changes: 6 additions & 3 deletions axelar-chains-config/info/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@
"api": "https://api.ftmscan.com/api"
},
"gasOptions": {
"gasLimit": 5000000
"gasLimit": 5000000,
"gasPriceAdjustment": 1.4
},
"staticGasOptions": {
"gasLimit": 3000000,
Expand Down Expand Up @@ -363,7 +364,8 @@
"api": "https://api.polygonscan.com/api"
},
"gasOptions": {
"gasLimit": 6000000
"gasLimit": 6000000,
"gasPriceAdjustment": 1.6
},
"staticGasOptions": {
"gasLimit": 3000000,
Expand Down Expand Up @@ -547,7 +549,8 @@
"api": "https://api.bscscan.com/api"
},
"gasOptions": {
"gasLimit": 8000000
"gasLimit": 8000000,
"gasPriceAdjustment": 1.4
},
"staticGasOptions": {
"gasLimit": 3000000,
Expand Down
5 changes: 2 additions & 3 deletions evm/deploy-const-address-deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const readlineSync = require('readline-sync');
const { Command, Option } = require('commander');
const chalk = require('chalk');

const { printInfo, writeJSON, predictAddressCreate, deployCreate } = require('./utils');
const { printInfo, writeJSON, predictAddressCreate, deployCreate, getGasOptions } = 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';
Expand Down Expand Up @@ -48,8 +48,7 @@ async function deployConstAddressDeployer(wallet, chain, options = {}, verifyOpt

console.log(`Deployer has ${balance / 1e18} ${chalk.green(chain.tokenSymbol)} and nonce ${nonce} on ${chain.name}.`);

const gasOptions = contractConfig.gasOptions || chain.gasOptions || {};
console.log(`Gas override for chain ${chain.name}: ${JSON.stringify(gasOptions)}`);
const gasOptions = await getGasOptions(chain, options, contractName);

const constAddressDeployerAddress = await predictAddressCreate(wallet.address, nonce);
printInfo('ConstAddressDeployer will be deployed to', constAddressDeployerAddress);
Expand Down
10 changes: 2 additions & 8 deletions evm/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
printInfo,
printWarn,
printError,
copyObject,
getGasOptions,
isNonEmptyString,
isNumber,
isAddressArray,
Expand Down Expand Up @@ -255,15 +255,9 @@ async function processCommand(config, chain, options) {
printInfo('Pre-deploy Contract bytecode hash', predeployCodehash);

const constructorArgs = await getConstructorArgs(contractName, chain, wallet, options);
const gasOptions = copyObject(contractConfig.gasOptions || chain.gasOptions || {});

// Some chains require a gas adjustment
if (env === 'mainnet' && !gasOptions.gasPrice && (chain.name === 'Fantom' || chain.name === 'Binance' || chain.name === 'Polygon')) {
gasOptions.gasPrice = Math.floor((await provider.getGasPrice()) * 1.6);
}
const gasOptions = await getGasOptions(chain, options, contractName);

printInfo(`Constructor args for chain ${chain.name}`, constructorArgs);
printInfo(`Gas override for chain ${chain.name}`, JSON.stringify(gasOptions, null, 2));

const salt = options.salt || contractName;
let deployerContract = deployMethod === 'create3' ? contracts.Create3Deployer?.address : contracts.ConstAddressDeployer?.address;
Expand Down
12 changes: 6 additions & 6 deletions evm/deploy-create3-deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const { predictContractConstant } = require('@axelar-network/axelar-gmp-sdk-soli
const { Command } = require('commander');
const chalk = require('chalk');

const { printInfo, writeJSON, deployCreate2 } = require('./utils');
const { printInfo, writeJSON, deployCreate2, getGasOptions } = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const contractJson = require('@axelar-network/axelar-gmp-sdk-solidity/artifacts/contracts/deploy/Create3Deployer.sol/Create3Deployer.json');
const { deployConstAddressDeployer } = require('./deploy-const-address-deployer');
const contractName = 'Create3Deployer';

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

console.log(
Expand All @@ -31,8 +31,7 @@ async function deployCreate3Deployer(wallet, chain, options = {}, verifyOptions
}

const contractConfig = contracts[contractName];
const gasOptions = contractConfig.gasOptions || chain.gasOptions || {};
console.log(`Gas override for chain ${chain.name}: ${JSON.stringify(gasOptions)}`);
const gasOptions = await getGasOptions(chain, options, contractName);

const salt = options.salt || contractName;
printInfo('Create3 deployer deployment salt', salt);
Expand Down Expand Up @@ -74,18 +73,19 @@ async function main(options) {
const verifyOptions = options.verify ? { env: options.env, chain: chain.name, only: options.verify } : null;

let wallet;
let provider;

if (options.env === 'local') {
const [funder] = await ethers.getSigners();
wallet = new Wallet(options.privateKey, funder.provider);
await (await funder.sendTransaction({ to: wallet.address, value: BigInt(1e21) })).wait();
await deployConstAddressDeployer(wallet, config.chains[chains[0].toLowerCase()]);
} else {
const provider = getDefaultProvider(chain.rpc);
provider = getDefaultProvider(chain.rpc);
wallet = new Wallet(options.privateKey, provider);
}

await deployCreate3Deployer(wallet, chain, { salt: options.salt, yes: options.yes }, verifyOptions);
await deployCreate3Deployer(wallet, chain, provider, { salt: options.salt, yes: options.yes }, verifyOptions);
writeJSON(config, `${__dirname}/../axelar-chains-config/info/${options.env}.json`);
}
}
Expand Down
8 changes: 4 additions & 4 deletions evm/deploy-gateway-v4.3.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
isAddressArray,
isNumber,
prompt,
getGasOptions,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { ethers } = require('hardhat');
Expand Down Expand Up @@ -65,8 +66,8 @@ async function deploy(config, options) {
});
printInfo('Predicted proxy address', proxyAddress);

const gasOptions = contractConfig.gasOptions || chain.gasOptions || { gasLimit: 6e6 };
printInfo('Gas override', JSON.stringify(gasOptions, null, 2));
const gasOptions = await getGasOptions(chain, options, contractName);

printInfo('Is verification enabled?', verify ? 'y' : 'n');
printInfo('Skip existing contracts?', skipExisting ? 'y' : 'n');

Expand Down Expand Up @@ -272,8 +273,7 @@ async function upgrade(config, options) {
printInfo('Upgrading to implementation', contractConfig.implementation);
printInfo('Implementation codehash', implementationCodehash);

const gasOptions = contractConfig.gasOptions || chain.gasOptions || {};
printInfo('Gas options', JSON.stringify(gasOptions, null, 2));
const gasOptions = await getGasOptions(chain, options, contractName);

if (prompt(`Proceed with upgrade on ${chain.name}?`, yes)) {
return;
Expand Down
16 changes: 5 additions & 11 deletions evm/deploy-gateway-v6.2.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const {
mainProcessor,
isContract,
deployContract,
getGasOptions,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const { storeSignedTx, signTransaction, getWallet } = require('./sign-utils.js');
Expand Down Expand Up @@ -82,7 +83,7 @@ function getProxyParams(governance, mintLimiter) {
}

async function deploy(config, chain, options) {
const { env, privateKey, reuseProxy, reuseHelpers, verify, yes } = options;
const { privateKey, reuseProxy, reuseHelpers, verify, yes } = options;

const contractName = 'AxelarGateway';

Expand Down Expand Up @@ -131,14 +132,8 @@ async function deploy(config, chain, options) {
printInfo('MintLimiter address', mintLimiter);
}

const gasOptions = JSON.parse(JSON.stringify(contractConfig.gasOptions || chain.gasOptions || {}));
const gasOptions = await getGasOptions(chain, options, contractName);

// Some chains require a gas adjustment
if (env === 'mainnet' && !gasOptions.gasPrice && (chain.name === 'Fantom' || chain.name === 'Binance' || chain.name === 'Polygon')) {
gasOptions.gasPrice = Math.floor((await provider.getGasPrice()) * 1.6);
}

printInfo('Gas override', JSON.stringify(gasOptions, null, 2));
const gatewayFactory = new ContractFactory(AxelarGateway.abi, AxelarGateway.bytecode, wallet);
const authFactory = new ContractFactory(AxelarAuthWeighted.abi, AxelarAuthWeighted.bytecode, wallet);
const tokenDeployerFactory = new ContractFactory(TokenDeployer.abi, TokenDeployer.bytecode, wallet);
Expand Down Expand Up @@ -481,14 +476,13 @@ async function upgrade(_, chain, options) {
printInfo('Mint limiter', mintLimiter);
printInfo('Setup params', setupParams);

const gasOptions = contractConfig.gasOptions || chain.gasOptions || {};
printInfo('Gas options', JSON.stringify(gasOptions, null, 2));
const gasOptions = await getGasOptions(chain, options, contractName);

if (prompt(`Proceed with an upgrade on ${chain.name}?`, yes)) {
return;
}

const tx = await gateway.populateTransaction.upgrade(contractConfig.implementation, implementationCodehash, setupParams);
const tx = await gateway.populateTransaction.upgrade(contractConfig.implementation, implementationCodehash, setupParams, gasOptions);

const { baseTx, signedTx } = await signTransaction(wallet, chain, tx, options);

Expand Down
6 changes: 4 additions & 2 deletions evm/deploy-its.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
getDefaultProvider,
utils: { defaultAbiCoder, isAddress },
} = ethers;

const {
deployContract,
printWalletInfo,
Expand All @@ -18,6 +19,7 @@ const {
prompt,
sleep,
getBytecodeHash,
getGasOptions,
} = require('./utils');
const { addExtendedOptions } = require('./cli-utils');
const InterchainTokenService = getContractJSON('InterchainTokenService');
Expand Down Expand Up @@ -62,7 +64,7 @@ async function deployImplementation(config, wallet, chain, options) {
return;
}

const gasOptions = contractConfig.gasOptions || chain.gasOptions || {};
const gasOptions = await getGasOptions(chain, options, contractName);

const deployOptions =
deployMethod === 'create'
Expand Down Expand Up @@ -335,7 +337,7 @@ async function upgrade(config, chain, options) {

printInfo(`Upgrading Interchain Token Service.`);

const gasOptions = chain.gasOptions || {};
const gasOptions = await getGasOptions(chain, options, contractName);
const contract = new Contract(contractConfig.address, InterchainTokenService.abi, wallet);

const codehash = await getBytecodeHash(contractConfig.implementation, chain.id, provider);
Expand Down
5 changes: 2 additions & 3 deletions evm/deploy-upgradable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const IUpgradable = require('@axelar-network/axelar-gmp-sdk-solidity/interfaces/
const { Command, Option } = require('commander');

const { deployUpgradable, deployCreate2Upgradable, deployCreate3Upgradable, upgradeUpgradable } = require('./upgradable');
const { printInfo, printError, saveConfig, loadConfig, printWalletInfo, getDeployedAddress, prompt } = require('./utils');
const { printInfo, printError, saveConfig, loadConfig, printWalletInfo, getDeployedAddress, prompt, getGasOptions } = require('./utils');
const { addExtendedOptions } = require('./cli-utils');

function getProxy(wallet, proxyAddress) {
Expand Down Expand Up @@ -130,9 +130,8 @@ async function deploy(options, chain) {

const contractConfig = contracts[contractName];
const implArgs = await getImplementationArgs(contractName, contracts, options);
const gasOptions = contractConfig.gasOptions || chain.gasOptions || {};
const gasOptions = await getGasOptions(chain, options, contractName);
printInfo(`Implementation args for chain ${chain.name}`, implArgs);
console.log(`Gas override for chain ${chain.name}: ${JSON.stringify(gasOptions, null, 2)}`);
const salt = options.salt || contractName;
let deployerContract = deployMethod === 'create3' ? contracts.Create3Deployer?.address : contracts.ConstAddressDeployer?.address;

Expand Down
5 changes: 2 additions & 3 deletions evm/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const {
wasEventEmitted,
mainProcessor,
printError,
getGasOptions,
} = require('./utils');
const { addBaseOptions } = require('./cli-utils');
const { getWallet } = require('./sign-utils');
Expand Down Expand Up @@ -61,7 +62,6 @@ async function processCommand(config, chain, options) {

const contracts = chain.contracts;
const contractName = 'AxelarGateway';
const contractConfig = contracts.AxelarGateway;

const gatewayAddress = address || contracts.AxelarGateway?.address;

Expand All @@ -82,8 +82,7 @@ async function processCommand(config, chain, options) {

const gateway = new Contract(gatewayAddress, IGateway.abi, wallet);

const gasOptions = contractConfig?.gasOptions || chain?.gasOptions || {};
printInfo('Gas options', JSON.stringify(gasOptions, null, 2));
const gasOptions = await getGasOptions(chain, options, contractName);

printInfo('Action', action);

Expand Down
13 changes: 3 additions & 10 deletions evm/governance.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
const { Command, Option } = require('commander');
const {
printInfo,
copyObject,
getGasOptions,
printWalletInfo,
isValidTimeFormat,
dateToEta,
Expand Down Expand Up @@ -65,7 +65,7 @@ async function getGatewaySetupParams(governance, gateway, contracts, options) {
}

async function processCommand(_, chain, options) {
const { env, contractName, address, action, date, privateKey, yes } = options;
const { contractName, address, action, date, privateKey, yes } = options;

const contracts = chain.contracts;
const contractConfig = contracts[contractName];
Expand Down Expand Up @@ -106,14 +106,7 @@ async function processCommand(_, chain, options) {

const governance = new Contract(governanceAddress, IGovernance.abi, wallet);

const gasOptions = copyObject(contractConfig?.gasOptions || chain?.gasOptions || { gasLimit: 5e6 });

// Some chains require a gas adjustment
if (env === 'mainnet' && !gasOptions.gasPrice && (chain.name === 'Fantom' || chain.name === 'Binance' || chain.name === 'Polygon')) {
gasOptions.gasPrice = Math.floor((await provider.getGasPrice()) * 1.4);
}

printInfo('Gas options', JSON.stringify(gasOptions, null, 2));
const gasOptions = await getGasOptions(chain, options, contractName);

printInfo('Proposal Action', action);

Expand Down
Loading

0 comments on commit 0654570

Please sign in to comment.