Skip to content

Commit

Permalink
feat: checking core config for Aggregation ISM on zksync core deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ljankovic-txfusion committed Oct 22, 2024
1 parent 29205fb commit fbc7c31
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
13 changes: 12 additions & 1 deletion typescript/cli/src/deploy/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import {
import { MINIMUM_CORE_DEPLOY_GAS } from '../consts.js';
import { getOrRequestApiKeys } from '../context/context.js';
import { WriteCommandContext } from '../context/types.js';
import { log, logBlue, logGray, logGreen } from '../logger.js';
import { log, logBlue, logGray, logGreen, logRed } from '../logger.js';
import { runSingleChainSelectionStep } from '../utils/chains.js';
import { indentYamlOrJson } from '../utils/files.js';

import {
checkTechStackCoreConfigCompatibility,
completeDeploy,
prepareDeploy,
runDeployPlanStep,
Expand Down Expand Up @@ -81,6 +82,16 @@ export async function runCoreDeploy(params: DeployParams) {

const userAddress = await signer.getAddress();

const { technicalStack: chainTechnicalStack } =
context.multiProvider.getChainMetadata(chain);

if (!checkTechStackCoreConfigCompatibility({ chainTechnicalStack, config })) {
logRed(
'ERROR: CoreConfig is not compatible with the selected Chain Technical Stack!',
);
return;
}

const initialBalances = await prepareDeploy(context, userAddress, [chain]);

const contractVerifier = new ContractVerifier(
Expand Down
31 changes: 31 additions & 0 deletions typescript/cli/src/deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import {
ChainMap,
ChainMetadata,
ChainName,
ChainTechnicalStack,
CoreConfig,
IsmConfig,
IsmType,
MultisigConfig,
getLocalProvider,
shouldSkipStaticDeployment,
} from '@hyperlane-xyz/sdk';
import { Address, ProtocolType } from '@hyperlane-xyz/utils';

Expand All @@ -19,6 +23,7 @@ import {
logGray,
logGreen,
logPink,
logRed,
logTable,
} from '../logger.js';
import { nativeBalancesAreSufficient } from '../utils/balances.js';
Expand Down Expand Up @@ -186,3 +191,29 @@ function transformChainMetadataForDisplay(chainMetadata: ChainMetadata) {
'Native Token: Decimals': chainMetadata.nativeToken?.decimals,
};
}

/**
* Checks if the given chain technical stack is compatible with the core configuration.
*
* @param {ChainTechnicalStack | undefined} params.chainTechnicalStack - The technical stack of the chain.
* @param {CoreConfig} params.config - The core configuration to check.
* @returns {boolean} True if the configuration is compatible, false otherwise.
*/
export function checkTechStackCoreConfigCompatibility({
chainTechnicalStack,
config,
}: {
chainTechnicalStack: ChainTechnicalStack | undefined;
config: CoreConfig;
}): boolean {
// Static deployment is not available on certain chains (e.g., ZKSync) for aggregation ISMs.
if (
shouldSkipStaticDeployment(chainTechnicalStack) &&
typeof config.defaultIsm !== 'string' &&
config.defaultIsm.type === IsmType.AGGREGATION
) {
logRed('⛔ Static contract deployment not available on ZKSync!');
return false;
}
return true;
}
1 change: 1 addition & 0 deletions typescript/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,4 @@ export {
export { EvmIsmModule } from './ism/EvmIsmModule.js';
export { AnnotatedEV5Transaction } from './providers/ProviderType.js';
export { EvmERC20WarpModule } from './token/EvmERC20WarpModule.js';
export { shouldSkipStaticDeployment } from './deploy/protocolDeploymentConfig.js';

0 comments on commit fbc7c31

Please sign in to comment.