From 549ead9ac5bacfee3edcdc542c41d20c08475ee5 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Wed, 30 Oct 2024 09:33:59 +0000 Subject: [PATCH] feat: add keymanager endpoint to retrieve proposer config --- packages/api/src/keymanager/routes.ts | 33 +++++++++++++++++++ packages/api/test/unit/keymanager/testData.ts | 15 +++++++++ .../cli/src/cmds/validator/keymanager/impl.ts | 4 +++ 3 files changed, 52 insertions(+) diff --git a/packages/api/src/keymanager/routes.ts b/packages/api/src/keymanager/routes.ts index 0db096d14e83..f91beccce804 100644 --- a/packages/api/src/keymanager/routes.ts +++ b/packages/api/src/keymanager/routes.ts @@ -109,6 +109,17 @@ export type SignerDefinition = { export type RemoteSignerDefinition = Pick; +export type ProposerConfig = { + graffiti?: string; + strictFeeRecipientCheck?: boolean; + feeRecipient?: string; + builder?: { + gasLimit?: number; + selection?: string; + boostFactor?: bigint; + }; +}; + /** * JSON serialized representation of a single keystore in EIP-2335: BLS12-381 Keystore format. * ``` @@ -356,6 +367,15 @@ export type Endpoints = { EmptyMeta >; + getProposerConfig: Endpoint< + // ⏎ + "GET", + {pubkey: PubkeyHex}, + {params: {pubkey: string}}, + ProposerConfig, + EmptyMeta + >; + /** * Create a signed voluntary exit message for an active validator, identified by a public key known to the validator * client. This endpoint returns a `SignedVoluntaryExit` object, which can be used to initiate voluntary exit via the @@ -635,6 +655,19 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions ({params: {pubkey}}), + parseReq: ({params: {pubkey}}) => ({pubkey}), + schema: { + params: {pubkey: Schema.StringRequired}, + }, + }, + resp: JsonOnlyResponseCodec, + }, + signVoluntaryExit: { url: "/eth/v1/validator/{pubkey}/voluntary_exit", method: "POST", diff --git a/packages/api/test/unit/keymanager/testData.ts b/packages/api/test/unit/keymanager/testData.ts index bd37798c4685..d9eb4eaa0da1 100644 --- a/packages/api/test/unit/keymanager/testData.ts +++ b/packages/api/test/unit/keymanager/testData.ts @@ -112,4 +112,19 @@ export const testData: GenericServerTestCases = { args: {pubkey: pubkeyRand}, res: undefined, }, + getProposerConfig: { + args: {pubkey: pubkeyRand}, + res: { + data: { + graffiti: "graffiti", + strictFeeRecipientCheck: false, + feeRecipient: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + builder: { + gasLimit: 30000000, + selection: "maxprofit", + boostFactor: BigInt(50), + }, + }, + }, + }, }; diff --git a/packages/cli/src/cmds/validator/keymanager/impl.ts b/packages/cli/src/cmds/validator/keymanager/impl.ts index b4233f3162cd..550640cc1c7e 100644 --- a/packages/cli/src/cmds/validator/keymanager/impl.ts +++ b/packages/cli/src/cmds/validator/keymanager/impl.ts @@ -364,6 +364,10 @@ export class KeymanagerApi implements Api { return {status: 204}; } + async getProposerConfig({pubkey}: {pubkey: PubkeyHex}): ReturnType { + return {data: this.validator.validatorStore.getProposerConfig(pubkey) ?? {}}; + } + async signVoluntaryExit({pubkey, epoch}: {pubkey: PubkeyHex; epoch?: Epoch}): ReturnType { if (!isValidatePubkeyHex(pubkey)) { throw new ApiError(400, `Invalid pubkey ${pubkey}`);