Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement EIP-7691 increase blob throughput #7309

Merged
merged 23 commits into from
Jan 9, 2025
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
21 changes: 15 additions & 6 deletions packages/beacon-node/src/chain/validation/blobSidecar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {ChainConfig} from "@lodestar/config";
import {KZG_COMMITMENT_INCLUSION_PROOF_DEPTH, KZG_COMMITMENT_SUBTREE_INDEX0} from "@lodestar/params";
import {
ForkName,
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH,
KZG_COMMITMENT_SUBTREE_INDEX0,
isForkPostElectra,
} from "@lodestar/params";
import {computeStartSlotAtEpoch, getBlockHeaderProposerSignatureSet} from "@lodestar/state-transition";
import {BlobIndex, Root, Slot, deneb, ssz} from "@lodestar/types";
import {toRootHex, verifyMerkleBranch} from "@lodestar/utils";
Expand All @@ -12,23 +17,25 @@ import {IBeaconChain} from "../interface.js";
import {RegenCaller} from "../regen/index.js";

export async function validateGossipBlobSidecar(
fork: ForkName,
chain: IBeaconChain,
blobSidecar: deneb.BlobSidecar,
subnet: number
): Promise<void> {
const blobSlot = blobSidecar.signedBlockHeader.message.slot;

// [REJECT] The sidecar's index is consistent with `MAX_BLOBS_PER_BLOCK` -- i.e. `blob_sidecar.index < MAX_BLOBS_PER_BLOCK`.
if (blobSidecar.index >= chain.config.MAX_BLOBS_PER_BLOCK) {
const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(fork);
if (blobSidecar.index >= maxBlobsPerBlock) {
throw new BlobSidecarGossipError(GossipAction.REJECT, {
code: BlobSidecarErrorCode.INDEX_TOO_LARGE,
blobIdx: blobSidecar.index,
maxBlobsPerBlock: chain.config.MAX_BLOBS_PER_BLOCK,
maxBlobsPerBlock,
});
}

// [REJECT] The sidecar is for the correct subnet -- i.e. `compute_subnet_for_blob_sidecar(sidecar.index) == subnet_id`.
if (computeSubnetForBlobSidecar(blobSidecar.index, chain.config) !== subnet) {
if (computeSubnetForBlobSidecar(fork, chain.config, blobSidecar.index) !== subnet) {
throw new BlobSidecarGossipError(GossipAction.REJECT, {
code: BlobSidecarErrorCode.INVALID_INDEX,
blobIdx: blobSidecar.index,
Expand Down Expand Up @@ -236,6 +243,8 @@ function validateInclusionProof(blobSidecar: deneb.BlobSidecar): boolean {
);
}

function computeSubnetForBlobSidecar(blobIndex: BlobIndex, config: ChainConfig): number {
return blobIndex % config.BLOB_SIDECAR_SUBNET_COUNT;
function computeSubnetForBlobSidecar(fork: ForkName, config: ChainConfig, blobIndex: BlobIndex): number {
return (
blobIndex % (isForkPostElectra(fork) ? config.BLOB_SIDECAR_SUBNET_COUNT_ELECTRA : config.BLOB_SIDECAR_SUBNET_COUNT)
);
}
5 changes: 3 additions & 2 deletions packages/beacon-node/src/chain/validation/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ export async function validateGossipBlock(
// [REJECT] The length of KZG commitments is less than or equal to the limitation defined in Consensus Layer -- i.e. validate that len(body.signed_beacon_block.message.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
if (isForkBlobs(fork)) {
const blobKzgCommitmentsLen = (block as deneb.BeaconBlock).body.blobKzgCommitments.length;
if (blobKzgCommitmentsLen > chain.config.MAX_BLOBS_PER_BLOCK) {
const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(fork);
if (blobKzgCommitmentsLen > maxBlobsPerBlock) {
throw new BlockGossipError(GossipAction.REJECT, {
code: BlockErrorCode.TOO_MANY_KZG_COMMITMENTS,
blobKzgCommitmentsLen,
commitmentLimit: chain.config.MAX_BLOBS_PER_BLOCK,
commitmentLimit: maxBlobsPerBlock,
});
}
}
Expand Down
6 changes: 5 additions & 1 deletion packages/beacon-node/src/network/gossip/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ export function getCoreTopicsAtFork(

// After Deneb also track blob_sidecar_{subnet_id}
if (ForkSeq[fork] >= ForkSeq.deneb) {
for (let subnet = 0; subnet < config.BLOB_SIDECAR_SUBNET_COUNT; subnet++) {
const subnetCount = isForkPostElectra(fork)
? config.BLOB_SIDECAR_SUBNET_COUNT_ELECTRA
: config.BLOB_SIDECAR_SUBNET_COUNT;

for (let subnet = 0; subnet < subnetCount; subnet++) {
topics.push({type: GossipType.blob_sidecar, subnet});
}
}
Expand Down
23 changes: 18 additions & 5 deletions packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {PeerId} from "@libp2p/interface";
import {routes} from "@lodestar/api";
import {BeaconConfig} from "@lodestar/config";
import {LoggerNode} from "@lodestar/logger/node";
import {ForkSeq} from "@lodestar/params";
import {ForkSeq, isForkPostElectra} from "@lodestar/params";
import {ResponseIncoming} from "@lodestar/reqresp";
import {computeStartSlotAtEpoch, computeTimeAtSlot} from "@lodestar/state-transition";
import {
Expand Down Expand Up @@ -501,17 +501,29 @@ export class Network implements INetwork {
peerId: PeerIdStr,
request: deneb.BlobSidecarsByRangeRequest
): Promise<deneb.BlobSidecar[]> {
const fork = this.config.getForkName(request.startSlot);
return collectMaxResponseTyped(
this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRange, [Version.V1], request),
this.sendReqRespRequest(
peerId,
ReqRespMethod.BlobSidecarsByRange,
[isForkPostElectra(fork) ? Version.V2 : Version.V1],
request
),
// request's count represent the slots, so the actual max count received could be slots * blobs per slot
request.count * this.config.MAX_BLOBS_PER_BLOCK,
request.count * this.config.getMaxBlobsPerBlock(fork),
responseSszTypeByMethod[ReqRespMethod.BlobSidecarsByRange]
);
}

async sendBlobSidecarsByRoot(peerId: PeerIdStr, request: BlobSidecarsByRootRequest): Promise<deneb.BlobSidecar[]> {
const fork = this.config.getForkName(this.clock.currentSlot);
return collectMaxResponseTyped(
this.sendReqRespRequest(peerId, ReqRespMethod.BlobSidecarsByRoot, [Version.V1], request),
this.sendReqRespRequest(
peerId,
ReqRespMethod.BlobSidecarsByRoot,
[isForkPostElectra(fork) ? Version.V2 : Version.V1],
Copy link
Contributor

Choose a reason for hiding this comment

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

whats different in v2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Max size of the param in V1 is MAX_REQUEST_BLOB_SIDECARS(768) , V2 is MAX_REQUEST_BLOB_SIDECARS_ELECTRA(1152)

Copy link
Member

Choose a reason for hiding this comment

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

there is some discussion around this on discord, we might get rid of v2 again in a future spec release

request
),
request.length,
responseSszTypeByMethod[ReqRespMethod.BlobSidecarsByRoot]
);
Expand All @@ -523,7 +535,8 @@ export class Network implements INetwork {
versions: number[],
request: Req
): AsyncIterable<ResponseIncoming> {
const requestType = requestSszTypeByMethod(this.config)[method];
const fork = this.config.getForkName(this.clock.currentSlot);
const requestType = requestSszTypeByMethod(this.config, fork)[method];
const requestData = requestType ? requestType.serialize(request as never) : new Uint8Array();

// ReqResp outgoing request, emit from main thread to worker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
): Promise<BlockInput | NullBlockInput> {
const blobBlockHeader = blobSidecar.signedBlockHeader.message;
const slot = blobBlockHeader.slot;
const fork = config.getForkName(slot);
const blockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blobBlockHeader);
const blockHex = prettyBytes(blockRoot);

Expand All @@ -203,7 +204,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
);

try {
await validateGossipBlobSidecar(chain, blobSidecar, subnet);
await validateGossipBlobSidecar(fork, chain, blobSidecar, subnet);
const recvToValidation = Date.now() / 1000 - seenTimestampSec;
const validationTime = recvToValidation - recvToValLatency;

Expand Down
11 changes: 10 additions & 1 deletion packages/beacon-node/src/network/reqresp/ReqRespBeaconNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ export class ReqRespBeaconNode extends ReqResp {
versions: number[],
request: Req
): AsyncIterable<ResponseIncoming> {
const requestType = requestSszTypeByMethod(this.config)[method];
const fork = ForkName[ForkSeq[this.currentRegisteredFork] as ForkName];
const requestType = requestSszTypeByMethod(this.config, fork)[method];
Copy link
Contributor

@g11tech g11tech Dec 20, 2024

Choose a reason for hiding this comment

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

we need this for v1/v2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, request type for BlobSidecarsByRootV2 has changed. But ReqRespMethod does not communicate version info, so we can only pass in fork info to determine the correct type.

const requestData = requestType ? requestType.serialize(request as never) : new Uint8Array();
return this.sendRequestWithoutEncoding(peerId, method, versions, requestData);
}
Expand Down Expand Up @@ -251,12 +252,20 @@ export class ReqRespBeaconNode extends ReqResp {
}

if (ForkSeq[fork] >= ForkSeq.deneb) {
// TODO Electra: Consider deprecating BlobSidecarsByRootV1 and BlobSidecarsByRangeV1 at fork boundary or after Electra is stable
protocolsAtFork.push(
[protocols.BlobSidecarsByRoot(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRoot)],
[protocols.BlobSidecarsByRange(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRange)]
);
}

if (ForkSeq[fork] >= ForkSeq.electra) {
protocolsAtFork.push(
[protocols.BlobSidecarsByRootV2(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRoot)],
[protocols.BlobSidecarsByRangeV2(this.config), this.getHandler(ReqRespMethod.BlobSidecarsByRange)]
);
}

return protocolsAtFork;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export function validateBeaconBlocksByRangeRequest(
// step > 1 is deprecated, see https://github.com/ethereum/consensus-specs/pull/2856

if (count > MAX_REQUEST_BLOCKS) {
// TODO: This is probably not right as `BeaconBlocksByRangeV2` takes at most `MAX_REQUEST_BLOCKS_DENEB`
count = MAX_REQUEST_BLOCKS;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/beacon-node/src/network/reqresp/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {ForkName} from "@lodestar/params";
import {ProtocolHandler} from "@lodestar/reqresp";
import {ssz} from "@lodestar/types";
import {IBeaconChain} from "../../../chain/index.js";
import {IBeaconDb} from "../../../db/index.js";
import {BlobSidecarsByRootRequestType} from "../../../util/types.js";
import {GetReqRespHandlerFn, ReqRespMethod} from "../types.js";
import {GetReqRespHandlerFn, ReqRespMethod, Version} from "../types.js";
import {onBeaconBlocksByRange} from "./beaconBlocksByRange.js";
import {onBeaconBlocksByRoot} from "./beaconBlocksByRoot.js";
import {onBlobSidecarsByRange} from "./blobSidecarsByRange.js";
Expand Down Expand Up @@ -38,7 +39,8 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
return onBeaconBlocksByRoot(body, chain, db);
},
[ReqRespMethod.BlobSidecarsByRoot]: (req) => {
const body = BlobSidecarsByRootRequestType(chain.config).deserialize(req.data);
const fork = req.version === Version.V2 ? ForkName.electra : ForkName.deneb;
const body = BlobSidecarsByRootRequestType(fork, chain.config).deserialize(req.data);
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't type be the same just that v2 will have context bytes/fork type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

V2 accepts higher number of blob requests so the ssz container is different.

return onBlobSidecarsByRoot(body, chain, db);
},
[ReqRespMethod.BlobSidecarsByRange]: (req) => {
Expand Down
12 changes: 12 additions & 0 deletions packages/beacon-node/src/network/reqresp/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,24 @@ export const BlobSidecarsByRange = toProtocol({
contextBytesType: ContextBytesType.ForkDigest,
});

export const BlobSidecarsByRangeV2 = toProtocol({
method: ReqRespMethod.BlobSidecarsByRange,
version: Version.V2,
contextBytesType: ContextBytesType.ForkDigest,
});

export const BlobSidecarsByRoot = toProtocol({
method: ReqRespMethod.BlobSidecarsByRoot,
version: Version.V1,
contextBytesType: ContextBytesType.ForkDigest,
});

export const BlobSidecarsByRootV2 = toProtocol({
method: ReqRespMethod.BlobSidecarsByRoot,
version: Version.V2,
contextBytesType: ContextBytesType.ForkDigest,
});

export const LightClientBootstrap = toProtocol({
method: ReqRespMethod.LightClientBootstrap,
version: Version.V1,
Expand Down
2 changes: 2 additions & 0 deletions packages/beacon-node/src/network/reqresp/rateLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ export const rateLimitQuotas: (config: ChainConfig) => Record<ReqRespMethod, Inb
},
[ReqRespMethod.BlobSidecarsByRange]: {
// Rationale: MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
// TODO Electra: Stays as `MAX_REQUEST_BLOB_SIDECARS` until we have fork-aware `byPeer` and set it to `MAX_REQUEST_BLOB_SIDECARS_ELECTRA`
byPeer: {quota: config.MAX_REQUEST_BLOB_SIDECARS, quotaTimeMs: 10_000},
getRequestCount: getRequestCountFn(config, ReqRespMethod.BlobSidecarsByRange, (req) => req.count),
},
[ReqRespMethod.BlobSidecarsByRoot]: {
// Rationale: quota of BeaconBlocksByRoot * MAX_BLOBS_PER_BLOCK
// TODO Electra: Stays as `MAX_REQUEST_BLOB_SIDECARS` until we have fork-aware `byPeer` and set it to `MAX_REQUEST_BLOB_SIDECARS_ELECTRA`
byPeer: {quota: config.MAX_REQUEST_BLOB_SIDECARS, quotaTimeMs: 10_000},
getRequestCount: getRequestCountFn(config, ReqRespMethod.BlobSidecarsByRoot, (req) => req.length),
},
Expand Down
10 changes: 7 additions & 3 deletions packages/beacon-node/src/network/reqresp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,21 @@ type ResponseBodyByMethod = {
};

/** Request SSZ type for each method and ForkName */
export const requestSszTypeByMethod: (config: ChainConfig) => {
// TODO Electra: Currently setting default fork to deneb because not every caller of requestSszTypeByMethod can provide fork info
export const requestSszTypeByMethod: (
config: ChainConfig,
fork?: ForkName
) => {
[K in ReqRespMethod]: RequestBodyByMethod[K] extends null ? null : Type<RequestBodyByMethod[K]>;
} = (config) => ({
} = (config, fork = ForkName.deneb) => ({
[ReqRespMethod.Status]: ssz.phase0.Status,
[ReqRespMethod.Goodbye]: ssz.phase0.Goodbye,
[ReqRespMethod.Ping]: ssz.phase0.Ping,
[ReqRespMethod.Metadata]: null,
[ReqRespMethod.BeaconBlocksByRange]: ssz.phase0.BeaconBlocksByRangeRequest,
[ReqRespMethod.BeaconBlocksByRoot]: ssz.phase0.BeaconBlocksByRootRequest,
[ReqRespMethod.BlobSidecarsByRange]: ssz.deneb.BlobSidecarsByRangeRequest,
[ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequestType(config),
[ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequestType(fork, config),
[ReqRespMethod.LightClientBootstrap]: ssz.Root,
[ReqRespMethod.LightClientUpdatesByRange]: ssz.altair.LightClientUpdatesByRange,
[ReqRespMethod.LightClientFinalityUpdate]: null,
Expand Down
8 changes: 6 additions & 2 deletions packages/beacon-node/src/util/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ContainerType, ListCompositeType, ValueOf} from "@chainsafe/ssz";
import {ChainConfig} from "@lodestar/config";
import {ForkName, isForkPostElectra} from "@lodestar/params";
import {ssz} from "@lodestar/types";

// Misc SSZ types used only in the beacon-node package, no need to upstream to types
Expand All @@ -14,6 +15,9 @@ export const signedBLSToExecutionChangeVersionedType = new ContainerType(
);
export type SignedBLSToExecutionChangeVersioned = ValueOf<typeof signedBLSToExecutionChangeVersionedType>;

export const BlobSidecarsByRootRequestType = (config: ChainConfig) =>
new ListCompositeType(ssz.deneb.BlobIdentifier, config.MAX_REQUEST_BLOB_SIDECARS);
export const BlobSidecarsByRootRequestType = (fork: ForkName, config: ChainConfig) =>
new ListCompositeType(
ssz.deneb.BlobIdentifier,
isForkPostElectra(fork) ? config.MAX_REQUEST_BLOB_SIDECARS_ELECTRA : config.MAX_REQUEST_BLOB_SIDECARS
);
export type BlobSidecarsByRootRequest = ValueOf<ReturnType<typeof BlobSidecarsByRootRequestType>>;
3 changes: 2 additions & 1 deletion packages/beacon-node/test/unit/util/kzg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe("C-KZG", () => {
afterEachCallbacks.push(() => chain.close());

const slot = 0;
const fork = config.getForkName(slot);
const blobs = [generateRandomBlob(), generateRandomBlob()];
const kzgCommitments = blobs.map((blob) => ckzg.blobToKzgCommitment(blob));

Expand All @@ -65,7 +66,7 @@ describe("C-KZG", () => {

for (const blobSidecar of blobSidecars) {
try {
await validateGossipBlobSidecar(chain, blobSidecar, blobSidecar.index);
await validateGossipBlobSidecar(fork, chain, blobSidecar, blobSidecar.index);
} catch (_e) {
// We expect some error from here
// console.log(error);
Expand Down
6 changes: 5 additions & 1 deletion packages/config/src/chainConfig/configs/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export const chainConfig: ChainConfig = {
// Electra
// 2**8 * 10**9 (= 256,000,000,000)
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000,
// 2*7 * 10**9 (= 128,000,000,000)
// 2**7 * 10**9 (= 128,000,000,000)
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000,
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9,
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,
};
4 changes: 4 additions & 0 deletions packages/config/src/chainConfig/configs/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,8 @@ export const chainConfig: ChainConfig = {
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 128000000000,
// 2**6 * 10**9 (= 64,000,000,000)
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 64000000000,
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9,
MAX_BLOBS_PER_BLOCK_ELECTRA: 9,
// MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152,
};
6 changes: 6 additions & 0 deletions packages/config/src/chainConfig/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export type ChainConfig = {
BLOB_SIDECAR_SUBNET_COUNT: number;
MAX_BLOBS_PER_BLOCK: number;
MAX_REQUEST_BLOB_SIDECARS: number;
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: number;
MAX_BLOBS_PER_BLOCK_ELECTRA: number;
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: number;
};

export const chainConfigTypes: SpecTypes<ChainConfig> = {
Expand Down Expand Up @@ -142,6 +145,9 @@ export const chainConfigTypes: SpecTypes<ChainConfig> = {
BLOB_SIDECAR_SUBNET_COUNT: "number",
MAX_BLOBS_PER_BLOCK: "number",
MAX_REQUEST_BLOB_SIDECARS: "number",
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: "number",
MAX_BLOBS_PER_BLOCK_ELECTRA: "number",
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: "number",
};

/** Allows values in a Spec file */
Expand Down
4 changes: 4 additions & 0 deletions packages/config/src/forkConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
isForkBlobs,
isForkExecution,
isForkLightClient,
isForkPostElectra,
} from "@lodestar/params";
import {Epoch, SSZTypesFor, Slot, Version, sszTypesFor} from "@lodestar/types";
import {ChainConfig} from "../chainConfig/index.js";
Expand Down Expand Up @@ -129,5 +130,8 @@ export function createForkConfig(config: ChainConfig): ForkConfig {
}
return sszTypesFor(forkName);
},
getMaxBlobsPerBlock(fork: ForkName): number {
return isForkPostElectra(fork) ? config.MAX_BLOBS_PER_BLOCK_ELECTRA : config.MAX_BLOBS_PER_BLOCK;
},
};
}
2 changes: 2 additions & 0 deletions packages/config/src/forkConfig/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ export type ForkConfig = {
getExecutionForkTypes(slot: Slot): SSZTypesFor<ForkExecution>;
/** Get blobs SSZ types by hard-fork*/
getBlobsForkTypes(slot: Slot): SSZTypesFor<ForkBlobs>;
/** Get max blobs per block by hard-fork */
getMaxBlobsPerBlock(fork: ForkName): number;
};
4 changes: 2 additions & 2 deletions packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ export const BLOB_TX_TYPE = 0x03;
export const VERSIONED_HASH_VERSION_KZG = 0x01;

// ssz.deneb.BeaconBlockBody.getPathInfo(['blobKzgCommitments',0]).gindex
export const KZG_COMMITMENT_GINDEX0 = ACTIVE_PRESET === PresetName.minimal ? 864 : 221184;
export const KZG_COMMITMENT_GINDEX0 = ACTIVE_PRESET === PresetName.minimal ? 1728 : 221184;
ensi321 marked this conversation as resolved.
Show resolved Hide resolved
export const KZG_COMMITMENT_SUBTREE_INDEX0 = KZG_COMMITMENT_GINDEX0 - 2 ** KZG_COMMITMENT_INCLUSION_PROOF_DEPTH;

// ssz.deneb.BlobSidecars.elementType.fixedSize
export const BLOBSIDECAR_FIXED_SIZE = ACTIVE_PRESET === PresetName.minimal ? 131672 : 131928;
export const BLOBSIDECAR_FIXED_SIZE = ACTIVE_PRESET === PresetName.minimal ? 131704 : 131928;

// Electra Misc
export const UNSET_DEPOSIT_REQUESTS_START_INDEX = 2n ** 64n - 1n;
Expand Down
4 changes: 2 additions & 2 deletions packages/params/src/presets/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export const minimalPreset: BeaconPreset = {
// DENEB
///////////
FIELD_ELEMENTS_PER_BLOB: 4096,
MAX_BLOB_COMMITMENTS_PER_BLOCK: 16,
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 9,
MAX_BLOB_COMMITMENTS_PER_BLOCK: 32,
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 10,
Copy link
Member

@nflaig nflaig Jan 8, 2025

Choose a reason for hiding this comment

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

It looks like there is a consensus issue with Lighthouse in our sim tests due to this, need to use a image with the updated minimal preset values. Should not be a blocker to merge this but should figure out a solution (ie. updating LH image) before we merge the devnet-5 branch to unstable


// ELECTRA
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD: 4,
Expand Down
Loading
Loading