Skip to content

Commit

Permalink
feat:removing igp from preset hook config (hyperlane-xyz#3215)
Browse files Browse the repository at this point in the history
### Description

- To simplify the PI deployment, I've removed the igp from preset hook
config which PI deployers use if they don't provide a hook config via
the CLI.
- This means we don't need to deploy IGP or storage gas oracles and the
PI deployer can spin up relayer with gas enforcement policy set to
false.

### Drive-by changes

None

### Related issues

None

### Backward compatibility

Yes
### Testing

Manual
  • Loading branch information
aroralanuk authored and ltyu committed Mar 13, 2024
1 parent 4510aaa commit f8f042b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 62 deletions.
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

0 comments on commit f8f042b

Please sign in to comment.