Skip to content

Commit

Permalink
Filter testnet owners to eth chains
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed May 1, 2024
1 parent b2f29ed commit a38b0df
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 56 deletions.
7 changes: 3 additions & 4 deletions typescript/infra/config/environments/mainnet3/chains.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk';
import { ChainMap, ChainMetadata } from '@hyperlane-xyz/sdk';
import { objKeys } from '@hyperlane-xyz/utils';

import { getChainMetadatas } from '../../../src/config/chain.js';
import { getChain } from '../../registry.js';
Expand Down Expand Up @@ -67,6 +68,4 @@ export const mainnetConfigs: ChainMap<ChainMetadata> = {
...nonEthereumMainnetConfigs,
};

export const ethereumChainNames = Object.keys(
ethereumMainnetConfigs,
) as ChainName[];
export const ethereumChainNames = objKeys(ethereumMainnetConfigs);
12 changes: 2 additions & 10 deletions typescript/infra/config/environments/mainnet3/igp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ import {
ChainMap,
ChainName,
IgpConfig,
OwnableConfig,
TOKEN_EXCHANGE_RATE_DECIMALS,
defaultMultisigConfigs,
multisigIsmVerificationCost,
} from '@hyperlane-xyz/sdk';
import { ProtocolType, exclude, objFilter, objMap } from '@hyperlane-xyz/utils';
import { exclude, objMap } from '@hyperlane-xyz/utils';

import {
AllStorageGasOracleConfigs,
getAllStorageGasOracleConfigs,
getTokenExchangeRateFromValues,
} from '../../../src/config/gas-oracle.js';
import { getChain } from '../../registry.js';

import { ethereumChainNames } from './chains.js';
import gasPrices from './gasPrices.json';
Expand Down Expand Up @@ -59,13 +57,7 @@ const storageGasOracleConfig: AllStorageGasOracleConfigs =
(local) => remoteOverhead(local),
);

const evmOwners = objFilter(
owners,
(chain, _): _ is OwnableConfig =>
getChain(chain).protocol === ProtocolType.Ethereum,
);

export const igp: ChainMap<IgpConfig> = objMap(evmOwners, (local, owner) => ({
export const igp: ChainMap<IgpConfig> = objMap(owners, (local, owner) => ({
...owner,
ownerOverrides: {
...owner.ownerOverrides,
Expand Down
13 changes: 10 additions & 3 deletions typescript/infra/config/environments/testnet4/chains.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { ChainMap, ChainMetadata } from '@hyperlane-xyz/sdk';
import { objKeys } from '@hyperlane-xyz/utils';

import { getChainMetadatas } from '../../../src/config/chain.js';
import { getChain } from '../../registry.js';

import { supportedChainNames } from './supportedChainNames.js';

export const environment = 'testnet4';

const {
ethereumMetadatas: defaultEthereumMainnetConfigs,
nonEthereumMetadatas: nonEthereumMainnetConfigs,
} = getChainMetadatas(supportedChainNames);

export const testnetConfigs: ChainMap<ChainMetadata> = {
...Object.fromEntries(
supportedChainNames.map((chain) => [chain, getChain(chain)]),
),
...defaultEthereumMainnetConfigs,
bsctestnet: {
...getChain('bsctestnet'),
transactionOverrides: {
gasPrice: 8 * 10 ** 9, // 8 gwei
},
},
};

export const ethereumChainNames = objKeys(defaultEthereumMainnetConfigs);
56 changes: 19 additions & 37 deletions typescript/infra/config/environments/testnet4/igp.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
import {
ChainMap,
IgpConfig,
OwnableConfig,
defaultMultisigConfigs,
multisigIsmVerificationCost,
} from '@hyperlane-xyz/sdk';
import {
Address,
ProtocolType,
exclude,
objFilter,
objMap,
} from '@hyperlane-xyz/utils';

import { getChain } from '../../registry.js';
import { Address, exclude, objMap } from '@hyperlane-xyz/utils';

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

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,
),
]),
),
};
},
);
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,
),
]),
),
};
});
4 changes: 2 additions & 2 deletions typescript/infra/config/environments/testnet4/owners.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ChainMap, OwnableConfig } from '@hyperlane-xyz/sdk';

import { supportedChainNames } from './supportedChainNames.js';
import { ethereumChainNames } from './chains.js';

const ETHEREUM_DEPLOYER_ADDRESS = '0xfaD1C94469700833717Fa8a3017278BC1cA8031C';
// const SEALEVEL_DEPLOYER_ADDRESS = '6DjHX6Ezjpq3zZMZ8KsqyoFYo1zPSDoiZmLLkxD4xKXS';

export const owners: ChainMap<OwnableConfig> = {
...Object.fromEntries(
supportedChainNames.map((chain) => [
ethereumChainNames.map((chain) => [
chain,
{ owner: ETHEREUM_DEPLOYER_ADDRESS },
]),
Expand Down

0 comments on commit a38b0df

Please sign in to comment.