Skip to content

Commit

Permalink
Filter infra IGP owners to evm chains
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Apr 30, 2024
1 parent eebc103 commit ea283dc
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 38 deletions.
56 changes: 37 additions & 19 deletions typescript/infra/config/environments/test/igp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ import {
ChainName,
GasOracleContractType,
IgpConfig,
OwnableConfig,
multisigIsmVerificationCost,
} from '@hyperlane-xyz/sdk';
import { Address, exclude, objMap } from '@hyperlane-xyz/utils';
import {
Address,
ProtocolType,
exclude,
objFilter,
objMap,
} from '@hyperlane-xyz/utils';

import { getChain } from '../../registry.js';

import { testChainNames } from './chains.js';
import { multisigIsm } from './multisigIsm.js';
Expand All @@ -20,21 +29,30 @@ function getGasOracles(local: ChainName) {
);
}

export const igp: ChainMap<IgpConfig> = objMap(owners, (chain, ownerConfig) => {
const overhead = Object.fromEntries(
exclude(chain, testChainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
multisigIsm[remote].threshold,
multisigIsm[remote].validators.length,
),
]),
);
return {
oracleKey: ownerConfig.owner as Address, // owner can be AccountConfig
beneficiary: ownerConfig.owner as Address, // same as above
gasOracleType: getGasOracles(chain),
overhead,
...ownerConfig,
};
});
const evmOwners = objFilter(
owners,
(chain, _): _ is OwnableConfig =>
getChain(chain).protocol === ProtocolType.Ethereum,
);

export const igp: ChainMap<IgpConfig> = objMap(
evmOwners,
(chain, ownerConfig) => {
const overhead = Object.fromEntries(
exclude(chain, testChainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
multisigIsm[remote].threshold,
multisigIsm[remote].validators.length,
),
]),
);
return {
oracleKey: ownerConfig.owner as Address, // owner can be AccountConfig
beneficiary: ownerConfig.owner as Address, // same as above
gasOracleType: getGasOracles(chain),
overhead,
...ownerConfig,
};
},
);
56 changes: 37 additions & 19 deletions typescript/infra/config/environments/testnet4/igp.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
import {
ChainMap,
IgpConfig,
OwnableConfig,
defaultMultisigConfigs,
multisigIsmVerificationCost,
} from '@hyperlane-xyz/sdk';
import { Address, exclude, objMap } from '@hyperlane-xyz/utils';
import {
Address,
ProtocolType,
exclude,
objFilter,
objMap,
} from '@hyperlane-xyz/utils';

import { getChain } from '../../registry.js';

import { storageGasOracleConfig } from './gas-oracle.js';
import { owners } from './owners.js';
import { supportedChainNames } from './supportedChainNames.js';

export const igp: ChainMap<IgpConfig> = objMap(owners, (chain, ownerConfig) => {
return {
...ownerConfig,
oracleKey: ownerConfig.owner as Address,
beneficiary: ownerConfig.owner as Address,
oracleConfig: storageGasOracleConfig[chain],
overhead: Object.fromEntries(
exclude(chain, supportedChainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
// TODO: parameterize this
defaultMultisigConfigs[remote].threshold,
defaultMultisigConfigs[remote].validators.length,
),
]),
),
};
});
const evmOwners = objFilter(
owners,
(chain, _): _ is OwnableConfig =>
getChain(chain).protocol === ProtocolType.Ethereum,
);

export const igp: ChainMap<IgpConfig> = objMap(
evmOwners,
(chain, ownerConfig) => {
return {
...ownerConfig,
oracleKey: ownerConfig.owner as Address,
beneficiary: ownerConfig.owner as Address,
oracleConfig: storageGasOracleConfig[chain],
overhead: Object.fromEntries(
exclude(chain, supportedChainNames).map((remote) => [
remote,
multisigIsmVerificationCost(
// TODO: parameterize this
defaultMultisigConfigs[remote].threshold,
defaultMultisigConfigs[remote].validators.length,
),
]),
),
};
},
);

0 comments on commit ea283dc

Please sign in to comment.