feat: infra script for printing mailbox ownership (#4497)

feat: script to check mailbox ownership

drive-by:
- ICA ownership for everclear+oortmainnet
- move check scripts to check dir

mainnet3:
```sh
┌──────────────┬──────────────────────────────────────────────┬────────┐
│ (index)      │ address                                      │ owner  │
├──────────────┼──────────────────────────────────────────────┼────────┤
│ ancient8     │ '0xD2BFA0F0654E3f2139b8cDC56c32eeC54D32b133' │ 'SAFE' │
│ arbitrum     │ '0x03fD5BE9DF85F0017dC7F4DC3068dDF64fffF25e' │ 'SAFE' │
│ astar        │ '0x6b241544eBa7d89B51b72DF85a0342dAa37371Ca' │ 'ICA'  │
│ astarzkevm   │ '0x526c6DAee1175A1A2337E703B63593acb327Dde4' │ 'ICA'  │
│ avalanche    │ '0x5bE94B17112B8F18eA9Ac8e559377B467556a3c3' │ 'SAFE' │
│ base         │ '0x3949eD0CD036D9FF662d97BD7aC1686051c4aeBF' │ 'SAFE' │
│ bitlayer     │ '0xe6239316cA60814229E801fF0B9DD71C9CA29008' │ 'ICA'  │
│ blast        │ '0xaCD1865B262C89Fb0b50dcc8fB095330ae8F35b5' │ 'SAFE' │
│ bob          │ '0x9e2fe7723b018d02cDE4f5cC1A9bC9C65b922Fc8' │ 'SAFE' │
│ bsc          │ '0x7bB2ADeDdC342ffb611dDC073095cc4B8C547170' │ 'SAFE' │
│ celo         │ '0x879038d6Fc9F6D5e2BA73188bd078486d77e1156' │ 'SAFE' │
│ cheesechain  │ '0xEe2C5320BE9bC7A1492187cfb289953b53E3ff1b' │ 'ICA'  │
│ coredao      │ '0x84802CdF47565C95d8ffd59E7c4B1cf027F5452F' │ 'ICA'  │
│ cyber        │ '0x984Fe5a45Ac4aaeC4E4655b50f776aB79c9Be19F' │ 'ICA'  │
│ degenchain   │ '0x22d952d3b9F493442731a3c7660aCaD98e55C00A' │ 'ICA'  │
│ dogechain    │ '0x84802CdF47565C95d8ffd59E7c4B1cf027F5452F' │ 'ICA'  │
│ endurance    │ '0xaCD1865B262C89Fb0b50dcc8fB095330ae8F35b5' │ 'SAFE' │
│ ethereum     │ '0x3965AC3D295641E452E0ea896a086A9cD7C6C5b6' │ 'SAFE' │
│ everclear    │ '0x63B2075372D6d0565F51210D0A296D3c8a773aB6' │ 'ICA'  │
│ flare        │ '0x689b8DaBBF2f9Fd83D37427A062B30edF463e20b' │ 'ICA'  │
│ fraxtal      │ '0x66e9f52800E9F89F0569fddc594Acd5EE609f762' │ 'SAFE' │
│ fusemainnet  │ '0x29a526227CB864C90Cf078d03872da913B473139' │ 'SAFE' │
│ gnosis       │ '0x0Ac72fBc82c9c39F81242229631dfC38aA13031B' │ 'SAFE' │
│ inevm        │ '0xFDF9EDcb2243D51f5f317b9CEcA8edD2bEEE036e' │ 'ICA'  │
│ kroma        │ '0xc1e20A0D78E79B94D71d4bDBC8FD0Af7c856Dd7A' │ 'ICA'  │
│ linea        │ '0xaCD1865B262C89Fb0b50dcc8fB095330ae8F35b5' │ 'SAFE' │
│ lisk         │ '0x22d952d3b9F493442731a3c7660aCaD98e55C00A' │ 'ICA'  │
│ lukso        │ '0xc1e20A0D78E79B94D71d4bDBC8FD0Af7c856Dd7A' │ 'ICA'  │
│ mantapacific │ '0x03ed2D65f2742193CeD99D48EbF1F1D6F12345B6' │ 'SAFE' │
│ mantle       │ '0x8aFE6EECc6CcB02aA20DA8Fff7d29aadEBbc2DCd' │ 'SAFE' │
│ merlin       │ '0xCf867cEaeeE8CBe65C680c734D29d26440931D5b' │ 'ICA'  │
│ metis        │ '0xb51e63CD0842D670a13c88B159fCFc268DA652A3' │ 'ICA'  │
│ mint         │ '0xb51e63CD0842D670a13c88B159fCFc268DA652A3' │ 'ICA'  │
│ mode         │ '0xaCD1865B262C89Fb0b50dcc8fB095330ae8F35b5' │ 'SAFE' │
│ molten       │ '0x84802CdF47565C95d8ffd59E7c4B1cf027F5452F' │ 'ICA'  │
│ moonbeam     │ '0x594203849E52BF6ee0E511cD807Ca2D658893e37' │ 'SAFE' │
│ oortmainnet  │ '0x7021D11F9fAe455AB2f45D72dbc2C64d116Cb657' │ 'ICA'  │
│ optimism     │ '0xbd7db3821806bc72D223F0AE521Bf82FcBd6Ef4d' │ 'SAFE' │
│ polygon      │ '0xf9cFD440CfBCfAB8473cc156485B7eE753b2913E' │ 'SAFE' │
│ polygonzkevm │ '0x1610f578D4d77Fc4ae7ce2DD9AA0b98A5Cd0a9b2' │ 'SAFE' │
│ proofofplay  │ '0xb51e63CD0842D670a13c88B159fCFc268DA652A3' │ 'ICA'  │
│ real         │ '0xc761e68BF3A94326FD0D305e3ccb4cdaab2edA19' │ 'ICA'  │
│ redstone     │ '0xa1a50ff5FD859558E1899fEC5C3064483177FA23' │ 'SAFE' │
│ sanko        │ '0x5DAcd2f1AafC749F2935A160865Ab1568eC23752' │ 'ICA'  │
│ scroll       │ '0x6EeEbB9F7FB18DD5E59F82658c59B846715eD4F7' │ 'SAFE' │
│ sei          │ '0xCed197FBc360C26C19889745Cf73511b71D03d5D' │ 'SAFE' │
│ shibarium    │ '0x6348FAe3a8374dbAAaE84EEe5458AE4063Fe2be7' │ 'ICA'  │
│ taiko        │ '0xa4864301d3fa2a3e68256309F9F0F570270a1BD0' │ 'SAFE' │
│ tangle       │ '0xCC2aeb692197C7894E561d31ADFE8F79746f7d9F' │ 'ICA'  │
│ viction      │ '0x23ed65DE22ac29Ec1C16E75EddB0cE3A187357b4' │ 'ICA'  │
│ worldchain   │ '0x1996DbFcFB433737fE404F58D2c32A7f5f334210' │ 'ICA'  │
│ xai          │ '0x22d952d3b9F493442731a3c7660aCaD98e55C00A' │ 'ICA'  │
│ xlayer       │ '0x1571c482fe9E76bbf50829912b1c746792966369' │ 'ICA'  │
│ zetachain    │ '0x9d399876522Fc5C044D048594de399A2349d6026' │ 'SAFE' │
│ zircuit      │ '0x9e2fe7723b018d02cDE4f5cC1A9bC9C65b922Fc8' │ 'SAFE' │
│ zoramainnet  │ '0xF87018025575552889062De4b05bBC3DAe35Cd96' │ 'SAFE' │
└──────────────┴──────────────────────────────────────────────┴────────┘

Total chains: 56
┌─────────┬────────────────┬─────────────┐
│ (index) │ Owner Type     │ Chain Count │
├─────────┼────────────────┼─────────────┤
│ 0       │ 'ICA'          │ 28          │
│ 1       │ 'SAFE'         │ 28          │
│ 2       │ 'DEPLOYER KEY' │ 0           │
│ 3       │ 'UNKNOWN'      │ 0           │
└─────────┴────────────────┴─────────────┘
```

testnet4:
```
┌──────────────────────┬──────────────────────────────────────────────┬────────────────┐
│ (index)              │ address                                      │ owner          │
├──────────────────────┼──────────────────────────────────────────────┼────────────────┤
│ alfajores            │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ arbitrumsepolia      │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ basesepolia          │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ bsctestnet           │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ connextsepolia       │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ ecotestnet           │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ fuji                 │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ holesky              │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ optimismsepolia      │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ polygonamoy          │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ scrollsepolia        │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ sepolia              │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
│ superpositiontestnet │ '0xfaD1C94469700833717Fa8a3017278BC1cA8031C' │ 'DEPLOYER KEY' │
└──────────────────────┴──────────────────────────────────────────────┴────────────────┘

Total chains: 13
┌─────────┬────────────────┬─────────────┐
│ (index) │ Owner Type     │ Chain Count │
├─────────┼────────────────┼─────────────┤
│ 0       │ 'ICA'          │ 0           │
│ 1       │ 'SAFE'         │ 0           │
│ 2       │ 'DEPLOYER KEY' │ 13          │
│ 3       │ 'UNKNOWN'      │ 0           │
└─────────┴────────────────┴─────────────┘
```
pull/4503/head
Paul Balaji 2 months ago committed by GitHub
parent 509213dcfc
commit be53dd23c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      typescript/infra/config/environments/mainnet3/owners.ts
  2. 7
      typescript/infra/scripts/check/check-owner-ica.ts
  3. 7
      typescript/infra/scripts/check/check-rpc-urls.ts
  4. 7
      typescript/infra/scripts/check/check-validator-announce.ts
  5. 139
      typescript/infra/scripts/print-mailbox-owner.ts

@ -99,6 +99,11 @@ export const icas: Partial<
flare: '0x689b8DaBBF2f9Fd83D37427A062B30edF463e20b',
molten: '0x84802CdF47565C95d8ffd59E7c4B1cf027F5452F',
shibarium: '0x6348FAe3a8374dbAAaE84EEe5458AE4063Fe2be7',
// Sep 9, 2024 batch
// ----------------------------
everclear: '0x63B2075372D6d0565F51210D0A296D3c8a773aB6',
oortmainnet: '0x7021D11F9fAe455AB2f45D72dbc2C64d116Cb657',
} as const;
export const DEPLOYER = '0xa7ECcdb9Be08178f896c26b7BbD8C3D4E844d9Ba';

