-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Mev builder api integration * extract builder in its own folder space * fix engine path * rebase fixes * refactor the builder with latest beacon state transtion processing changes * fix the registration signature * make typescript happy * remove the early return * rebase fixes * gas limit option * builder enabling on validator, gaslimit and other refac * fixes * Rebase fixes with the api refac * some cleanup fixes * comment explaining the immediate registration call * use already defined batchItems * serialize the validator registration chunks * validate transactions root on payload response * removing the BlockType from global types and sandboxing it just inside block factory * make builder optional in dev validator setup * option builder with dev val init with keystores * add builder api test routes * fix validator tests * fix block assembly scripts * handle the mergemock customization * fix body extraction * remove linter superession for boolean expressions * Implement type-guards * fix breaking build * execution is enabled if stateroot non zero * Fix spec tests Co-authored-by: dapplion <35266934+dapplion@users.noreply.github.com>
- Loading branch information
Showing
64 changed files
with
927 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,69 @@ | ||
import {ReturnTypes, RoutesData, ReqSerializers, reqEmpty, ReqEmpty} from "../utils/index.js"; | ||
import {ssz, bellatrix, Slot, Root, BLSPubkey} from "@chainsafe/lodestar-types"; | ||
import {fromHexString, toHexString} from "@chainsafe/ssz"; | ||
import { | ||
ReturnTypes, | ||
RoutesData, | ||
Schema, | ||
ReqSerializers, | ||
reqOnlyBody, | ||
ContainerData, | ||
reqEmpty, | ||
ReqEmpty, | ||
ArrayOf, | ||
} from "../utils/index.js"; | ||
// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes | ||
|
||
export type Api = { | ||
checkStatus(): Promise<void>; | ||
registerValidator(registrations: bellatrix.SignedValidatorRegistrationV1[]): Promise<void>; | ||
getPayloadHeader( | ||
slot: Slot, | ||
parentHash: Root, | ||
proposerPubKey: BLSPubkey | ||
): Promise<{data: bellatrix.SignedBuilderBid}>; | ||
submitSignedBlindedBlock( | ||
signedBlock: bellatrix.SignedBlindedBeaconBlock | ||
): Promise<{data: bellatrix.ExecutionPayload}>; | ||
}; | ||
|
||
/** | ||
* Define javascript values for each route | ||
*/ | ||
export const routesData: RoutesData<Api> = { | ||
checkStatus: {url: "/eth/v1/builder/status", method: "GET"}, | ||
registerValidator: {url: "/eth/v1/builder/validators", method: "POST"}, | ||
getPayloadHeader: {url: "/eth/v1/builder/header/:slot/:parent_hash/:pubkey", method: "GET"}, | ||
submitSignedBlindedBlock: {url: "/eth/v1/builder/blinded_blocks", method: "POST"}, | ||
}; | ||
|
||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
export type ReqTypes = { | ||
checkStatus: ReqEmpty; | ||
registerValidator: {body: unknown}; | ||
getPayloadHeader: {params: {slot: Slot; parent_hash: string; pubkey: string}}; | ||
submitSignedBlindedBlock: {body: unknown}; | ||
}; | ||
|
||
export function getReqSerializers(): ReqSerializers<Api, ReqTypes> { | ||
return { | ||
checkStatus: reqEmpty, | ||
registerValidator: reqOnlyBody(ArrayOf(ssz.bellatrix.SignedValidatorRegistrationV1), Schema.ObjectArray), | ||
getPayloadHeader: { | ||
writeReq: (slot, parentHash, proposerPubKey) => ({ | ||
params: {slot, parent_hash: toHexString(parentHash), pubkey: toHexString(proposerPubKey)}, | ||
}), | ||
parseReq: ({params}) => [params.slot, fromHexString(params.parent_hash), fromHexString(params.pubkey)], | ||
schema: { | ||
params: {slot: Schema.UintRequired, parent_hash: Schema.StringRequired, pubkey: Schema.StringRequired}, | ||
}, | ||
}, | ||
submitSignedBlindedBlock: reqOnlyBody(ssz.bellatrix.SignedBlindedBeaconBlock, Schema.Object), | ||
}; | ||
} | ||
|
||
export function getReturnTypes(): ReturnTypes<Api> { | ||
return {}; | ||
return { | ||
getPayloadHeader: ContainerData(ssz.bellatrix.SignedBuilderBid), | ||
submitSignedBlindedBlock: ContainerData(ssz.bellatrix.ExecutionPayload), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.