Update block publishing Beacon APIs to Electra (#14361)

* Update block publishing Beacon APIs to Electra

* linter
This commit is contained in:
Radosław Kapka
2024-08-20 18:57:08 +02:00
committed by GitHub
parent 068139a78a
commit ed3d7d49ec
8 changed files with 1008 additions and 53 deletions

View File

@@ -149,6 +149,7 @@ ssz_electra_objs = [
"PendingConsolidation",
"PendingPartialWithdrawal",
"SignedAggregateAttestationAndProofElectra",
"SignedBeaconBlockContentsElectra",
"SignedBeaconBlockElectra",
"SignedBlindedBeaconBlockElectra",
"SignedConsolidation",
@@ -156,90 +157,89 @@ ssz_electra_objs = [
ssz_gen_marshal(
name = "ssz_generated_phase0",
go_proto = ":go_proto",
out = "phase0.ssz.go",
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
],
objs = ssz_phase0_objs,
)
ssz_gen_marshal(
name = "ssz_generated_altair",
go_proto = ":go_proto",
out = "altair.ssz.go",
exclude_objs = ssz_phase0_objs,
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
],
objs = ssz_altair_objs,
exclude_objs = ssz_phase0_objs,
)
ssz_gen_marshal(
name = "ssz_generated_bellatrix",
go_proto = ":go_proto",
out = "bellatrix.ssz.go",
exclude_objs = ssz_phase0_objs + ssz_altair_objs,
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
],
objs = ssz_bellatrix_objs,
exclude_objs = ssz_phase0_objs + ssz_altair_objs,
)
ssz_gen_marshal(
name = "ssz_generated_capella",
go_proto = ":go_proto",
out = "capella.ssz.go",
exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs,
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
],
objs = ssz_capella_objs,
exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs,
)
ssz_gen_marshal(
name = "ssz_generated_deneb",
go_proto = ":go_proto",
out = "deneb.ssz.go",
exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs,
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
],
objs = ssz_deneb_objs,
exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs,
)
ssz_gen_marshal(
name = "ssz_generated_electra",
go_proto = ":go_proto",
out = "electra.ssz.go",
exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs + ssz_deneb_objs,
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
],
objs = ssz_electra_objs,
exclude_objs = ssz_phase0_objs + ssz_altair_objs + ssz_bellatrix_objs + ssz_capella_objs + ssz_deneb_objs,
)
ssz_gen_marshal(
name = "ssz_generated_non_core",
go_proto = ":go_proto",
out = "non-core.ssz.go",
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//math:go_default_library",
"//proto/engine/v1:go_default_library",
],
objs = [
"BeaconBlocksByRangeRequest",
@@ -313,13 +313,13 @@ go_library(
"eip_7521.go",
"sync_committee_mainnet.go",
"sync_committee_minimal.go", # keep
":ssz_generated_non_core", # keep
":ssz_generated_phase0", # keep
":ssz_generated_altair", # keep
":ssz_generated_bellatrix", # keep
":ssz_generated_capella", # keep
":ssz_generated_deneb", # keep
":ssz_generated_electra", # keep
":ssz_generated_non_core", # keep
":ssz_generated_phase0", # keep
],
embed = [
":go_grpc_gateway_library",

View File

@@ -1,5 +1,5 @@
// Code generated by fastssz. DO NOT EDIT.
// Hash: 84572d8fa233c45a41477bced891ee355cc1745ae0fad290f110b7f6b5ed12e1
// Hash: 502599304fd370b8602d212eaf1956fe5bf034fe59c75d1a3a6e3db8bcde291a
package eth
import (
@@ -30,20 +30,20 @@ func (a *AttestationElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) {
return
}
// Field (2) 'CommitteeBits'
if size := len(a.CommitteeBits); size != 8 {
err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8)
return
}
dst = append(dst, a.CommitteeBits...)
// Field (3) 'Signature'
// Field (2) 'Signature'
if size := len(a.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
dst = append(dst, a.Signature...)
// Field (3) 'CommitteeBits'
if size := len(a.CommitteeBits); size != 8 {
err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8)
return
}
dst = append(dst, a.CommitteeBits...)
// Field (0) 'AggregationBits'
if size := len(a.AggregationBits); size > 131072 {
err = ssz.ErrBytesLengthFn("--.AggregationBits", size, 131072)
@@ -82,17 +82,17 @@ func (a *AttestationElectra) UnmarshalSSZ(buf []byte) error {
return err
}
// Field (2) 'CommitteeBits'
if cap(a.CommitteeBits) == 0 {
a.CommitteeBits = make([]byte, 0, len(buf[132:140]))
}
a.CommitteeBits = append(a.CommitteeBits, buf[132:140]...)
// Field (3) 'Signature'
// Field (2) 'Signature'
if cap(a.Signature) == 0 {
a.Signature = make([]byte, 0, len(buf[140:236]))
a.Signature = make([]byte, 0, len(buf[132:228]))
}
a.Signature = append(a.Signature, buf[140:236]...)
a.Signature = append(a.Signature, buf[132:228]...)
// Field (3) 'CommitteeBits'
if cap(a.CommitteeBits) == 0 {
a.CommitteeBits = make([]byte, 0, len(buf[228:236]))
}
a.CommitteeBits = append(a.CommitteeBits, buf[228:236]...)
// Field (0) 'AggregationBits'
{
@@ -139,20 +139,20 @@ func (a *AttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) {
return
}
// Field (2) 'CommitteeBits'
if size := len(a.CommitteeBits); size != 8 {
err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8)
return
}
hh.PutBytes(a.CommitteeBits)
// Field (3) 'Signature'
// Field (2) 'Signature'
if size := len(a.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
hh.PutBytes(a.Signature)
// Field (3) 'CommitteeBits'
if size := len(a.CommitteeBits); size != 8 {
err = ssz.ErrBytesLengthFn("--.CommitteeBits", size, 8)
return
}
hh.PutBytes(a.CommitteeBits)
hh.Merkleize(indx)
return
}
@@ -653,6 +653,215 @@ func (i *IndexedAttestationElectra) HashTreeRootWith(hh *ssz.Hasher) (err error)
return
}
// MarshalSSZ ssz marshals the SignedBeaconBlockContentsElectra object
func (s *SignedBeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBeaconBlockContentsElectra object to a target array
func (s *SignedBeaconBlockContentsElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(12)
// Offset (0) 'Block'
dst = ssz.WriteOffset(dst, offset)
if s.Block == nil {
s.Block = new(SignedBeaconBlockElectra)
}
offset += s.Block.SizeSSZ()
// Offset (1) 'KzgProofs'
dst = ssz.WriteOffset(dst, offset)
offset += len(s.KzgProofs) * 48
// Offset (2) 'Blobs'
dst = ssz.WriteOffset(dst, offset)
offset += len(s.Blobs) * 131072
// Field (0) 'Block'
if dst, err = s.Block.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'KzgProofs'
if size := len(s.KzgProofs); size > 4096 {
err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096)
return
}
for ii := 0; ii < len(s.KzgProofs); ii++ {
if size := len(s.KzgProofs[ii]); size != 48 {
err = ssz.ErrBytesLengthFn("--.KzgProofs[ii]", size, 48)
return
}
dst = append(dst, s.KzgProofs[ii]...)
}
// Field (2) 'Blobs'
if size := len(s.Blobs); size > 4096 {
err = ssz.ErrListTooBigFn("--.Blobs", size, 4096)
return
}
for ii := 0; ii < len(s.Blobs); ii++ {
if size := len(s.Blobs[ii]); size != 131072 {
err = ssz.ErrBytesLengthFn("--.Blobs[ii]", size, 131072)
return
}
dst = append(dst, s.Blobs[ii]...)
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlockContentsElectra object
func (s *SignedBeaconBlockContentsElectra) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 12 {
return ssz.ErrSize
}
tail := buf
var o0, o1, o2 uint64
// Offset (0) 'Block'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 != 12 {
return ssz.ErrInvalidVariableOffset
}
// Offset (1) 'KzgProofs'
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
return ssz.ErrOffset
}
// Offset (2) 'Blobs'
if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 {
return ssz.ErrOffset
}
// Field (0) 'Block'
{
buf = tail[o0:o1]
if s.Block == nil {
s.Block = new(SignedBeaconBlockElectra)
}
if err = s.Block.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (1) 'KzgProofs'
{
buf = tail[o1:o2]
num, err := ssz.DivideInt2(len(buf), 48, 4096)
if err != nil {
return err
}
s.KzgProofs = make([][]byte, num)
for ii := 0; ii < num; ii++ {
if cap(s.KzgProofs[ii]) == 0 {
s.KzgProofs[ii] = make([]byte, 0, len(buf[ii*48:(ii+1)*48]))
}
s.KzgProofs[ii] = append(s.KzgProofs[ii], buf[ii*48:(ii+1)*48]...)
}
}
// Field (2) 'Blobs'
{
buf = tail[o2:]
num, err := ssz.DivideInt2(len(buf), 131072, 4096)
if err != nil {
return err
}
s.Blobs = make([][]byte, num)
for ii := 0; ii < num; ii++ {
if cap(s.Blobs[ii]) == 0 {
s.Blobs[ii] = make([]byte, 0, len(buf[ii*131072:(ii+1)*131072]))
}
s.Blobs[ii] = append(s.Blobs[ii], buf[ii*131072:(ii+1)*131072]...)
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockContentsElectra object
func (s *SignedBeaconBlockContentsElectra) SizeSSZ() (size int) {
size = 12
// Field (0) 'Block'
if s.Block == nil {
s.Block = new(SignedBeaconBlockElectra)
}
size += s.Block.SizeSSZ()
// Field (1) 'KzgProofs'
size += len(s.KzgProofs) * 48
// Field (2) 'Blobs'
size += len(s.Blobs) * 131072
return
}
// HashTreeRoot ssz hashes the SignedBeaconBlockContentsElectra object
func (s *SignedBeaconBlockContentsElectra) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBeaconBlockContentsElectra object with a hasher
func (s *SignedBeaconBlockContentsElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Block'
if err = s.Block.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'KzgProofs'
{
if size := len(s.KzgProofs); size > 4096 {
err = ssz.ErrListTooBigFn("--.KzgProofs", size, 4096)
return
}
subIndx := hh.Index()
for _, i := range s.KzgProofs {
if len(i) != 48 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(i)
}
numItems := uint64(len(s.KzgProofs))
hh.MerkleizeWithMixin(subIndx, numItems, 4096)
}
// Field (2) 'Blobs'
{
if size := len(s.Blobs); size > 4096 {
err = ssz.ErrListTooBigFn("--.Blobs", size, 4096)
return
}
subIndx := hh.Index()
for _, i := range s.Blobs {
if len(i) != 131072 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(i)
}
numItems := uint64(len(s.Blobs))
hh.MerkleizeWithMixin(subIndx, numItems, 4096)
}
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the SignedBeaconBlockElectra object
func (s *SignedBeaconBlockElectra) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)