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:removing igp from preset hook config #3215

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/friendly-peas-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/cli': patch
---

Removed IGP from preset hook config
54 changes: 2 additions & 52 deletions typescript/cli/src/config/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
GasOracleContractType,
HookType,
HooksConfig,
MultisigConfig,
chainMetadata,
defaultMultisigConfigs,
multisigIsmVerificationCost,
} from '@hyperlane-xyz/sdk';
import {
Address,
Expand Down Expand Up @@ -83,41 +80,7 @@ export function isValidHookConfigMap(config: any) {
return HooksConfigMapSchema.safeParse(config).success;
}

export function presetHookConfigs(
owner: Address,
local: ChainName,
destinationChains: ChainName[],
multisigConfig?: MultisigConfig,
): HooksConfig {
const gasOracleType = destinationChains.reduce<
ChainMap<GasOracleContractType>
>((acc, chain) => {
acc[chain] = GasOracleContractType.StorageGasOracle;
return acc;
}, {});
const overhead = destinationChains.reduce<ChainMap<number>>((acc, chain) => {
let validatorThreshold: number;
let validatorCount: number;
if (multisigConfig) {
validatorThreshold = multisigConfig.threshold;
validatorCount = multisigConfig.validators.length;
} else if (local in defaultMultisigConfigs) {
validatorThreshold = defaultMultisigConfigs[local].threshold;
validatorCount = defaultMultisigConfigs[local].validators.length;
} else {
// default values
// fix here: https://github.com/hyperlane-xyz/issues/issues/773
validatorThreshold = 2;
validatorCount = 3;
}
acc[chain] = multisigIsmVerificationCost(
validatorThreshold,
validatorCount,
);
return acc;
}, {});

// TODO improve types here to avoid need for `as` casts
export function presetHookConfigs(owner: Address): HooksConfig {
return {
required: {
type: HookType.PROTOCOL_FEE,
Expand All @@ -127,20 +90,7 @@ export function presetHookConfigs(
owner: owner,
},
default: {
type: HookType.AGGREGATION,
hooks: [
{
type: HookType.MERKLE_TREE,
},
{
type: HookType.INTERCHAIN_GAS_PAYMASTER,
owner: owner,
beneficiary: owner,
gasOracleType,
overhead,
oracleKey: owner,
},
],
type: HookType.MERKLE_TREE,
},
};
}
Expand Down
11 changes: 1 addition & 10 deletions typescript/cli/src/deploy/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ async function executeDeploy({
chains,
defaultIsms,
hooksConfig,
multisigConfigs,
);
const coreContracts = await coreDeployer.deploy(coreConfigs);

Expand Down Expand Up @@ -391,17 +390,9 @@ function buildCoreConfigMap(
chains: ChainName[],
defaultIsms: ChainMap<IsmConfig>,
hooksConfig: ChainMap<HooksConfig>,
multisigConfigs: ChainMap<MultisigConfig>,
): ChainMap<CoreConfig> {
return chains.reduce<ChainMap<CoreConfig>>((config, chain) => {
const hooks =
hooksConfig[chain] ??
presetHookConfigs(
owner,
chain,
chains.filter((c) => c !== chain),
multisigConfigs[chain], // if no multisig config, uses default 2/3
);
const hooks = hooksConfig[chain] ?? presetHookConfigs(owner);
config[chain] = {
owner,
defaultIsm: defaultIsms[chain],
Expand Down
Loading