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

Open
wants to merge 20 commits into
base: devnet-5
Choose a base branch
from

Conversation

ensi321
Copy link
Contributor

@ensi321 ensi321 commented Dec 17, 2024

Implement EIP-7691.

Outstanding items that is not covered in this PR:

  • Make callers of requestSszTypeByMethod to provide fork info
  • Make InboundRateLimitQuota fork-aware so byPeer limit can be correctly set for BlobSidecarsByRange and BlobSidecarsByRoot.
  • Make ReqRespRateLimiter to re-set the rate limit on fork activation

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 43.95604% with 51 lines in your changes missing coverage. Please review.

Project coverage is 48.60%. Comparing base (4b8de08) to head (760fbb8).

Additional details and impacted files
@@             Coverage Diff              @@
##           devnet-5    #7309      +/-   ##
============================================
- Coverage     48.61%   48.60%   -0.01%     
============================================
  Files           603      604       +1     
  Lines         40457    40516      +59     
  Branches       2065     2065              
============================================
+ Hits          19667    19694      +27     
- Misses        20752    20784      +32     
  Partials         38       38              

@ensi321 ensi321 marked this pull request as ready for review December 18, 2024 23:07
@ensi321 ensi321 requested a review from a team as a code owner December 18, 2024 23:07
@ensi321
Copy link
Contributor Author

ensi321 commented Dec 18, 2024

Please ignore E2E Tests and spec tests as they will be addressed in the next PR.

@@ -501,17 +501,30 @@ export class Network implements INetwork {
peerId: PeerIdStr,
request: deneb.BlobSidecarsByRangeRequest
): Promise<deneb.BlobSidecar[]> {
const fork = this.config.getForkName(this.clock.currentSlot);
Copy link
Member

Choose a reason for hiding this comment

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

need to check if it's correct to use clock slot here, what if we range sync and wanna get deneb blob sidecars but clock slot is already electra?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I think we should use request.startSlot here. And if the request start slot is in deneb but the end slot is in electra, we still want to send out V1.

): 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 = isForkPostElectra(fork)
Copy link
Member

Choose a reason for hiding this comment

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

Assigning maxBlobsPerBlock is done in multiple places, we could think about adding a helper for that as there will be likely more values in the future since we intend to bump the blob count further (likely in the next hard fork)

Maybe something similar to what the CL spec uses in their tests get_max_blob_count

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added constantsHelper.ts for the purpose of reducing number of conditional assignments in the codebase.

Can expand the scope of constantsHelper to outside of blobs in another PR

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if those could just be part of ChainForkConfig, like config.getForkName() and only take in the fork

Copy link
Member

Choose a reason for hiding this comment

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

return isForkPostElectra(fork) ? config.MAX_BLOBS_PER_BLOCK_ELECTRA : config.MAX_BLOBS_PER_BLOCK;
}

export function getBlobSidecarSubnetCount(fork: ForkName, config: ChainConfig): number {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't really used much compared to max blob per blob, also will likely go away with peerdas, might get away with not adding a helper

Copy link
Member

Choose a reason for hiding this comment

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

I removed this in my PR #7322 as it's already pretty encapsulated where it is used

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?

@@ -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 keyof typeof 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?

@@ -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?

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

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

this changed for electra or was the value incorrect? then gindex0 constant needs to be forkaware

Copy link
Member

Choose a reason for hiding this comment

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

in the spec PR the minimal preset values for deneb were changed here, I thought you have to add new constants for that but apparently not

but agree the gindex should be fork aware

Copy link
Contributor

Choose a reason for hiding this comment

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

then this will break the current deneb minimal devnets

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh because we retrospectively changed deneb max vals, sounds very random to me to do (in spec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants