Skip to content

Commit

Permalink
feat: add keymanager endpoint to retrieve proposer config
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Oct 30, 2024
1 parent 558ec2f commit 549ead9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/api/src/keymanager/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ export type SignerDefinition = {

export type RemoteSignerDefinition = Pick<SignerDefinition, "pubkey" | "url">;

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.
* ```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -635,6 +655,19 @@ export function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpo
resp: EmptyResponseCodec,
},

getProposerConfig: {
url: "/eth/v0/validator/{pubkey}/proposer_config",
method: "GET",
req: {
writeReq: ({pubkey}) => ({params: {pubkey}}),
parseReq: ({params: {pubkey}}) => ({pubkey}),
schema: {
params: {pubkey: Schema.StringRequired},
},
},
resp: JsonOnlyResponseCodec,
},

signVoluntaryExit: {
url: "/eth/v1/validator/{pubkey}/voluntary_exit",
method: "POST",
Expand Down
15 changes: 15 additions & 0 deletions packages/api/test/unit/keymanager/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,19 @@ export const testData: GenericServerTestCases<Endpoints> = {
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),
},
},
},
},
};
4 changes: 4 additions & 0 deletions packages/cli/src/cmds/validator/keymanager/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ export class KeymanagerApi implements Api {
return {status: 204};
}

async getProposerConfig({pubkey}: {pubkey: PubkeyHex}): ReturnType<Api["getProposerConfig"]> {
return {data: this.validator.validatorStore.getProposerConfig(pubkey) ?? {}};
}

async signVoluntaryExit({pubkey, epoch}: {pubkey: PubkeyHex; epoch?: Epoch}): ReturnType<Api["signVoluntaryExit"]> {
if (!isValidatePubkeyHex(pubkey)) {
throw new ApiError(400, `Invalid pubkey ${pubkey}`);
Expand Down

0 comments on commit 549ead9

Please sign in to comment.