feat: cli core checker (#4687)
### Description This PR implements a new `core check` command to allow comparing local core contract configuration with the on chain deployment and detect mismatches. Examples: ![image](https://github.com/user-attachments/assets/5f0cd24a-45b1-4999-92d2-aa75182f9ef7) ![image](https://github.com/user-attachments/assets/e6b00714-0234-4f54-b63d-69aebd8148e9) ### Drive-by changes - Defined the `DEFAULT_CORE_DEPLOYMENT_CONFIG_PATH` to remove repeated and hardcoded './configs/core-config.yaml' strings - Implemented the `executeCoreRead` function to reuse it in the `core check` command logic. - Added memorization to the `EvmHookReader` because reading on chain configuration for chains like `arbitrum`, `ethereum` or `optimism` was taking more than 10 minutes to complete due to repeated hook config retrieval ### Related issues - https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/4666 ### Backward compatibility - Yes ### Testing - Manual ### Notes - Please merge #4667 before this PR because this was built on top of itpull/4659/merge
parent
e15dc267b8
commit
29341950e5
@ -0,0 +1,7 @@ |
||||
--- |
||||
'@hyperlane-xyz/utils': minor |
||||
'@hyperlane-xyz/cli': minor |
||||
'@hyperlane-xyz/sdk': minor |
||||
--- |
||||
|
||||
Adds new `core check` command to compare local configuration and on chain deployments. Adds memoization to the EvmHookReader to avoid repeating configuration derivation |
@ -0,0 +1,36 @@ |
||||
import { ChainName, CoreConfig, EvmCoreReader } from '@hyperlane-xyz/sdk'; |
||||
import { Address, assert } from '@hyperlane-xyz/utils'; |
||||
|
||||
import { CommandContext } from '../context/types.js'; |
||||
import { errorRed } from '../logger.js'; |
||||
|
||||
export async function executeCoreRead({ |
||||
context, |
||||
chain, |
||||
mailbox, |
||||
}: { |
||||
context: CommandContext; |
||||
chain: ChainName; |
||||
mailbox?: Address; |
||||
}): Promise<CoreConfig> { |
||||
if (!mailbox) { |
||||
const addresses = await context.registry.getChainAddresses(chain); |
||||
mailbox = addresses?.mailbox; |
||||
|
||||
assert( |
||||
mailbox, |
||||
`${chain} mailbox not provided and none found in registry.`, |
||||
); |
||||
} |
||||
|
||||
const evmCoreReader = new EvmCoreReader(context.multiProvider, chain); |
||||
try { |
||||
return evmCoreReader.deriveCoreConfig(mailbox); |
||||
} catch (e: any) { |
||||
errorRed( |
||||
`❌ Failed to read core config for mailbox ${mailbox} on ${chain}:`, |
||||
e, |
||||
); |
||||
process.exit(1); |
||||
} |
||||
} |
Loading…
Reference in new issue