Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/api/src/beacon/routes/validator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ContainerType, Type, ValueOf} from "@chainsafe/ssz";
import {ChainForkConfig} from "@lodestar/config";
import {isForkPostDeneb, isForkPostElectra} from "@lodestar/params";
import {VALIDATOR_REGISTRY_LIMIT, isForkPostDeneb, isForkPostElectra} from "@lodestar/params";
import {
Attestation,
BLSSignature,
Expand Down Expand Up @@ -44,6 +44,7 @@ import {
VersionType,
} from "../../utils/metadata.js";
import {fromGraffitiHex, toBoolean, toGraffitiHex} from "../../utils/serdes.js";
import {WireFormat} from "../../utils/wireFormat.js";

export enum BuilderSelection {
Default = "default",
Expand Down Expand Up @@ -209,7 +210,10 @@ export const ProposerPreparationDataListType = ArrayOf(ProposerPreparationDataTy
export const BeaconCommitteeSelectionListType = ArrayOf(BeaconCommitteeSelectionType);
export const SyncCommitteeSelectionListType = ArrayOf(SyncCommitteeSelectionType);
export const LivenessResponseDataListType = ArrayOf(LivenessResponseDataType);
export const SignedValidatorRegistrationV1ListType = ArrayOf(ssz.bellatrix.SignedValidatorRegistrationV1);
export const SignedValidatorRegistrationV1ListType = ArrayOf(
ssz.bellatrix.SignedValidatorRegistrationV1,
VALIDATOR_REGISTRY_LIMIT
);

export type ValidatorIndices = ValueOf<typeof ValidatorIndicesType>;
export type AttesterDuty = ValueOf<typeof AttesterDutyType>;
Expand Down Expand Up @@ -955,6 +959,9 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
},
},
resp: EmptyResponseCodec,
init: {
requestWireFormat: WireFormat.ssz,
Copy link
Copy Markdown
Member Author

@nflaig nflaig Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of spec now ethereum/beacon-APIs#508, we can enable SSZ by default, worst case we get a 415 response from beacon node and fall back to JSON

},
},
};
}
Expand Down
15 changes: 10 additions & 5 deletions packages/api/src/builder/routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ChainForkConfig} from "@lodestar/config";
import {ForkName, isForkPostDeneb} from "@lodestar/params";
import {ForkName, VALIDATOR_REGISTRY_LIMIT, isForkPostDeneb} from "@lodestar/params";
import {
BLSPubkey,
ExecutionPayload,
Expand All @@ -22,21 +22,21 @@ import {
EmptyRequestCodec,
EmptyResponseCodec,
EmptyResponseData,
JsonOnlyReq,
WithVersion,
} from "../utils/codecs.js";
import {getPostBellatrixForkTypes, getPostDenebForkTypes, toForkName} from "../utils/fork.js";
import {fromHeaders} from "../utils/headers.js";
import {Endpoint, RouteDefinitions, Schema} from "../utils/index.js";
import {MetaHeader, VersionCodec, VersionMeta} from "../utils/metadata.js";
import {WireFormat} from "../utils/wireFormat.js";

// Mev-boost might not return any data if there are no bids from builders or min-bid threshold was not reached.
// In this case, we receive a success response (204) which is not handled as an error. The generic response
// handler already checks the status code and will not attempt to parse the body, but it will return no value.
// It is important that this type indicates that there might be no value to ensure it is properly handled downstream.
export type MaybeSignedBuilderBid = SignedBuilderBid | undefined;

const RegistrationsType = ArrayOf(ssz.bellatrix.SignedValidatorRegistrationV1);
const RegistrationsType = ArrayOf(ssz.bellatrix.SignedValidatorRegistrationV1, VALIDATOR_REGISTRY_LIMIT);

export type Endpoints = {
status: Endpoint<
Expand Down Expand Up @@ -88,12 +88,17 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
registerValidator: {
url: "/eth/v1/builder/validators",
method: "POST",
req: JsonOnlyReq({
req: {
writeReqJson: ({registrations}) => ({body: RegistrationsType.toJson(registrations)}),
parseReqJson: ({body}) => ({registrations: RegistrationsType.fromJson(body)}),
writeReqSsz: ({registrations}) => ({body: RegistrationsType.serialize(registrations)}),
parseReqSsz: ({body}) => ({registrations: RegistrationsType.deserialize(body)}),
schema: {body: Schema.ObjectArray},
}),
},
resp: EmptyResponseCodec,
init: {
requestWireFormat: WireFormat.ssz,
},
},
getHeader: {
url: "/eth/v1/builder/header/{slot}/{parent_hash}/{pubkey}",
Expand Down
Loading