From abe6751566d948df5c55f7d90b7742bfd8973f68 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Sun, 3 Nov 2024 07:25:02 +0000 Subject: [PATCH] fix: only return local keys from /eth/v1/keystores (#7215) * fix: only return local keys from /eth/v1/keystores * Fix fetching remote keys in node assertion --- packages/cli/src/cmds/validator/keymanager/impl.ts | 9 ++++++--- .../cli/test/utils/crucible/assertions/nodeAssertion.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/cmds/validator/keymanager/impl.ts b/packages/cli/src/cmds/validator/keymanager/impl.ts index 24bf653250eb..9a5a8bd72743 100644 --- a/packages/cli/src/cmds/validator/keymanager/impl.ts +++ b/packages/cli/src/cmds/validator/keymanager/impl.ts @@ -110,12 +110,15 @@ export class KeymanagerApi implements Api { } async listKeys(): ReturnType { - const pubkeys = this.validator.validatorStore.votingPubkeys(); + const localKeys = this.validator.validatorStore + .votingPubkeys() + .filter((pubkey) => this.validator.validatorStore.getSigner(pubkey)?.type === SignerType.Local); + return { - data: pubkeys.map((pubkey) => ({ + data: localKeys.map((pubkey) => ({ validatingPubkey: pubkey, derivationPath: "", - readonly: this.validator.validatorStore.getSigner(pubkey)?.type !== SignerType.Local, + readonly: false, })), }; } diff --git a/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts b/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts index 6b94f2e701a9..5a951ced89ce 100644 --- a/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts +++ b/packages/cli/test/utils/crucible/assertions/nodeAssertion.ts @@ -20,8 +20,13 @@ export const nodeAssertion: Assertion<"node", {health: number; keyManagerKeys: s if (node.validator.client === ValidatorClient.Lighthouse || getAllKeys(node.validator.keys).length === 0) { keyManagerKeys = []; } else { - const keys = (await node.validator.keyManager.listKeys()).value(); - keyManagerKeys = keys.map((k) => k.validatingPubkey); + if (node.validator.keys.type === "local") { + const keys = (await node.validator.keyManager.listKeys()).value(); + keyManagerKeys = keys.map((k) => k.validatingPubkey); + } else { + const keys = (await node.validator.keyManager.listRemoteKeys()).value(); + keyManagerKeys = keys.map((k) => k.pubkey); + } } return {health, keyManagerKeys};