Skip to content

Commit

Permalink
feat: switch blinded and full block production to produce block v3
Browse files Browse the repository at this point in the history
update the impl interfaces

Restore the previous versions

update test

fix oapi spec

fix tests

fix merge tests

fix tests

fix the tests

implement produce blockv3

refac forktypes

plug v3 into vlidator and get it working

mock test produceblockv3 and fix issues

fix lint

fixes

update head opts

cleanup the validator flags

shift fee recipient to extra args as well

typo

fix tests

missed commit

deprecate flag instead of removing

backward produceblock v2 compatability

lint

disable produce blockv3 for mixed tests

run on only execution

sim option fixes

improve log

pass args

fix spell check

sort wordlist

chore: sort wordlist

chore: fix spell check

refactor block types and introduce builder/execution race in produceblindedblock api as well

fix the publish blinded block to pick locally cached blinded data

add flag in get init dev vals

fix unit test

fixes

switch to v2 as default fix issues and run sim tests on mix configurations

remove utf8 graffiti from text log

apply feedback on api

cleanup on the sidecar cache

blinded to full utils

small produced cache cleanup

add metrics

cleanup response parsing

lint

further improv

improve interface

fix

apply feedback
  • Loading branch information
g11tech committed Oct 24, 2023
1 parent ace85ff commit 676e315
Show file tree
Hide file tree
Showing 54 changed files with 1,385 additions and 828 deletions.
1 change: 1 addition & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ nodemodule
overriden
params
plaintext
produceBlockV
prover
req
reqresp
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/beacon-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ A young testnet should take a few hours to sync. If you see multiple or consiste

### Checkpoint Sync

