Skip to content

Commit

Permalink
fix: only return local keys from /eth/v1/keystores (#7215)
Browse files Browse the repository at this point in the history
* fix: only return local keys from /eth/v1/keystores

* Fix fetching remote keys in node assertion
  • Loading branch information
nflaig authored Nov 3, 2024
1 parent 07d1145 commit abe6751
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 6 additions & 3 deletions packages/cli/src/cmds/validator/keymanager/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ export class KeymanagerApi implements Api {
}

async listKeys(): ReturnType<Api["listKeys"]> {
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,
})),
};
}
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/test/utils/crucible/assertions/nodeAssertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit abe6751

Please sign in to comment.