Skip to content

Commit

Permalink
feat: Add warp config test (#5304)
Browse files Browse the repository at this point in the history
### Description
This PR adds warp config unit tests to compares the Registry's configs
to the configs generated by the Checkers. The goal of this test is to
ensure syncing between the programatic configs (e.g. Renzo) to whats
checked into the Registry.

### Backward compatibility

Yes

### Testing

Manual
  • Loading branch information
ltyu authored Jan 29, 2025
1 parent 6bec48d commit b8a7ba2
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 12 deletions.
2 changes: 1 addition & 1 deletion typescript/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@aws-sdk/client-kms": "^3.577.0",
"@aws-sdk/client-s3": "^3.577.0",
"@hyperlane-xyz/registry": "7.1.0",
"@hyperlane-xyz/registry": "7.4.0",
"@hyperlane-xyz/sdk": "8.5.0",
"@hyperlane-xyz/utils": "8.5.0",
"@inquirer/core": "9.0.10",
Expand Down
2 changes: 1 addition & 1 deletion typescript/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "8.5.0",
"dependencies": {
"@hyperlane-xyz/core": "5.11.1",
"@hyperlane-xyz/registry": "7.1.0",
"@hyperlane-xyz/registry": "7.4.0",
"@hyperlane-xyz/sdk": "8.5.0",
"@openzeppelin/contracts-upgradeable": "^4.9.3",
"ethers": "^5.7.2"
Expand Down
10 changes: 10 additions & 0 deletions typescript/infra/config/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fileURLToPath } from 'url';

import {
ChainAddresses,
GithubRegistry,
MergedRegistry,
PartialRegistry,
warpConfigToWarpAddresses,
Expand Down Expand Up @@ -33,6 +34,8 @@ const DEFAULT_REGISTRY_URI = join(
'hyperlane-registry',
);

const REGISTRY_PROXY = 'https://proxy.hyperlane.xyz';

// A global Registry singleton
// All uses of chain metadata or chain address artifacts should go through this registry.
let registry: FileSystemRegistry;
Expand Down Expand Up @@ -61,6 +64,13 @@ export function getRegistry(): FileSystemRegistry {
return registry;
}

export function getGithubRegistry(): GithubRegistry {
return new GithubRegistry({
proxyUrl: REGISTRY_PROXY,
logger: rootLogger.child({ module: 'infra-registry' }),
});
}

export function getChains(): ChainName[] {
return getRegistry().getChains();
}
Expand Down
2 changes: 1 addition & 1 deletion typescript/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@ethersproject/providers": "*",
"@google-cloud/secret-manager": "^5.5.0",
"@hyperlane-xyz/helloworld": "8.5.0",
"@hyperlane-xyz/registry": "7.1.0",
"@hyperlane-xyz/registry": "7.4.0",
"@hyperlane-xyz/sdk": "8.5.0",
"@hyperlane-xyz/utils": "8.5.0",
"@inquirer/prompts": "3.3.2",
Expand Down
52 changes: 52 additions & 0 deletions typescript/infra/test/warp-configs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { expect } from 'chai';

import { MultiProvider } from '@hyperlane-xyz/sdk';
import { diffObjMerge } from '@hyperlane-xyz/utils';

import { getGithubRegistry } from '../config/registry.js';
import { getWarpConfig, warpConfigGetterMap } from '../config/warp.js';
import {
getEnvironmentConfig,
getHyperlaneCore,
} from '../scripts/core-utils.js';

const DEFAULT_TIMEOUT = 20000;
describe('Warp Configs', async function () {
this.timeout(DEFAULT_TIMEOUT);
const ENV = 'mainnet3';
const warpIdsToCheck = Object.keys(warpConfigGetterMap);
let multiProvider: MultiProvider;

before(async () => {
multiProvider = (await getHyperlaneCore(ENV)).multiProvider;
});

const envConfig = getEnvironmentConfig(ENV);

for (const warpRouteId of warpIdsToCheck) {
it(`should match Github Registry configs for ${warpRouteId}`, async () => {
const warpConfig = await getWarpConfig(
multiProvider,
envConfig,
warpRouteId,
);
const githubRegistry = getGithubRegistry();
const configsFromGithub = await githubRegistry.getWarpDeployConfig(
warpRouteId,
);
const { mergedObject, isInvalid } = diffObjMerge(
warpConfig,
configsFromGithub!,
);

if (isInvalid) {
console.log('Differences', JSON.stringify(mergedObject, null, 2));
}

expect(
isInvalid,
`Registry config does not match Getter for ${warpRouteId}`,
).to.be.false;
});
}
});
2 changes: 1 addition & 1 deletion typescript/widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@eslint/js": "^9.15.0",
"@hyperlane-xyz/registry": "7.1.0",
"@hyperlane-xyz/registry": "7.4.0",
"@storybook/addon-essentials": "^7.6.14",
"@storybook/addon-interactions": "^7.6.14",
"@storybook/addon-links": "^7.6.14",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7320,7 +7320,7 @@ __metadata:
"@eslint/js": "npm:^9.15.0"
"@ethersproject/abi": "npm:*"
"@ethersproject/providers": "npm:*"
"@hyperlane-xyz/registry": "npm:7.1.0"
"@hyperlane-xyz/registry": "npm:7.4.0"
"@hyperlane-xyz/sdk": "npm:8.5.0"
"@hyperlane-xyz/utils": "npm:8.5.0"
"@inquirer/core": "npm:9.0.10"
Expand Down Expand Up @@ -7424,7 +7424,7 @@ __metadata:
dependencies:
"@eslint/js": "npm:^9.15.0"
"@hyperlane-xyz/core": "npm:5.11.1"
"@hyperlane-xyz/registry": "npm:7.1.0"
"@hyperlane-xyz/registry": "npm:7.4.0"
"@hyperlane-xyz/sdk": "npm:8.5.0"
"@nomiclabs/hardhat-ethers": "npm:^2.2.3"
"@nomiclabs/hardhat-waffle": "npm:^2.0.6"
Expand Down Expand Up @@ -7475,7 +7475,7 @@ __metadata:
"@ethersproject/providers": "npm:*"
"@google-cloud/secret-manager": "npm:^5.5.0"
"@hyperlane-xyz/helloworld": "npm:8.5.0"
"@hyperlane-xyz/registry": "npm:7.1.0"
"@hyperlane-xyz/registry": "npm:7.4.0"
"@hyperlane-xyz/sdk": "npm:8.5.0"
"@hyperlane-xyz/utils": "npm:8.5.0"
"@inquirer/prompts": "npm:3.3.2"
Expand Down Expand Up @@ -7537,13 +7537,13 @@ __metadata:
languageName: unknown
linkType: soft

"@hyperlane-xyz/registry@npm:7.1.0":
version: 7.1.0
resolution: "@hyperlane-xyz/registry@npm:7.1.0"
"@hyperlane-xyz/registry@npm:7.4.0":
version: 7.4.0
resolution: "@hyperlane-xyz/registry@npm:7.4.0"
dependencies:
yaml: "npm:2.4.5"
zod: "npm:^3.21.2"
checksum: 10/94b594ecd5734bc564e1a9ad220f4e5c9f04a98cd768cd4472afbaffe91009ae0680b8c4ffb01c13dbe913030dd730b22d5a73d7bfc88d6405df1e9f842ef939
checksum: 10/a7843cf18d69b595f2c7320f6165632685468a893d15c8e2456d1a41359a1c28d924f50931adbd7111494cae64a51efaa8e5ec102a581171bf051566fc872e00
languageName: node
linkType: hard

Expand Down Expand Up @@ -7642,7 +7642,7 @@ __metadata:
"@emotion/styled": "npm:^11.13.0"
"@eslint/js": "npm:^9.15.0"
"@headlessui/react": "npm:^2.1.8"
"@hyperlane-xyz/registry": "npm:7.1.0"
"@hyperlane-xyz/registry": "npm:7.4.0"
"@hyperlane-xyz/sdk": "npm:8.5.0"
"@hyperlane-xyz/utils": "npm:8.5.0"
"@interchain-ui/react": "npm:^1.23.28"
Expand Down

0 comments on commit b8a7ba2

Please sign in to comment.