If you are starting your node from a blank db, like starting from genesis, or from the last saved state in db and the network is now far ahead, your node will be susceptible to "long range attacks." Ethereum's solution to this is via something called weak subjectivity. [Read Vitalik's illuminating post explaining weak subjectivity.](https://blog.ethereum.org/2014/11/25/proof-stake-learned-love-weak-subjectivity/).
If you are starting your node from a blank db, like starting from genesis, or from the last saved state in db and the network is now far ahead, your node will be susceptible to "long range attacks." Ethereum's solution to this is via something called weak subjectivity. [Read Vitalik's illuminating post explaining weak subjectivity.](https://blog.ethereum.org/2014/11/25/proof-stake-learned-love-weak-subjectivity/).

If you have a synced beacon node available (e.g., your friend's node or an infrastructure provider) and a trusted checkpoint you can rely on, you can start off your beacon node in under a minute! And at the same time kicking the "long range attack" in its butt!

Expand Down
57 changes: 31 additions & 26 deletions packages/api/src/beacon/routes/beacon/block.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import {ContainerType} from "@chainsafe/ssz";
import {ForkName} from "@lodestar/params";
import {ChainForkConfig} from "@lodestar/config";
import {phase0, allForks, Slot, Root, ssz, RootHex, deneb} from "@lodestar/types";
import {
phase0,
allForks,
Slot,
Root,
ssz,
RootHex,
deneb,
isSignedBlockContents,
isSignedBlindedBlockContents,
} from "@lodestar/types";

import {
RoutesData,
Expand All @@ -21,12 +31,8 @@ import {HttpStatusCode} from "../../../utils/client/httpStatusCode.js";
import {parseAcceptHeader, writeAcceptHeader} from "../../../utils/acceptHeader.js";
import {ApiClientResponse, ResponseFormat} from "../../../interfaces.js";
import {
SignedBlockContents,
SignedBlindedBlockContents,
isSignedBlockContents,
isSignedBlindedBlockContents,
AllForksSignedBlockContentsReqSerializer,
AllForksSignedBlindedBlockContentsReqSerializer,
allForksSignedBlockContentsReqSerializer,
allForksSignedBlindedBlockContentsReqSerializer,
} from "../../../utils/routes.js";

// See /packages/api/src/routes/index.ts for reasoning and instructions to add new routes
Expand Down Expand Up @@ -175,7 +181,7 @@ export type Api = {
* @param requestBody The `SignedBeaconBlock` object composed of `BeaconBlock` object (produced by beacon node) and validator signature.
* @returns any The block was validated successfully and has been broadcast. It has also been integrated into the beacon node's database.
*/
publishBlock(blockOrContents: allForks.SignedBeaconBlock | SignedBlockContents): Promise<
publishBlock(blockOrContents: allForks.SignedBeaconBlockOrContents): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: void;
Expand All @@ -186,7 +192,7 @@ export type Api = {
>;

publishBlockV2(
blockOrContents: allForks.SignedBeaconBlock | SignedBlockContents,
blockOrContents: allForks.SignedBeaconBlockOrContents,
opts: {broadcastValidation?: BroadcastValidation}
): Promise<
ApiClientResponse<
Expand All @@ -202,7 +208,7 @@ export type Api = {
* Publish a signed blinded block by submitting it to the mev relay and patching in the block
* transactions beacon node gets in response.
*/
publishBlindedBlock(blindedBlockOrContents: allForks.SignedBlindedBeaconBlock | SignedBlindedBlockContents): Promise<
publishBlindedBlock(blindedBlockOrContents: allForks.SignedBlindedBeaconBlockOrContents): Promise<
ApiClientResponse<
{
[HttpStatusCode.OK]: void;
Expand All @@ -213,7 +219,7 @@ export type Api = {
>;

publishBlindedBlockV2(
blindedBlockOrContents: allForks.SignedBlindedBeaconBlock | SignedBlindedBlockContents,
blindedBlockOrContents: allForks.SignedBlindedBeaconBlockOrContents,
opts: {broadcastValidation?: BroadcastValidation}
): Promise<
ApiClientResponse<
Expand Down Expand Up @@ -293,15 +299,15 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
const getSignedBeaconBlockType = (data: allForks.SignedBeaconBlock): allForks.AllForksSSZTypes["SignedBeaconBlock"] =>
config.getForkTypes(data.message.slot).SignedBeaconBlock;

const AllForksSignedBlockOrContents: TypeJson<allForks.SignedBeaconBlock | SignedBlockContents> = {
const AllForksSignedBlockOrContents: TypeJson<allForks.SignedBeaconBlockOrContents> = {
toJson: (data) =>
isSignedBlockContents(data)
? AllForksSignedBlockContentsReqSerializer(getSignedBeaconBlockType).toJson(data)
? allForksSignedBlockContentsReqSerializer(getSignedBeaconBlockType).toJson(data)
: getSignedBeaconBlockType(data).toJson(data),

fromJson: (data) =>
(data as {signed_block: unknown}).signed_block !== undefined
? AllForksSignedBlockContentsReqSerializer(getSignedBeaconBlockType).fromJson(data)
? allForksSignedBlockContentsReqSerializer(getSignedBeaconBlockType).fromJson(data)
: getSignedBeaconBlockType(data as allForks.SignedBeaconBlock).fromJson(data),
};

Expand All @@ -310,18 +316,17 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
): allForks.AllForksBlindedSSZTypes["SignedBeaconBlock"] =>
config.getBlindedForkTypes(data.message.slot).SignedBeaconBlock;

const AllForksSignedBlindedBlockOrContents: TypeJson<allForks.SignedBlindedBeaconBlock | SignedBlindedBlockContents> =
{
toJson: (data) =>
isSignedBlindedBlockContents(data)
? AllForksSignedBlindedBlockContentsReqSerializer(getSignedBlindedBeaconBlockType).toJson(data)
: getSignedBlindedBeaconBlockType(data).toJson(data),

fromJson: (data) =>
(data as {signed_blinded_block: unknown}).signed_blinded_block !== undefined
? AllForksSignedBlindedBlockContentsReqSerializer(getSignedBlindedBeaconBlockType).fromJson(data)
: getSignedBlindedBeaconBlockType(data as allForks.SignedBlindedBeaconBlock).fromJson(data),
};
const AllForksSignedBlindedBlockOrContents: TypeJson<allForks.SignedBlindedBeaconBlockOrContents> = {
toJson: (data) =>
isSignedBlindedBlockContents(data)
? allForksSignedBlindedBlockContentsReqSerializer(getSignedBlindedBeaconBlockType).toJson(data)
: getSignedBlindedBeaconBlockType(data).toJson(data),

fromJson: (data) =>
(data as {signed_blinded_block: unknown}).signed_blinded_block !== undefined
? allForksSignedBlindedBlockContentsReqSerializer(getSignedBlindedBeaconBlockType).fromJson(data)
: getSignedBlindedBeaconBlockType(data as allForks.SignedBlindedBeaconBlock).fromJson(data),
};

return {
getBlock: getBlockReq,
Expand Down
Loading

0 comments on commit 676e315

Please sign in to comment.