@ -1,10 +1,9 @@
import { AccountConfig, InterchainAccount } from '@hyperlane-xyz/sdk';
import { Address, eqAddress } from '@hyperlane-xyz/utils';
import { icas } from '../config/environments/mainnet3/owners.js';
import { getArgs as getEnvArgs } from './agent-utils.js';
import { getEnvironmentConfig, getHyperlaneCore } from './core-utils.js';
import { icas } from '../../config/environments/mainnet3/owners.js';
import { getArgs as getEnvArgs } from '../agent-utils.js';
import { getEnvironmentConfig, getHyperlaneCore } from '../core-utils.js';
function getArgs() {
return getEnvArgs().option('ownerChain', {

@ -2,10 +2,9 @@ import { ethers } from 'ethers';
import { rootLogger } from '@hyperlane-xyz/utils';
import { getSecretRpcEndpoints } from '../src/agents/index.js';
import { getArgs } from './agent-utils.js';
import { getEnvironmentConfig } from './core-utils.js';
import { getSecretRpcEndpoints } from '../../src/agents/index.js';
import { getArgs } from '../agent-utils.js';
import { getEnvironmentConfig } from '../core-utils.js';
async function main() {
const { environment } = await getArgs().argv;

@ -1,10 +1,9 @@
import { ChainMap, defaultMultisigConfigs } from '@hyperlane-xyz/sdk';
import { eqAddress } from '@hyperlane-xyz/utils';
import { isEthereumProtocolChain } from '../src/utils/utils.js';
import { getArgs, withChains } from './agent-utils.js';
import { getEnvironmentConfig, getHyperlaneCore } from './core-utils.js';
import { isEthereumProtocolChain } from '../../src/utils/utils.js';
import { getArgs, withChains } from '../agent-utils.js';
import { getEnvironmentConfig, getHyperlaneCore } from '../core-utils.js';
const minimumValidatorCount = 3;

@ -0,0 +1,139 @@
import { ethers } from 'ethers';
import { ChainAddresses } from '@hyperlane-xyz/registry';
import {
ChainMap,
CoreFactories,
HyperlaneContracts,
HyperlaneCore,
} from '@hyperlane-xyz/sdk';
import {
Address,
eqAddressEvm,
objFilter,
objMap,
promiseObjAll,
} from '@hyperlane-xyz/utils';
import { Contexts } from '../config/contexts.js';
import { DeployEnvironment } from '../src/config/environment.js';
import { Role } from '../src/roles.js';
import {
filterRemoteDomainMetadata,
isEthereumProtocolChain,
} from '../src/utils/utils.js';
import {
Modules,
getAddresses,
getArgs,
withAgentRoles,
withChains,
withContext,
} from './agent-utils.js';
import { getEnvironmentConfig } from './core-utils.js';
const DEPLOYERS: Record<DeployEnvironment, Address> = {
mainnet3: '0xa7ECcdb9Be08178f896c26b7BbD8C3D4E844d9Ba',
testnet4: '0xfaD1C94469700833717Fa8a3017278BC1cA8031C',
test: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
};
export enum Owner {
ICA = 'ICA',
SAFE = 'SAFE',
DEPLOYER = 'DEPLOYER KEY',
UNKNOWN = 'UNKNOWN',
}
async function main() {
const {
context = Contexts.Hyperlane,
environment,
chains,
} = await withContext(withChains(withAgentRoles(getArgs()))).argv;
const envConfig = getEnvironmentConfig(environment);
const chainsToCheck = (
chains?.length ? chains : envConfig.supportedChainNames
).filter(isEthereumProtocolChain);
const multiProvider = await envConfig.getMultiProvider(
context,
Role.Deployer,
true,
chainsToCheck,
);
// Get the addresses for the environment
const addressesMap = getAddresses(
environment,
Modules.CORE,
) as ChainMap<ChainAddresses>;
const addressesForEnv = filterRemoteDomainMetadata(addressesMap);
const core = HyperlaneCore.fromAddressesMap(addressesForEnv, multiProvider);
const evmContractsMap = objFilter(
core.contractsMap,
(chain, _): _ is HyperlaneContracts<CoreFactories> =>
isEthereumProtocolChain(chain),
);
const deployer = DEPLOYERS[environment];
const mailboxOwners = await promiseObjAll(
objMap(
evmContractsMap,
async (chain: string, contracts: HyperlaneContracts<CoreFactories>) => {
// get possible owners from config
const ownerConfig = envConfig.owners[chain];
const safeAddress =
ownerConfig.ownerOverrides?._safeAddress ??
ethers.constants.AddressZero;
const icaAddress =
ownerConfig.ownerOverrides?._icaAddress ??
ethers.constants.AddressZero;
// get actual onchain owner
const ownerAddress = await contracts.mailbox.owner();
// determine owner type
let ownerType = Owner.UNKNOWN;
if (eqAddressEvm(ownerAddress, deployer)) {
ownerType = Owner.DEPLOYER;
} else if (eqAddressEvm(ownerAddress, safeAddress)) {
ownerType = Owner.SAFE;
} else if (eqAddressEvm(ownerAddress, icaAddress)) {
ownerType = Owner.ICA;
}
return {
address: ownerAddress,
owner: ownerType,
};
},
),
);
console.table(mailboxOwners);
const totalChains = Object.keys(mailboxOwners).length;
console.log(`\nTotal chains: ${totalChains}`);
console.table(
Object.values(Owner).map((ownerType) => ({
'Owner Type': ownerType,
'Chain Count': Object.values(mailboxOwners).filter(
({ owner }) => owner === ownerType,
).length,
})),
);
}
main()
.then()
.catch((e) => {
console.error(e);
process.exit(1);
});
Loading…
Cancel
Save