Skip to content

Commit 694ade5

Browse files
authored
fix(bootstrap): skip static nodes generation when keys artifact is ex… (#111)
…cluded Static nodes are derived from validator keys, so they should only be generated when the 'keys' artifact is included in --artifacts filter. This prevents unwanted ConfigMap conflicts when selectively generating artifacts. - Skip static nodes in screen output when keys are not generated - Skip static nodes.json file output when keys are not generated - Skip static-nodes ConfigMap in kubernetes output when keys are not generated - Update tests to verify static nodes respect the keys artifact filter When --artifacts is not specified, all artifacts default to enabled (including keys), so static nodes continue to be generated in that case. ## Summary by Sourcery Skip static nodes generation when the keys artifact is excluded to avoid unwanted ConfigMap conflicts while preserving default behavior when no filter is specified Enhancements: - Omit static nodes from screen output, file output, and Kubernetes ConfigMaps if the keys artifact is disabled Tests: - Add tests to verify static nodes are only included when the keys filter is enabled and excluded otherwise
1 parent eb6dee4 commit 694ade5

2 files changed

Lines changed: 45 additions & 15 deletions

File tree

src/cli/commands/bootstrap/bootstrap.output.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ const outputToScreen = (payload: OutputPayload): void => {
165165
if (artifactFilter.keys) {
166166
printGroup("Validator Nodes", payload.validators);
167167
printFaucet(payload.faucet);
168+
printStaticNodes(payload.staticNodes);
168169
}
169-
printStaticNodes(payload.staticNodes);
170170
};
171171

172172
const formatTimestampForDirectory = (date: Date): string => {
@@ -246,11 +246,13 @@ const outputToFile = async (payload: OutputPayload): Promise<string> => {
246246
);
247247
}
248248

249-
fileEntries.push({
250-
path: join(directory, `${artifactNames.staticNodesConfigMapName}.json`),
251-
description: `${artifactNames.staticNodesConfigMapName}.json`,
252-
contents: `${JSON.stringify(payload.staticNodes, null, 2)}\n`,
253-
});
249+
if (artifactFilter.keys) {
250+
fileEntries.push({
251+
path: join(directory, `${artifactNames.staticNodesConfigMapName}.json`),
252+
description: `${artifactNames.staticNodesConfigMapName}.json`,
253+
contents: `${JSON.stringify(payload.staticNodes, null, 2)}\n`,
254+
});
255+
}
254256

255257
if (artifactFilter.subgraph && payload.subgraphHash) {
256258
fileEntries.push({
@@ -303,6 +305,11 @@ const outputToKubernetes = async (payload: OutputPayload): Promise<void> => {
303305
configMapSpecs.push(
304306
...createFaucetConfigSpecs(payload.faucet, artifactNames.faucetPrefix)
305307
);
308+
configMapSpecs.push({
309+
name: artifactNames.staticNodesConfigMapName,
310+
key: "static-nodes.json",
311+
value: `${JSON.stringify(payload.staticNodes, null, 2)}\n`,
312+
});
306313
}
307314

308315
if (artifactFilter.genesis) {
@@ -315,12 +322,6 @@ const outputToKubernetes = async (payload: OutputPayload): Promise<void> => {
315322
});
316323
}
317324

318-
configMapSpecs.push({
319-
name: artifactNames.staticNodesConfigMapName,
320-
key: "static-nodes.json",
321-
value: `${JSON.stringify(payload.staticNodes, null, 2)}\n`,
322-
});
323-
324325
if (artifactFilter.abis) {
325326
configMapSpecs.push(...createAbiConfigSpecs(payload.abiArtifacts));
326327
}

src/cli/commands/bootstrap/bootstrap.selective-artifacts.test.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe("Selective artifact generation - screen output", () => {
130130
expect(output).not.toContain("Genesis");
131131
});
132132

133-
test("includes static nodes regardless of filter", async () => {
133+
test("excludes static nodes when keys filter is disabled", async () => {
134134
output = "";
135135
const filter: ArtifactFilter = {
136136
genesis: false,
@@ -140,6 +140,19 @@ describe("Selective artifact generation - screen output", () => {
140140
allocations: false,
141141
};
142142
await outputResult("screen", createSamplePayload(filter));
143+
expect(output).not.toContain("Static Nodes");
144+
});
145+
146+
test("includes static nodes when keys filter is enabled", async () => {
147+
output = "";
148+
const filter: ArtifactFilter = {
149+
genesis: false,
150+
keys: true,
151+
abis: false,
152+
subgraph: false,
153+
allocations: false,
154+
};
155+
await outputResult("screen", createSamplePayload(filter));
143156
expect(output).toContain("Static Nodes");
144157
});
145158

@@ -224,7 +237,7 @@ describe("Selective artifact generation - file output", () => {
224237
expect(output).toContain("besu-subgraph");
225238
});
226239

227-
test("always writes static nodes regardless of filter", async () => {
240+
test("skips static nodes file when keys filter is disabled", async () => {
228241
const filter: ArtifactFilter = {
229242
genesis: false,
230243
keys: false,
@@ -236,7 +249,23 @@ describe("Selective artifact generation - file output", () => {
236249
const payload = createSamplePayload(filter);
237250
await outputResult("file", payload);
238251

239-
// Should always log about static nodes
252+
// Should not log about static nodes when keys are disabled
253+
expect(output).not.toContain("static-nodes");
254+
});
255+
256+
test("writes static nodes file when keys filter is enabled", async () => {
257+
const filter: ArtifactFilter = {
258+
genesis: false,
259+
keys: true,
260+
abis: false,
261+
subgraph: false,
262+
allocations: false,
263+
};
264+
output = "";
265+
const payload = createSamplePayload(filter);
266+
await outputResult("file", payload);
267+
268+
// Should log about static nodes when keys are enabled
240269
expect(output).toContain("static-nodes");
241270
});
242271
});

0 commit comments

Comments
 (0)