Skip to content

Commit 1043561

Browse files
authored
feat: check-deploy with --registry (#5621)
### Description This PR - allows check-deploy to run with a `--registry` instead of having to check out the Registry branch. This is similar to how CLI's parameter. - Update getConfigFromMergedRegistry() to fetch from the array in `--registry` - Adds new functions getWarpCoreConfigFromMergedRegistry() and getWarpAddressesFromMergedRegistry() to fetch from the array in `--registry` - requires `--warpRouteId` to be filled in and no longer depend on the warpRouteIds mapping ### Related issues - Fixes #5240 ### Backward compatibility Yes - We now fetch from the FileSystem and Github Registry instead of just FileSystem ### Testing Manual
1 parent 439befe commit 1043561

14 files changed

Lines changed: 92 additions & 26 deletions

typescript/infra/config/registry.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
PartialRegistry,
88
warpConfigToWarpAddresses,
99
} from '@hyperlane-xyz/registry';
10-
import { FileSystemRegistry } from '@hyperlane-xyz/registry/fs';
10+
import {
11+
FileSystemRegistry,
12+
getRegistry as getMergedRegistry,
13+
} from '@hyperlane-xyz/registry/fs';
1114
import {
1215
ChainMap,
1316
ChainMetadata,
@@ -112,6 +115,32 @@ export function getWarpAddresses(
112115
return warpConfigToWarpAddresses(warpCoreConfig);
113116
}
114117

118+
export async function getWarpCoreConfigFromMergedRegistry(
119+
warpRouteId: string,
120+
registryUris: string[],
121+
): Promise<WarpCoreConfig> {
122+
const registry = getMergedRegistry({ registryUris, enableProxy: true });
123+
const warpRouteConfig = await registry.getWarpRoute(warpRouteId);
124+
125+
if (!warpRouteConfig) {
126+
throw new Error(
127+
`Warp route config for ${warpRouteId} not found in registry`,
128+
);
129+
}
130+
return warpRouteConfig;
131+
}
132+
133+
export async function getWarpAddressesFromMergedRegistry(
134+
warpRouteId: string,
135+
registryUris: string[],
136+
): Promise<ChainMap<ChainAddresses>> {
137+
const warpCoreConfig = await getWarpCoreConfigFromMergedRegistry(
138+
warpRouteId,
139+
registryUris,
140+
);
141+
return warpConfigToWarpAddresses(warpCoreConfig);
142+
}
143+
115144
export function getEnvChains(env: DeployEnvironment): ChainName[] {
116145
if (env === 'mainnet3') return mainnet3Chains;
117146
if (env === 'testnet4') return testnet4Chains;

typescript/infra/config/warp.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ async function getConfigFromMergedRegistry(
136136
_routerConfig: ChainMap<RouterConfigWithoutOwner>,
137137
_abacusWorksEnvOwnerConfig: ChainMap<OwnableConfig>,
138138
warpRouteId: string,
139+
registryUris: string[],
139140
): Promise<ChainMap<HypTokenRouterConfig>> {
140141
const registry = getRegistry({
141-
registryUris: [DEFAULT_REGISTRY_URI],
142+
registryUris,
142143
enableProxy: true,
143144
});
144145
const warpRoute = await registry.getWarpDeployConfig(warpRouteId);
@@ -176,6 +177,7 @@ export async function getWarpConfig(
176177
multiProvider: MultiProvider,
177178
envConfig: EnvironmentConfig,
178179
warpRouteId: string,
180+
registryUris = [DEFAULT_REGISTRY_URI],
179181
): Promise<ChainMap<HypTokenRouterConfig>> {
180182
const routerConfig = await getRouterConfigsForAllVms(
181183
envConfig,
@@ -212,5 +214,6 @@ export async function getWarpConfig(
212214
routerConfigWithoutOwner,
213215
abacusWorksEnvOwnerConfig,
214216
warpRouteId,
217+
registryUris,
215218
);
216219
}

typescript/infra/scripts/agent-utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,26 @@ export function withOutputFile<T>(args: Argv<T>) {
201201
.alias('o', 'outFile');
202202
}
203203

204-
export function withWarpRouteId<T>(args: Argv<T>) {
204+
export function withKnownWarpRouteId<T>(args: Argv<T>) {
205205
return args
206206
.describe('warpRouteId', 'warp route id')
207207
.string('warpRouteId')
208208
.choices('warpRouteId', Object.values(WarpRouteIds));
209209
}
210210

211+
export function withWarpRouteId<T>(args: Argv<T>) {
212+
return args.describe('warpRouteId', 'warp route id').string('warpRouteId');
213+
}
214+
211215
export function withDryRun<T>(args: Argv<T>) {
212216
return args
213217
.describe('dryRun', 'Dry run')
214218
.boolean('dryRun')
215219
.default('dryRun', false);
216220
}
217221

218-
export function withWarpRouteIdRequired<T>(args: Argv<T>) {
219-
return withWarpRouteId(args).demandOption('warpRouteId');
222+
export function withKnownWarpRouteIdRequired<T>(args: Argv<T>) {
223+
return withKnownWarpRouteId(args).demandOption('warpRouteId');
220224
}
221225

222226
export function withProtocol<T>(args: Argv<T>) {

typescript/infra/scripts/check/check-deploy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ async function main() {
1414
fork,
1515
govern,
1616
warpRouteId,
17+
registry,
1718
} = await getCheckDeployArgs().argv;
1819

1920
const governor = await getGovernor(
@@ -25,6 +26,8 @@ async function main() {
2526
chains,
2627
fork,
2728
govern,
29+
undefined,
30+
registry,
2831
);
2932

3033
if (fork) {

typescript/infra/scripts/check/check-utils.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import { eqAddress, objFilter } from '@hyperlane-xyz/utils';
2323

2424
import { Contexts } from '../../config/contexts.js';
2525
import { DEPLOYER } from '../../config/environments/mainnet3/owners.js';
26-
import { getWarpAddresses } from '../../config/registry.js';
26+
import {
27+
getWarpAddresses,
28+
getWarpAddressesFromMergedRegistry,
29+
} from '../../config/registry.js';
2730
import { getWarpConfig } from '../../config/warp.js';
2831
import { chainsToSkip } from '../../src/config/chain.js';
2932
import { DeployEnvironment } from '../../src/config/environment.js';
@@ -45,11 +48,12 @@ import {
4548
withContext,
4649
withFork,
4750
withGovern,
51+
withKnownWarpRouteId,
4852
withModule,
4953
withPushMetrics,
50-
withWarpRouteId,
5154
} from '../agent-utils.js';
5255
import { getEnvironmentConfig, getHyperlaneCore } from '../core-utils.js';
56+
import { withRegistryUris } from '../github-utils.js';
5357
import { getHelloWorldApp } from '../helloworld/utils.js';
5458

5559
export function getCheckBaseArgs() {
@@ -63,7 +67,7 @@ export function getCheckWarpDeployArgs() {
6367
}
6468

6569
export function getCheckDeployArgs() {
66-
return withWarpRouteId(withModule(getCheckBaseArgs()));
70+
return withRegistryUris(withKnownWarpRouteId(withModule(getCheckBaseArgs())));
6771
}
6872

6973
export async function getGovernor(
@@ -76,6 +80,7 @@ export async function getGovernor(
7680
fork?: string,
7781
govern?: boolean,
7882
multiProvider: MultiProvider | undefined = undefined,
83+
registryUris?: string[],
7984
) {
8085
const envConfig = getEnvironmentConfig(environment);
8186
// If the multiProvider is not passed in, get it from the environment
@@ -196,8 +201,15 @@ export async function getGovernor(
196201
if (!warpRouteId) {
197202
warpRouteId = await getWarpRouteIdInteractive();
198203
}
199-
const config = await getWarpConfig(multiProvider, envConfig, warpRouteId);
200-
const warpAddresses = getWarpAddresses(warpRouteId);
204+
const config = await getWarpConfig(
205+
multiProvider,
206+
envConfig,
207+
warpRouteId,
208+
registryUris,
209+
);
210+
const warpAddresses = registryUris
211+
? await getWarpAddressesFromMergedRegistry(warpRouteId, registryUris)
212+
: getWarpAddresses(warpRouteId);
201213
const filteredAddresses = Object.keys(warpAddresses) // filter out changes not in config
202214
.filter((key) => key in config)
203215
.reduce((obj, key) => {

typescript/infra/scripts/deploy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ import {
4949
withConcurrentDeploy,
5050
withContext,
5151
withFork,
52+
withKnownWarpRouteId,
5253
withModule,
53-
withWarpRouteId,
5454
} from './agent-utils.js';
5555
import { getEnvironmentConfig, getHyperlaneCore } from './core-utils.js';
5656

@@ -67,7 +67,9 @@ async function main() {
6767
} = await withContext(
6868
withConcurrentDeploy(
6969
withChains(
70-
withModule(withFork(withWarpRouteId(withBuildArtifactPath(getArgs())))),
70+
withModule(
71+
withFork(withKnownWarpRouteId(withBuildArtifactPath(getArgs()))),
72+
),
7173
),
7274
),
7375
).argv;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Argv } from 'yargs';
2+
3+
export function withRegistryUris<T>(args: Argv<T>) {
4+
return args
5+
.describe('registry', 'Github registry urls (comma separated)')
6+
.string('registry')
7+
.array('registry');
8+
}

typescript/infra/scripts/warp-routes/deploy-warp-monitor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
getAgentConfig,
1919
getArgs,
2020
getWarpRouteIdsInteractive,
21-
withWarpRouteId,
21+
withKnownWarpRouteId,
2222
} from '../agent-utils.js';
2323
import { getEnvironmentConfig } from '../core-utils.js';
2424

@@ -42,7 +42,8 @@ async function validateRegistryCommit(commit: string) {
4242

4343
async function main() {
4444
configureRootLogger(LogFormat.Pretty, LogLevel.Info);
45-
const { environment, warpRouteId } = await withWarpRouteId(getArgs()).argv;
45+
const { environment, warpRouteId } = await withKnownWarpRouteId(getArgs())
46+
.argv;
4647
const envConfig = getEnvironmentConfig(environment);
4748
const multiProtocolProvider = await envConfig.getMultiProtocolProvider();
4849

typescript/infra/scripts/warp-routes/generate-strategy-config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ import {
99

1010
import { strategyConfigGetterMap } from '../../config/warp.js';
1111
import { writeYamlAtPath } from '../../src/utils/utils.js';
12-
import { getArgs, withOutputFile, withWarpRouteId } from '../agent-utils.js';
12+
import {
13+
getArgs,
14+
withKnownWarpRouteId,
15+
withOutputFile,
16+
} from '../agent-utils.js';
1317

1418
// Writes the strategy config to disk
1519
async function main() {
1620
const logger = configureRootLogger(LogFormat.Pretty, LogLevel.Info);
1721
const { warpRouteId, outFile } = await withOutputFile(
18-
withWarpRouteId(getArgs()),
22+
withKnownWarpRouteId(getArgs()),
1923
).argv;
2024
assert(warpRouteId, 'warpRouteId not provided');
2125

typescript/infra/scripts/warp-routes/generate-warp-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import { getWarpConfig } from '../../config/warp.js';
77
import { writeYamlAtPath } from '../../src/utils/utils.js';
88
import {
99
getArgs,
10+
withKnownWarpRouteIdRequired,
1011
withOutputFile,
11-
withWarpRouteIdRequired,
1212
} from '../agent-utils.js';
1313
import { getEnvironmentConfig, getHyperlaneCore } from '../core-utils.js';
1414

1515
async function main() {
1616
const { warpRouteId, environment, outFile } = await withOutputFile(
17-
withWarpRouteIdRequired(getArgs()),
17+
withKnownWarpRouteIdRequired(getArgs()),
1818
).argv;
1919

2020
const { multiProvider } = await getHyperlaneCore(environment);

0 commit comments

Comments
 (0)