Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bump relayer memory usage to 20GB, start using new SVM submission in relayer #5063

Merged
merged 6 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-seahorses-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/utils': patch
---

Require concurrency > 0 for concurrentMap
6 changes: 3 additions & 3 deletions typescript/infra/config/environments/mainnet3/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,21 +482,21 @@ const metricAppContextsGetter = (): MetricAppContext[] => {
const relayerResources = {
requests: {
cpu: '14000m',
memory: '15Gi',
memory: '20G',
},
};

const validatorResources = {
requests: {
cpu: '500m',
memory: '1Gi',
memory: '1G',
},
};

const scraperResources = {
requests: {
cpu: '2000m',
memory: '4Gi',
memory: '4G',
},
};

Expand Down
7 changes: 7 additions & 0 deletions typescript/infra/scripts/agent-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ export function withConcurrentDeploy<T>(args: Argv<T>) {
.default('concurrentDeploy', false);
}

export function withConcurrency<T>(args: Argv<T>) {
return args
.describe('concurrency', 'Number of concurrent deploys')
.number('concurrency')
.default('concurrency', 1);
}

export function withRpcUrls<T>(args: Argv<T>) {
return args
.describe(
Expand Down
22 changes: 16 additions & 6 deletions typescript/infra/scripts/agents/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { concurrentMap } from '@hyperlane-xyz/utils';

import {
AgentHelmManager,
RelayerHelmManager,
Expand All @@ -7,12 +9,13 @@ import {
import { RootAgentConfig } from '../../src/config/agent/agent.js';
import { EnvironmentConfig } from '../../src/config/environment.js';
import { Role } from '../../src/roles.js';
import { HelmCommand } from '../../src/utils/helm.js';
import { HelmCommand, HelmManager } from '../../src/utils/helm.js';
import {
assertCorrectKubeContext,
getArgs,
withAgentRolesRequired,
withChains,
withConcurrency,
withContext,
} from '../agent-utils.js';
import { getConfigsBasedOnArgs } from '../core-utils.js';
Expand All @@ -24,6 +27,7 @@ export class AgentCli {
initialized = false;
dryRun = false;
chains?: string[];
concurrency = 1;

public async runHelmCommand(command: HelmCommand) {
await this.init();
Expand Down Expand Up @@ -63,15 +67,20 @@ export class AgentCli {
console.log('Dry run values:\n', JSON.stringify(values, null, 2));
}

for (const m of Object.values(managers)) {
await m.runHelmCommand(command, this.dryRun);
}
await concurrentMap(
this.concurrency,
Object.entries(managers),
async ([key, manager]) => {
console.log(`Running helm command for ${key}`);
await manager.runHelmCommand(command, { dryRun: this.dryRun });
},
);
}

protected async init() {
if (this.initialized) return;
const argv = await withChains(
withAgentRolesRequired(withContext(getArgs())),
const argv = await withConcurrency(
withChains(withAgentRolesRequired(withContext(getArgs()))),
)
.describe('dry-run', 'Run through the steps without making any changes')
.boolean('dry-run').argv;
Expand All @@ -92,5 +101,6 @@ export class AgentCli {
this.dryRun = argv.dryRun || false;
this.initialized = true;
this.chains = argv.chains;
this.concurrency = argv.concurrency;
}
}
2 changes: 1 addition & 1 deletion typescript/infra/src/helloworld/kathy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ export class KathyHelmManager extends HelmManager<HelmValues> {
);
await kathyKey.createIfNotExists();

super.runHelmCommand(action, dryRun);
await super.runHelmCommand(action, { dryRun });
}
}
23 changes: 19 additions & 4 deletions typescript/infra/src/utils/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,17 @@ export function getDeployableHelmChartName(helmChartConfig: HelmChartConfig) {
return helmChartConfig.name;
}

export function buildHelmChartDependencies(chartPath: string) {
return execCmd(`cd ${chartPath} && helm dependency build`, {}, false, true);
export function buildHelmChartDependencies(
chartPath: string,
updateRepoCache: boolean,
) {
const flags = updateRepoCache ? '' : '--skip-refresh';
return execCmd(
`cd ${chartPath} && helm dependency build ${flags}`,
{},
false,
true,
);
}

// Convenience function to remove a helm release without having a HelmManger for it.
Expand All @@ -111,7 +120,13 @@ export abstract class HelmManager<T = HelmValues> {
*/
abstract helmValues(): Promise<T>;

async runHelmCommand(action: HelmCommand, dryRun?: boolean): Promise<void> {
async runHelmCommand(
action: HelmCommand,
options: { dryRun?: boolean; updateRepoCache?: boolean },
): Promise<void> {
const dryRun = options.dryRun ?? false;
const updateRepoCache = options.updateRepoCache ?? false;

const cmd = ['helm', action];
if (dryRun) cmd.push('--dry-run');

Expand Down Expand Up @@ -141,7 +156,7 @@ export abstract class HelmManager<T = HelmValues> {
}
}

await buildHelmChartDependencies(this.helmChartPath);
await buildHelmChartDependencies(this.helmChartPath, updateRepoCache);
cmd.push(
this.helmReleaseName,
this.helmChartPath,
Expand Down
2 changes: 2 additions & 0 deletions typescript/utils/src/async.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { rootLogger } from './logging.js';
import { assert } from './validation.js';

/**
* Return a promise that resolves in ms milliseconds.
Expand Down Expand Up @@ -159,6 +160,7 @@ export async function concurrentMap<A, B>(
mapFn: (val: A, idx: number) => Promise<B>,
): Promise<B[]> {
let res: B[] = [];
assert(concurrency > 0, 'concurrency must be greater than 0');
for (let i = 0; i < xs.length; i += concurrency) {
const remaining = xs.length - i;
const sliceSize = Math.min(remaining, concurrency);
Expand Down
Loading