@@ -238,32 +238,44 @@ type BeaconBody struct {
238238}
239239
240240func NewBeaconBody (beaconCfg * clparams.BeaconChainConfig , version clparams.StateVersion ) * BeaconBody {
241- var (
242- executionRequests * ExecutionRequests
243- maxAttSlashing = MaxAttesterSlashings
244- maxAttestation = MaxAttestations
245- )
246- if version .AfterOrEqual (clparams .ElectraVersion ) {
247- // upgrade to electra
241+ maxAttSlashing := MaxAttesterSlashings
242+ maxAttestation := MaxAttestations
243+ if version >= clparams .ElectraVersion {
248244 maxAttSlashing = int (beaconCfg .MaxAttesterSlashingsElectra )
249245 maxAttestation = int (beaconCfg .MaxAttestationsElectra )
250- executionRequests = NewExecutionRequests (beaconCfg )
251246 }
252247
253- return & BeaconBody {
254- beaconCfg : beaconCfg ,
255- Eth1Data : & Eth1Data {},
256- ProposerSlashings : solid .NewStaticListSSZ [* ProposerSlashing ](MaxProposerSlashings , 416 ),
257- AttesterSlashings : solid.NewDynamicListSSZ [* AttesterSlashing ](maxAttSlashing ),
258- Attestations : solid.NewDynamicListSSZ [* solid.Attestation ](maxAttestation ),
259- Deposits : solid .NewStaticListSSZ [* Deposit ](MaxDeposits , 1240 ),
260- VoluntaryExits : solid .NewStaticListSSZ [* SignedVoluntaryExit ](MaxVoluntaryExits , 112 ),
261- ExecutionPayload : NewEth1Block (version , beaconCfg ),
262- ExecutionChanges : solid .NewStaticListSSZ [* SignedBLSToExecutionChange ](MaxExecutionChanges , 172 ),
263- BlobKzgCommitments : solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 ),
264- ExecutionRequests : executionRequests ,
265- Version : version ,
248+ body := & BeaconBody {
249+ beaconCfg : beaconCfg ,
250+ Eth1Data : & Eth1Data {},
251+ ProposerSlashings : solid .NewStaticListSSZ [* ProposerSlashing ](MaxProposerSlashings , 416 ),
252+ AttesterSlashings : solid.NewDynamicListSSZ [* AttesterSlashing ](maxAttSlashing ),
253+ Attestations : solid.NewDynamicListSSZ [* solid.Attestation ](maxAttestation ),
254+ Deposits : solid .NewStaticListSSZ [* Deposit ](MaxDeposits , 1240 ),
255+ VoluntaryExits : solid .NewStaticListSSZ [* SignedVoluntaryExit ](MaxVoluntaryExits , 112 ),
256+ ExecutionChanges : solid .NewStaticListSSZ [* SignedBLSToExecutionChange ](MaxExecutionChanges , 172 ),
257+ Version : version ,
258+ }
259+
260+ // [Modified in Gloas:EIP7732] Version-specific fields
261+ if version < clparams .GloasVersion {
262+ // Pre-GLOAS: ExecutionPayload, BlobKzgCommitments in BeaconBody
263+ body .ExecutionPayload = NewEth1Block (version , beaconCfg )
264+ body .BlobKzgCommitments = solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 )
265+ if version >= clparams .ElectraVersion {
266+ body .ExecutionRequests = NewExecutionRequests (beaconCfg )
267+ }
268+ } else {
269+ // GLOAS: SignedExecutionPayloadBid and PayloadAttestations replace above
270+ body .SignedExecutionPayloadBid = & SignedExecutionPayloadBid {
271+ Message : & ExecutionPayloadBid {
272+ BlobKzgCommitments : * solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 ),
273+ },
274+ }
275+ body .PayloadAttestations = solid .NewStaticListSSZ [* PayloadAttestation ](int (beaconCfg .MaxPayloadAttestations ), 0 )
266276 }
277+
278+ return body
267279}
268280
269281func (b * BeaconBody ) EncodeSSZ (dst []byte ) ([]byte , error ) {
@@ -302,35 +314,58 @@ func (b *BeaconBody) EncodingSizeSSZ() (size int) {
302314 if b .VoluntaryExits == nil {
303315 b .VoluntaryExits = solid .NewStaticListSSZ [* SignedVoluntaryExit ](MaxVoluntaryExits , 112 )
304316 }
305- if b .ExecutionPayload == nil {
317+ // [Modified in Gloas:EIP7732] ExecutionPayload removed in GLOAS
318+ if b .ExecutionPayload == nil && b .Version < clparams .GloasVersion {
306319 b .ExecutionPayload = NewEth1Block (b .Version , b .beaconCfg )
307320 }
308321 if b .ExecutionChanges == nil {
309322 b .ExecutionChanges = solid .NewStaticListSSZ [* SignedBLSToExecutionChange ](MaxExecutionChanges , 172 )
310323 }
311- if b .BlobKzgCommitments == nil {
324+ // [Modified in Gloas:EIP7732] BlobKzgCommitments removed in GLOAS
325+ if b .BlobKzgCommitments == nil && b .Version < clparams .GloasVersion {
312326 b .BlobKzgCommitments = solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 )
313327 }
328+ // [New in Gloas:EIP7732] Initialize GLOAS fields if nil
329+ if b .Version >= clparams .GloasVersion {
330+ if b .SignedExecutionPayloadBid == nil {
331+ b .SignedExecutionPayloadBid = & SignedExecutionPayloadBid {
332+ Message : & ExecutionPayloadBid {
333+ BlobKzgCommitments : * solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 ),
334+ },
335+ }
336+ }
337+ if b .PayloadAttestations == nil {
338+ b .PayloadAttestations = solid .NewStaticListSSZ [* PayloadAttestation ](int (b .beaconCfg .MaxPayloadAttestations ), 0 )
339+ }
340+ }
314341
315342 size += b .ProposerSlashings .EncodingSizeSSZ ()
316343 size += b .AttesterSlashings .EncodingSizeSSZ ()
317344 size += b .Attestations .EncodingSizeSSZ ()
318345 size += b .Deposits .EncodingSizeSSZ ()
319346 size += b .VoluntaryExits .EncodingSizeSSZ ()
320- if b .Version >= clparams .BellatrixVersion {
347+ // [Modified in Gloas:EIP7732] ExecutionPayload removed in GLOAS
348+ if b .Version >= clparams .BellatrixVersion && b .Version < clparams .GloasVersion {
321349 size += b .ExecutionPayload .EncodingSizeSSZ ()
322350 }
323351 if b .Version >= clparams .CapellaVersion {
324352 size += b .ExecutionChanges .EncodingSizeSSZ ()
325353 }
326- if b .Version >= clparams .DenebVersion {
354+ // [Modified in Gloas:EIP7732] BlobKzgCommitments removed in GLOAS
355+ if b .Version >= clparams .DenebVersion && b .Version < clparams .GloasVersion {
327356 size += b .BlobKzgCommitments .EncodingSizeSSZ ()
328357 }
329- if b .Version >= clparams .ElectraVersion {
358+ // [Modified in Gloas:EIP7732] ExecutionRequests removed in GLOAS
359+ if b .Version >= clparams .ElectraVersion && b .Version < clparams .GloasVersion {
330360 if b .ExecutionRequests != nil {
331361 size += b .ExecutionRequests .EncodingSizeSSZ ()
332362 }
333363 }
364+ // [New in Gloas:EIP7732] SignedExecutionPayloadBid and PayloadAttestations
365+ if b .Version >= clparams .GloasVersion {
366+ size += b .SignedExecutionPayloadBid .EncodingSizeSSZ ()
367+ size += b .PayloadAttestations .EncodingSizeSSZ ()
368+ }
334369
335370 return
336371}
@@ -342,12 +377,30 @@ func (b *BeaconBody) DecodeSSZ(buf []byte, version int) error {
342377 return fmt .Errorf ("[BeaconBody] err: %s" , ssz .ErrLowBufferSize )
343378 }
344379
345- b .ExecutionPayload = NewEth1Block (b .Version , b .beaconCfg )
380+ // [Modified in Gloas:EIP7732] ExecutionPayload removed in GLOAS
381+ if b .Version < clparams .GloasVersion {
382+ b .ExecutionPayload = NewEth1Block (b .Version , b .beaconCfg )
383+ }
384+ // [New in Gloas:EIP7732] Initialize GLOAS fields for decoding
385+ if b .Version >= clparams .GloasVersion {
386+ b .SignedExecutionPayloadBid = & SignedExecutionPayloadBid {
387+ Message : & ExecutionPayloadBid {
388+ BlobKzgCommitments : * solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 ),
389+ },
390+ }
391+ b .PayloadAttestations = solid .NewStaticListSSZ [* PayloadAttestation ](int (b .beaconCfg .MaxPayloadAttestations ), 0 )
392+ }
346393 err := ssz2 .UnmarshalSSZ (buf , version , b .getSchema (false )... )
347394 return err
348395}
349396
350397func (b * BeaconBody ) Blinded () (* BlindedBeaconBody , error ) {
398+ // [Modified in Gloas:EIP7732] Blinded concept not applicable to GLOAS blocks
399+ // In GLOAS, execution payload is delivered via SignedExecutionPayloadEnvelope
400+ if b .Version >= clparams .GloasVersion {
401+ return nil , errors .New ("blinded beacon body not supported for GLOAS blocks" )
402+ }
403+
351404 header , err := b .ExecutionPayload .PayloadHeader ()
352405 if err != nil {
353406 return nil , err
@@ -380,30 +433,46 @@ func (b *BeaconBody) getSchema(storage bool) []any {
380433 if b .Version >= clparams .AltairVersion {
381434 s = append (s , b .SyncAggregate )
382435 }
383- if b .Version >= clparams .BellatrixVersion && ! storage {
436+ // [Modified in Gloas:EIP7732] ExecutionPayload removed in GLOAS
437+ if b .Version >= clparams .BellatrixVersion && b .Version < clparams .GloasVersion && ! storage {
384438 s = append (s , b .ExecutionPayload )
385439 }
386440 if b .Version >= clparams .CapellaVersion {
387441 s = append (s , b .ExecutionChanges )
388442 }
389- if b .Version >= clparams .DenebVersion {
443+ // [Modified in Gloas:EIP7732] BlobKzgCommitments removed in GLOAS
444+ if b .Version >= clparams .DenebVersion && b .Version < clparams .GloasVersion {
390445 s = append (s , b .BlobKzgCommitments )
391446 }
392- if b .Version >= clparams .ElectraVersion {
447+ // [Modified in Gloas:EIP7732] ExecutionRequests removed in GLOAS
448+ if b .Version >= clparams .ElectraVersion && b .Version < clparams .GloasVersion {
393449 s = append (s , b .ExecutionRequests )
394450 }
451+ // [New in Gloas:EIP7732] SignedExecutionPayloadBid and PayloadAttestations
452+ if b .Version >= clparams .GloasVersion {
453+ s = append (s , b .SignedExecutionPayloadBid )
454+ s = append (s , b .PayloadAttestations )
455+ }
395456 return s
396457}
397458
398459func (* BeaconBody ) Static () bool {
399460 return false
400461}
401462func (b * BeaconBody ) ExecutionPayloadMerkleProof () ([][32 ]byte , error ) {
463+ // [Modified in Gloas:EIP7732] ExecutionPayload not present in GLOAS blocks
464+ if b .Version >= clparams .GloasVersion {
465+ return nil , errors .New ("execution payload merkle proof not available for GLOAS blocks" )
466+ }
402467 return merkle_tree .MerkleProof (4 , 9 , b .getSchema (false )... )
403468}
404469
405470func (b * BeaconBody ) KzgCommitmentMerkleProof (index int ) ([][32 ]byte , error ) {
406- if index >= b .BlobKzgCommitments .Len () {
471+ // [Modified in Gloas:EIP7732] BlobKzgCommitments not in BeaconBody for GLOAS
472+ if b .Version >= clparams .GloasVersion {
473+ return nil , errors .New ("kzg commitment merkle proof not available for GLOAS blocks; use SignedExecutionPayloadBid" )
474+ }
475+ if b .BlobKzgCommitments == nil || index >= b .BlobKzgCommitments .Len () {
407476 return nil , errors .New ("index out of range" )
408477 }
409478 kzgCommitmentsProof , err := merkle_tree .MerkleProof (4 , 11 , b .getSchema (false )... )
@@ -415,6 +484,10 @@ func (b *BeaconBody) KzgCommitmentMerkleProof(index int) ([][32]byte, error) {
415484}
416485
417486func (b * BeaconBody ) KzgCommitmentsInclusionProof () ([][32 ]byte , error ) {
487+ // [Modified in Gloas:EIP7732] BlobKzgCommitments not in BeaconBody for GLOAS
488+ if b .Version >= clparams .GloasVersion {
489+ return nil , errors .New ("kzg commitments inclusion proof not available for GLOAS blocks; use SignedExecutionPayloadBid" )
490+ }
418491 return merkle_tree .MerkleProof (4 , 11 , b .getSchema (false )... )
419492}
420493
@@ -442,16 +515,26 @@ func (b *BeaconBody) UnmarshalJSON(buf []byte) error {
442515 ExecutionChanges * solid.ListSSZ [* SignedBLSToExecutionChange ] `json:"bls_to_execution_changes,omitempty"`
443516 BlobKzgCommitments * solid.ListSSZ [* KZGCommitment ] `json:"blob_kzg_commitments,omitempty"`
444517 ExecutionRequests * ExecutionRequests `json:"execution_requests,omitempty"`
518+ // [New in Gloas:EIP7732]
519+ SignedExecutionPayloadBid * SignedExecutionPayloadBid `json:"signed_execution_payload_bid,omitempty"`
520+ PayloadAttestations * solid.ListSSZ [* PayloadAttestation ] `json:"payload_attestations,omitempty"`
445521 }
446522 tmp .ProposerSlashings = solid .NewStaticListSSZ [* ProposerSlashing ](MaxProposerSlashings , 416 )
447523 tmp .AttesterSlashings = solid.NewDynamicListSSZ [* AttesterSlashing ](maxAttSlashing )
448524 tmp .Attestations = solid.NewDynamicListSSZ [* solid.Attestation ](maxAttestation )
449525 tmp .Deposits = solid .NewStaticListSSZ [* Deposit ](MaxDeposits , 1240 )
450526 tmp .VoluntaryExits = solid .NewStaticListSSZ [* SignedVoluntaryExit ](MaxVoluntaryExits , 112 )
451527 tmp .ExecutionChanges = solid .NewStaticListSSZ [* SignedBLSToExecutionChange ](MaxExecutionChanges , 172 )
452- tmp .BlobKzgCommitments = solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 )
453- tmp .ExecutionRequests = NewExecutionRequests (b .beaconCfg )
454- tmp .ExecutionPayload = NewEth1Block (b .Version , b .beaconCfg )
528+ // [Modified in Gloas:EIP7732] Only initialize pre-GLOAS fields when needed
529+ if b .Version < clparams .GloasVersion {
530+ tmp .BlobKzgCommitments = solid .NewStaticListSSZ [* KZGCommitment ](MaxBlobsCommittmentsPerBlock , 48 )
531+ tmp .ExecutionRequests = NewExecutionRequests (b .beaconCfg )
532+ tmp .ExecutionPayload = NewEth1Block (b .Version , b .beaconCfg )
533+ }
534+ // [New in Gloas:EIP7732] Initialize GLOAS fields
535+ if b .Version >= clparams .GloasVersion {
536+ tmp .PayloadAttestations = solid .NewStaticListSSZ [* PayloadAttestation ](int (b .beaconCfg .MaxPayloadAttestations ), 0 )
537+ }
455538
456539 if err := json .Unmarshal (buf , & tmp ); err != nil {
457540 return err
@@ -471,16 +554,29 @@ func (b *BeaconBody) UnmarshalJSON(buf []byte) error {
471554 b .Deposits = tmp .Deposits
472555 b .VoluntaryExits = tmp .VoluntaryExits
473556 b .SyncAggregate = tmp .SyncAggregate
474- b .ExecutionPayload = tmp .ExecutionPayload
475557 b .ExecutionChanges = tmp .ExecutionChanges
476- b .BlobKzgCommitments = tmp .BlobKzgCommitments
477- if b .Version >= clparams .ElectraVersion {
478- b .ExecutionRequests = tmp .ExecutionRequests
558+
559+ // [Modified in Gloas:EIP7732] Version-specific field assignment
560+ if b .Version < clparams .GloasVersion {
561+ b .ExecutionPayload = tmp .ExecutionPayload
562+ b .BlobKzgCommitments = tmp .BlobKzgCommitments
563+ if b .Version >= clparams .ElectraVersion {
564+ b .ExecutionRequests = tmp .ExecutionRequests
565+ }
566+ }
567+ // [New in Gloas:EIP7732]
568+ if b .Version >= clparams .GloasVersion {
569+ b .SignedExecutionPayloadBid = tmp .SignedExecutionPayloadBid
570+ b .PayloadAttestations = tmp .PayloadAttestations
479571 }
480572 return nil
481573}
482574
483575func (b * BeaconBody ) GetPayloadHeader () (* Eth1Header , error ) {
576+ // [Modified in Gloas:EIP7732] ExecutionPayload not present in GLOAS blocks
577+ if b .Version >= clparams .GloasVersion || b .ExecutionPayload == nil {
578+ return nil , errors .New ("execution payload not available for GLOAS blocks" )
579+ }
484580 return b .ExecutionPayload .PayloadHeader ()
485581}
486582
@@ -517,6 +613,13 @@ func (b *BeaconBody) GetVoluntaryExits() *solid.ListSSZ[*SignedVoluntaryExit] {
517613}
518614
519615func (b * BeaconBody ) GetBlobKzgCommitments () * solid.ListSSZ [* KZGCommitment ] {
616+ // [Modified in Gloas:EIP7732] In GLOAS, blob_kzg_commitments moved to signed_execution_payload_bid.message
617+ if b .Version >= clparams .GloasVersion {
618+ if b .SignedExecutionPayloadBid != nil && b .SignedExecutionPayloadBid .Message != nil {
619+ return & b .SignedExecutionPayloadBid .Message .BlobKzgCommitments
620+ }
621+ return nil
622+ }
520623 return b .BlobKzgCommitments
521624}
522625
0 commit comments