Skip to content

Commit

Permalink
Merge branch 'main' into refactor/amplifier-options
Browse files Browse the repository at this point in the history
  • Loading branch information
eguajardo committed Aug 27, 2024
2 parents 54fcdc4 + 3def0c6 commit 3a34d86
Show file tree
Hide file tree
Showing 21 changed files with 356 additions and 140 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
Install dependencies via
`npm ci`

[EVM deployment instructions](./evm/README.md)
## Deployment Instructions

- [EVM](./evm/README.md)
- [Cosmwasm](./cosmwasm/README.md)
- [Sui](./sui/README.md)
- [Stellar](./stellar/README.md)
18 changes: 9 additions & 9 deletions axelar-chains-config/info/devnet-amplifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,24 @@
"contracts": {
"ServiceRegistry": {
"governanceAccount": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"codeId": 499,
"codeId": 624,
"address": "axelar1c9fkszt5lq34vvvlat3fxj6yv7ejtqapz04e97vtc9m5z9cwnamq8zjlhz"
},
"Router": {
"adminAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"codeId": 509,
"codeId": 623,
"address": "axelar14jjdxqhuxk803e9pq64w4fgf385y86xxhkpzswe9crmu6vxycezst0zq8y"
},
"Multisig": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"blockExpiry": 10,
"codeId": 494,
"codeId": 617,
"address": "axelar19jxy26z0qnnspa45y5nru0l5rmy9d637z5km2ndjxthfxf5qaswst9290r"
},
"Coordinator": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"codeId": 492,
"codeId": 615,
"address": "axelar1m2498n4h2tskcsmssjnzswl5e6eflmqnh487ds47yxyu6y5h4zuqr9zk4g"
},
"Rewards": {
Expand All @@ -302,12 +302,12 @@
"10"
]
},
"codeId": 497,
"codeId": 620,
"address": "axelar1vaj9sfzc3z0gpel90wu4ljutncutv0wuhvvwfsh30rqxq422z89qnd989l"
},
"NexusGateway": {
"nexus": "axelar17h8uk4ct0mdv9mgkuxszt4gp2htpfr08mge20r",
"codeId": 496,
"codeId": 619,
"address": "axelar1jjjr3tqs0nzjv3y9fg4xvzkww50jq06a9qp77r8kzmqyla97556sxx7702"
},
"VotingVerifier": {
Expand All @@ -324,7 +324,7 @@
"msgIdFormat": "hex_tx_hash_and_event_index",
"address": "axelar1ty7mx0cllgz8xuvhn2j7e3qy8999ssgmjtktyqetl335em0g88lq6rjhl2"
},
"codeId": 500,
"codeId": 626,
"fantom": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"serviceName": "validators",
Expand Down Expand Up @@ -369,7 +369,7 @@
"avalanche": {
"address": "axelar16hdkkxjyapw5zyf2wxs42854278tpwgqkz87kst8wamvr4pcy4pqrpn96s"
},
"codeId": 493,
"codeId": 616,
"fantom": {
"address": "axelar1pvcj8m7gp30tl26kt7n2ncg9g7xnt86wlqatlvwehh8s2ve2anmq6ea96w"
},
Expand All @@ -396,7 +396,7 @@
"domainSeparator": "0x598ba04d225cec385d1ce3cf3c9a076af803aa5c614bc0e0d176f04ac8d28f55",
"address": "axelar1g6520uhs8u37el40wqngf60z06mjgk6z7nezytd2mxrmh7yesnmsyc0zjw"
},
"codeId": 505,
"codeId": 618,
"fantom": {
"governanceAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
"adminAddress": "axelar1zlr7e5qf3sz7yf890rkh9tcnu87234k6k7ytd9",
Expand Down
1 change: 0 additions & 1 deletion common/cli-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,4 @@ const addExtendedOptions = (program, options = {}) => {
module.exports = {
addEnvOption,
addBaseOptions,
addExtendedOptions,
};
61 changes: 51 additions & 10 deletions common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const readlineSync = require('readline-sync');
const { CosmWasmClient } = require('@cosmjs/cosmwasm-stargate');
const { ethers } = require('hardhat');
const {
utils: { keccak256, hexlify },
utils: { keccak256, hexlify, defaultAbiCoder },
} = ethers;
const { normalizeBech32 } = require('@cosmjs/encoding');

Expand Down Expand Up @@ -57,12 +57,16 @@ function printLog(log) {
console.log(JSON.stringify({ log }, null, 2));
}

const isString = (arg) => {
return typeof arg === 'string';
};

const isNonEmptyString = (arg) => {
return typeof arg === 'string' && arg !== '';
return isString(arg) && arg !== '';
};

const isString = (arg) => {
return typeof arg === 'string';
const isStringLowercase = (arg) => {
return isNonEmptyString(arg) && arg === arg.toLowerCase();
};

const isStringArray = (arr) => Array.isArray(arr) && arr.every(isString);
Expand Down Expand Up @@ -347,6 +351,17 @@ const isValidCosmosAddress = (str) => {
}
};

const getSaltFromKey = (key) => {
return keccak256(defaultAbiCoder.encode(['string'], [key.toString()]));
};

const getContractConfig = async (config, chain) => {
const key = Buffer.from('config');
const client = await CosmWasmClient.connect(config.axelar.rpc);
const value = await client.queryContractRaw(config.axelar.contracts.MultisigProver[chain].address, key);
return JSON.parse(Buffer.from(value).toString('ascii'));
};

async function getDomainSeparator(config, chain, options) {
// Allow any domain separator for local deployments or `0x` if not provided
if (options.env === 'local') {
Expand Down Expand Up @@ -377,22 +392,42 @@ async function getDomainSeparator(config, chain, options) {
throw new Error(`missing or invalid chain ID`);
}

const expectedDomainSeparator = calculateDomainSeparator(chain.axelarId, routerAddress, chainId);

if (options.domainSeparator === 'offline') {
printInfo('Computed domain separator offline');
return expectedDomainSeparator;
}

printInfo(`Retrieving domain separator for ${chain.name} from Axelar network`);
const domainSeparator = hexlify((await getContractConfig(config, chain.axelarId)).domain_separator);
const expectedDomainSeparator = calculateDomainSeparator(chain.axelarId, routerAddress, chainId);

if (domainSeparator !== expectedDomainSeparator) {
throw new Error(`unexpected domain separator (want ${expectedDomainSeparator}, got ${domainSeparator})`);
}

return domainSeparator;
return expectedDomainSeparator;
}

const getContractConfig = async (config, chain) => {
const key = Buffer.from('config');
const getChainConfig = (config, chainName) => {
if (chainName === 'none') {
return undefined;
}

const chainConfig = config.chains[chainName] || config[chainName];

if (!chainConfig) {
throw new Error(`Chain ${chainName} not found in config`);
}

return chainConfig;
};

const getMultisigProof = async (config, chain, multisigSessionId) => {
const query = { proof: { multisig_session_id: `${multisigSessionId}` } };
const client = await CosmWasmClient.connect(config.axelar.rpc);
const value = await client.queryContractRaw(config.axelar.contracts.MultisigProver[chain].address, key);
return JSON.parse(Buffer.from(value).toString('ascii'));
const value = await client.queryContractSmart(config.axelar.contracts.MultisigProver[chain].address, query);
return value;
};

const calculateDomainSeparator = (chain, router, network) => keccak256(Buffer.from(`${chain}${router}${network}`));
Expand All @@ -409,6 +444,7 @@ module.exports = {
isNonEmptyString,
isString,
isStringArray,
isStringLowercase,
isNumber,
isValidNumber,
isValidDecimal,
Expand All @@ -429,4 +465,9 @@ module.exports = {
timeout,
validateParameters,
getDomainSeparator,
getChainConfig,
getMultisigProof,
getContractConfig,
getSaltFromKey,
calculateDomainSeparator,
};
4 changes: 2 additions & 2 deletions cosmwasm/deploy-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const upload = (client, wallet, chainName, config, options) => {
axelar: {
contracts: { [contractName]: contractConfig },
},
chains: { [chainName]: chainConfig },
} = config;
const chainConfig = chainName === 'none' ? undefined : getChainConfig(config, chainName);

Check failure on line 28 in cosmwasm/deploy-contract.js

View workflow job for this annotation

GitHub Actions / lint

'getChainConfig' is not defined

if (!fetchCodeId && (!reuseCodeId || isNil(contractConfig.codeId))) {
printInfo('Uploading contract binary');
Expand Down Expand Up @@ -53,7 +53,7 @@ const upload = (client, wallet, chainName, config, options) => {
.then(() => ({ wallet, client }));
}

printInfo('Skipping upload. Reusing previously uploaded binary');
printInfo('Skipping upload. Reusing previously uploaded bytecode');
return Promise.resolve({ wallet, client });
};

Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/submit-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const programHandler = () => {

// TODO: combine deploy-contract and submit-proposal options to remove duplicates
program.addOption(new Option('-m, --mnemonic <mnemonic>', 'mnemonic').makeOptionMandatory(true).env('MNEMONIC'));
program.addOption(new Option('-a, --artifactPath <artifactPath>', 'artifact path').makeOptionMandatory(true).env('ARTIFACT_PATH'));
program.addOption(new Option('-a, --artifactPath <artifactPath>', 'artifact path').env('ARTIFACT_PATH'));
program.addOption(new Option('-c, --contractName <contractName>', 'contract name').makeOptionMandatory(true));
program.addOption(new Option('-n, --chainNames <chainNames>', 'chain names').default('none'));

Expand Down
Loading

0 comments on commit 3a34d86

Please sign in to comment.