-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cli warp route checker (#4667)
### Description This PR implements the `warp check` command to compare on-chain warp deployments with provided configuration files ### Drive-by changes - updated the `inputFileCommandOption` to be a function for defining cli input file args - defined the `DEFAULT_WARP_ROUTE_DEPLOYMENT_CONFIG_PATH` to avoid hardcoding the `./configs/warp-route-deployment.yaml` file path - implemented the `logCommandHeader` function to format the command header and avoid always having to manually log the `---` separator in command outputs - implements the `getWarpCoreConfigOrExit` to get the warp core configuration from either the registry or a user-defined path and exit early if no input value is provided - Updated the `IsmConfigSchema`s to include the `BaseIsmConfigSchema` because when parsing config files the address field was not included in the parsed object as it wasn't defined on the type Example output ![image](https://github.com/user-attachments/assets/07821a13-d2e2-4b73-b493-9a2c2829a7b3) ![image](https://github.com/user-attachments/assets/768d724f-c96e-4ff5-9c4d-332560c57626) ![image](https://github.com/user-attachments/assets/f92df7c5-acac-4ff7-974b-0334e4a221ab) ### Related issues - Fixes #4666 ### Backward compatibility - Yes ### Testing - Manual
- Loading branch information
Showing
13 changed files
with
596 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@hyperlane-xyz/cli': minor | ||
'@hyperlane-xyz/sdk': minor | ||
--- | ||
|
||
Adds the warp check command to compare warp routes config files with on chain warp route deployments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { stringify as yamlStringify } from 'yaml'; | ||
|
||
import { WarpRouteDeployConfig, normalizeConfig } from '@hyperlane-xyz/sdk'; | ||
import { ObjectDiff, diffObjMerge } from '@hyperlane-xyz/utils'; | ||
|
||
import { log, logGreen } from '../logger.js'; | ||
import '../utils/output.js'; | ||
import { formatYamlViolationsOutput } from '../utils/output.js'; | ||
|
||
export async function runWarpRouteCheck({ | ||
warpRouteConfig, | ||
onChainWarpConfig, | ||
}: { | ||
warpRouteConfig: WarpRouteDeployConfig; | ||
onChainWarpConfig: WarpRouteDeployConfig; | ||
}): Promise<void> { | ||
// Go through each chain and only add to the output the chains that have mismatches | ||
const [violations, isInvalid] = Object.keys(warpRouteConfig).reduce( | ||
(acc, chain) => { | ||
const { mergedObject, isInvalid } = diffObjMerge( | ||
normalizeConfig(onChainWarpConfig[chain]), | ||
normalizeConfig(warpRouteConfig[chain]), | ||
); | ||
|
||
if (isInvalid) { | ||
acc[0][chain] = mergedObject; | ||
acc[1] ||= isInvalid; | ||
} | ||
|
||
return acc; | ||
}, | ||
[{}, false] as [{ [index: string]: ObjectDiff }, boolean], | ||
); | ||
|
||
if (isInvalid) { | ||
log(formatYamlViolationsOutput(yamlStringify(violations, null, 2))); | ||
process.exit(1); | ||
} | ||
|
||
logGreen(`No violations found`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.