-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support for different blob target and max values #14678
Conversation
33bafb6
to
d70c358
Compare
837eb16
to
68d9ce7
Compare
3d81330
to
4599ebd
Compare
api/client/builder/types.go
Outdated
@@ -1008,12 +1009,13 @@ func (ehr *ExecHeaderResponseDeneb) ToProto() (*eth.SignedBuilderBidDeneb, error | |||
} | |||
|
|||
// ToProto creates a BuilderBidDeneb Proto from BuilderBidDeneb. | |||
func (bb *BuilderBidDeneb) ToProto() (*eth.BuilderBidDeneb, error) { | |||
func (bb *BuilderBidDeneb) ToProto(s types.Slot) (*eth.BuilderBidDeneb, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not have this be the max blob count instead of the slot? That would be a better abstraction since this method doesn't actually care about the slot, it only needs it to derive the max blob count
config/params/config.go
Outdated
MaxBlobsPerBlock int `yaml:"MAX_BLOBS_PER_BLOCK" spec:"true"` // MaxBlobsPerBlock defines the max blobs could exist in a block. | ||
MaxBlobsPerBlockElectra int `yaml:"MAX_BLOBS_PER_BLOCK_ELECTRA" spec:"true"` // MaxBlobsPerBlockElectra defines the max blobs could exist in a block post Electra hard fork. | ||
TargetBlobsPerBlockElectra int `yaml:"TARGET_BLOBS_PER_BLOCK_ELECTRA" spec:"true"` // TargetBlobsPerBlockElectra defines the target number of blobs per block post Electra hard fork. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it an int when everything else is uint64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config/params/config.go
Outdated
@@ -280,6 +280,11 @@ type BeaconChainConfig struct { | |||
AttestationSubnetPrefixBits uint64 `yaml:"ATTESTATION_SUBNET_PREFIX_BITS" spec:"true"` // AttestationSubnetPrefixBits is defined as (ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS). | |||
SubnetsPerNode uint64 `yaml:"SUBNETS_PER_NODE" spec:"true"` // SubnetsPerNode is the number of long-lived subnets a beacon node should be subscribed to. | |||
NodeIdBits uint64 `yaml:"NODE_ID_BITS" spec:"true"` // NodeIdBits defines the bit length of a node id. | |||
|
|||
// Blobs Values | |||
MaxBlobsPerBlock int `yaml:"MAX_BLOBS_PER_BLOCK" spec:"true"` // MaxBlobsPerBlock defines the max blobs could exist in a block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having this as a public config value is going to be a potential footgun or lead to misuse. Is there a way that this can only be accessed via the helper method? If there is a single place in the production codepath that is using params.BeaconConfig().MaxBlobsPerBlock
instead of params.BeaconConfig().MaxBlobCount(slot)
then it's going to be a nasty bug at the fork.
8e83e77
to
8e2b3eb
Compare
8e2b3eb
to
a76b72c
Compare
CHANGELOG.md
Outdated
@@ -78,6 +78,7 @@ Notable features: | |||
- Save light client updates and bootstraps in DB. | |||
- Added more comprehensive tests for `BlockToLightClientHeader`. [PR](https://github.com/prysmaticlabs/prysm/pull/14699) | |||
- Added light client feature flag check to RPC handlers. [PR](https://github.com/prysmaticlabs/prysm/pull/14736) | |||
- Added support to update target and max blob count to different values per hard fork config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong section
@@ -166,7 +171,7 @@ func NewService(ctx context.Context, opts ...Option) (*Service, error) { | |||
ctx, cancel := context.WithCancel(ctx) | |||
bn := &blobNotifierMap{ | |||
notifiers: make(map[[32]byte]chan uint64), | |||
seenIndex: make(map[[32]byte][fieldparams.MaxBlobsPerBlock]bool), | |||
seenIndex: make(map[[32]byte][]bool), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably a micro optimization that can be in another PR, but a bitfield is cheaper on memory.
This PR adds support for potential new blob target and max values (based on hard forks) in the configuration, with updates applied throughout the codebase. The detailed change list is provided below.
Config
fieldparams
package'sMaxBlobsPerBlock
for mainnet and minimal configurations.DeprecatedMaxBlobsPerBlock
to theconfig
package which is mainly used for import through yamlMaxBlobsPerBlock
andTargetBlobsPerBlock
that determine the appropriate blob count for a given slot based on the active fork.Proposer Requesting Header from Relayer
ToProto()
toToProto(Slot)
for the proposergetHeader
response to the relayer endpoint. The proposer passes the slot, andToProto
ensures the builder's bid's KZG commitment does not exceedMaxBlobsPerBlock
for the current slot.Blockchain Package Checking DA
slot
tomissingIndices
for calculatingMaxBlobsPerBlock
as a safety check ensuring KZG commitments in the beacon block body do not exceed the limit.forRoot
inblobNotifierMap
to useslot
for constructing the correct number of channels (MaxBlobsPerBlock
). This manages theNotifyIndex
listener.Sync Notify New Blob to Blockchain Package
slot
tosendBlobEvent
innotifyIndex
to construct the correct size for theseen
map and downstream notifier channel.State Transition Process for New Payload
slot
toverifyBlobCommitmentCount
to ensure KZG commitments do not exceed theMaxBlobsPerBlock
limit. This is part of the state transition check, using thestate.slot
before processing the payload to match the block slot.DAS Cache
safeCommitmentArray
as it assumed a fixedMaxBlobsPerBlock
.filter
,stash
, andcommitmentsToCheck
:commitmentsToCheck
still ensures KZG commitments in the block do not exceed the max blob count.stash
now handles cases wheree.scs
is nil, which was previously unsupported.Blob Storage
slot
to indices forMaxBlobsPerBlock
checks and for constructing themask
object.blobIndexMask
to a slice instead of an array.hasIndex
andAllAvailable
to include additional checks ensuring indices do not exceed the length of the mask.v.mask
is nil, a newblobIndexMask
is constructed.Beacon API RPC
MaxBlobsPerBlock
based on Electra fork configurations.beacon-chain/rpc/lookup/blocker.go
.Proposer
MaxBlobsPerBlock
is used when fetching payload headers from the builder. This check is duplicated but not removed in this PR.Initial Sync - Backfill
blobVerifierMap
to use a slice ofBlobVerifier
instead of a hardcoded length.Sync - RPC
slot
toconstructPendingBlobsRequest
for database index validation.slot
toblobBatchLimit
for constructing the correct block batch limit.SendBlobSidecarByRoot
to verify that the blob sidecars in the response do not exceedMaxBlobsPerBlock
.Sync - Subscribe
slot
to all usages of database index changes.