Skip to content

Commit 6b44c2b

Browse files
committed
fix(test-suite): restore simple acl workflow compat
1 parent debfd54 commit 6b44c2b

File tree

5 files changed

+81
-7
lines changed

5 files changed

+81
-7
lines changed

test-suite/fhevm/src/artifacts.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from "node:path";
33

44
import { describe, expect, test } from "bun:test";
55

6-
import { composeUp, resolvedComposeEnv, serviceNameList } from "./artifacts";
6+
import { composeUp, resolvedComposeEnv, rewriteRelayerConfig, serviceNameList } from "./artifacts";
77
import { composePath, TEMPLATE_COMPOSE_DIR } from "./layout";
88
import { stubState } from "./test-helpers";
99

@@ -125,4 +125,25 @@ describe("compose templates", () => {
125125
],
126126
]);
127127
});
128+
129+
test("legacy relayer config keeps top-level readiness retry", () => {
130+
const config = rewriteRelayerConfig(
131+
{
132+
gateway: {
133+
readiness_checker: {
134+
host_acl_check: { retry: { max_attempts: 3, retry_interval_ms: 1000 } },
135+
gw_ciphertext_check: { retry: { max_attempts: 15, retry_interval_ms: 2000 } },
136+
public_decrypt: { capacity: 1 },
137+
user_decrypt: { capacity: 1 },
138+
},
139+
},
140+
},
141+
stubState(),
142+
) as { gateway: { readiness_checker: Record<string, unknown> } };
143+
expect(config.gateway.readiness_checker.retry).toEqual({
144+
max_attempts: 15,
145+
retry_interval_ms: 2000,
146+
});
147+
expect(config.gateway.readiness_checker.host_acl_check).toBeUndefined();
148+
});
128149
});

test-suite/fhevm/src/artifacts.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import YAML from "yaml";
55

66
import {
77
compatPolicyForState,
8+
requiresLegacyRelayerReadinessConfig,
89
requiresMultichainAclAddress,
910
type CompatPolicy,
1011
} from "./compat";
@@ -30,7 +31,6 @@ import {
3031
import type { BuiltImage, InstanceOverride, OverrideGroup, State } from "./types";
3132
import type { RunOptions, Runner } from "./utils";
3233
import {
33-
copyFile,
3434
ensureDir,
3535
exists,
3636
mergeArgs,
@@ -351,6 +351,33 @@ const deriveWallet = async (runner: Runner, mnemonic: string, index: number) =>
351351
return { address, privateKey };
352352
};
353353

354+
export const rewriteRelayerConfig = (config: Record<string, unknown>, state: Pick<State, "versions">) => {
355+
if (!requiresLegacyRelayerReadinessConfig(state)) {
356+
return config;
357+
}
358+
const gateway = config.gateway;
359+
if (!gateway || typeof gateway !== "object") {
360+
return config;
361+
}
362+
const readiness = (gateway as Record<string, unknown>).readiness_checker;
363+
if (!readiness || typeof readiness !== "object") {
364+
return config;
365+
}
366+
const current = readiness as Record<string, unknown>;
367+
(gateway as Record<string, unknown>).readiness_checker = Object.fromEntries(
368+
Object.entries({
369+
retry:
370+
current.retry ??
371+
(current.gw_ciphertext_check as Record<string, unknown> | undefined)?.retry ??
372+
(current.host_acl_check as Record<string, unknown> | undefined)?.retry,
373+
public_decrypt: current.public_decrypt,
374+
user_decrypt: current.user_decrypt,
375+
delegated_user_decrypt: current.delegated_user_decrypt,
376+
}).filter(([, value]) => value !== undefined),
377+
);
378+
return config;
379+
};
380+
354381
const writeRuntimeEnvFiles = async (state: State, deps: Pick<ArtifactDeps, "runner">) => {
355382
await ensureDir(ENV_DIR);
356383
const compat = compatPolicyForState(state);
@@ -467,7 +494,11 @@ const writeRuntimeEnvFiles = async (state: State, deps: Pick<ArtifactDeps, "runn
467494
versionsEnvPath,
468495
state.versions.env,
469496
);
470-
await copyFile(TEMPLATE_RELAYER_CONFIG, relayerConfigPath);
497+
const relayerConfig = rewriteRelayerConfig(
498+
YAML.parse(await fs.readFile(TEMPLATE_RELAYER_CONFIG, "utf8")) as Record<string, unknown>,
499+
state,
500+
);
501+
await fs.writeFile(relayerConfigPath, YAML.stringify(relayerConfig));
471502
};
472503

473504
const imageRefsForServices = async (component: string, services: string[]) => {

test-suite/fhevm/src/cli.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "./artifacts";
1313
import { REPO_ROOT, STATE_DIR, TEST_GREP, composePath, resolveServiceOverrides } from "./layout";
1414
import { main, overrideWarnings, probeBootstrap, resolveUpgradePlan } from "./runtime";
15-
import { compatPolicyForState } from "./compat";
15+
import { compatPolicyForState, requiresMultichainAclAddress } from "./compat";
1616
import { predictedCrsId, predictedKeyId } from "./utils";
1717
import { applyVersionEnvOverrides, createGitHubClient, resolveTarget } from "./versions";
1818
import {
@@ -359,6 +359,20 @@ describe("runtime invariants", () => {
359359
]);
360360
});
361361

362+
test("full modern workspace protocol overrides disable multichain acl discovery requirements", () => {
363+
expect(
364+
requiresMultichainAclAddress(
365+
stubState({
366+
overrides: [
367+
{ group: "coprocessor" },
368+
{ group: "gateway-contracts" },
369+
{ group: "host-contracts" },
370+
],
371+
}),
372+
),
373+
).toBe(false);
374+
});
375+
362376
test("probeBootstrap treats transient material fetch failures as retryable", async () => {
363377
const state = stubState({
364378
discovery: {

test-suite/fhevm/src/compat.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,16 @@ const versionLt = (version: string, target: CompatSemver) => {
7373
return false;
7474
};
7575

76-
export const requiresMultichainAclAddress = (state: Pick<State, "versions">) =>
77-
versionLt(state.versions.env.COPROCESSOR_TX_SENDER_VERSION ?? "", [0, 12, 0]);
76+
const usesModernWorkspaceProtocol = (state: Pick<State, "overrides">) =>
77+
["coprocessor", "gateway-contracts", "host-contracts"].every((group) =>
78+
state.overrides.some((override) => override.group === group),
79+
);
80+
81+
export const requiresMultichainAclAddress = (state: Pick<State, "versions" | "overrides">) =>
82+
!usesModernWorkspaceProtocol(state) && versionLt(state.versions.env.COPROCESSOR_TX_SENDER_VERSION ?? "", [0, 12, 0]);
83+
84+
export const requiresLegacyRelayerReadinessConfig = (state: Pick<State, "versions">) =>
85+
versionLt(state.versions.env.RELAYER_VERSION ?? "", [0, 10, 0]);
7886

7987
export const compatPolicyForState = (state: State): CompatPolicy => {
8088
const policy: CompatPolicy = { coprocessorArgs: {}, connectorEnv: {} };

test-suite/fhevm/src/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ const discoverContracts = async (deps: RuntimeDeps): Promise<Pick<Discovery, "ga
508508
};
509509
};
510510

511-
const validateDiscovery = (state: Pick<State, "target" | "versions" | "discovery">) => {
511+
const validateDiscovery = (state: Pick<State, "target" | "versions" | "discovery" | "overrides">) => {
512512
const discovery = state.discovery;
513513
if (!discovery) {
514514
throw new Error("Missing discovery state");

0 commit comments

Comments
 (0)