Builder ssz (#14976)

* wip

* refactoring functions for easier readability

* allow ssz for register validator

* changelog

* adding in blinded block submission tests

* adding in tests for header ssz

* fixing linting and tests

* adding in custom errors and fixing ssz validator registration

* Update api/client/builder/client.go

Co-authored-by: Manu NALEPA <enalepa@offchainlabs.com>

* Update api/client/builder/client.go

Co-authored-by: Manu NALEPA <enalepa@offchainlabs.com>

* manu's feedback

* linting

* adding in info log to notify that this setting was turned on

* fixing linting

* manu's feedback

* fixing import

---------

Co-authored-by: Manu NALEPA <enalepa@offchainlabs.com>
This commit is contained in:
james-prysm
2025-03-14 12:23:00 -05:00
committed by GitHub
parent 1caea86152
commit 15ae71c0da
20 changed files with 2054 additions and 456 deletions

View File

@@ -42,6 +42,7 @@ ssz_gen_marshal(
"ExecutionPayloadHeaderCapella",
"ExecutionPayloadHeaderDeneb",
"ExecutionPayloadDeneb",
'ExecutionPayloadDenebAndBlobsBundle',
"BlindedBlobsBundle",
"BlobsBundle",
"Withdrawal",

View File

@@ -1791,6 +1791,134 @@ func (e *ExecutionPayloadDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) {
return
}
// MarshalSSZ ssz marshals the ExecutionPayloadDenebAndBlobsBundle object
func (e *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(e)
}
// MarshalSSZTo ssz marshals the ExecutionPayloadDenebAndBlobsBundle object to a target array
func (e *ExecutionPayloadDenebAndBlobsBundle) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(8)
// Offset (0) 'Payload'
dst = ssz.WriteOffset(dst, offset)
if e.Payload == nil {
e.Payload = new(ExecutionPayloadDeneb)
}
offset += e.Payload.SizeSSZ()
// Offset (1) 'BlobsBundle'
dst = ssz.WriteOffset(dst, offset)
if e.BlobsBundle == nil {
e.BlobsBundle = new(BlobsBundle)
}
offset += e.BlobsBundle.SizeSSZ()
// Field (0) 'Payload'
if dst, err = e.Payload.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'BlobsBundle'
if dst, err = e.BlobsBundle.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the ExecutionPayloadDenebAndBlobsBundle object
func (e *ExecutionPayloadDenebAndBlobsBundle) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 8 {
return ssz.ErrSize
}
tail := buf
var o0, o1 uint64
// Offset (0) 'Payload'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 != 8 {
return ssz.ErrInvalidVariableOffset
}
// Offset (1) 'BlobsBundle'
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
return ssz.ErrOffset
}
// Field (0) 'Payload'
{
buf = tail[o0:o1]
if e.Payload == nil {
e.Payload = new(ExecutionPayloadDeneb)
}
if err = e.Payload.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (1) 'BlobsBundle'
{
buf = tail[o1:]
if e.BlobsBundle == nil {
e.BlobsBundle = new(BlobsBundle)
}
if err = e.BlobsBundle.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadDenebAndBlobsBundle object
func (e *ExecutionPayloadDenebAndBlobsBundle) SizeSSZ() (size int) {
size = 8
// Field (0) 'Payload'
if e.Payload == nil {
e.Payload = new(ExecutionPayloadDeneb)
}
size += e.Payload.SizeSSZ()
// Field (1) 'BlobsBundle'
if e.BlobsBundle == nil {
e.BlobsBundle = new(BlobsBundle)
}
size += e.BlobsBundle.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the ExecutionPayloadDenebAndBlobsBundle object
func (e *ExecutionPayloadDenebAndBlobsBundle) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(e)
}
// HashTreeRootWith ssz hashes the ExecutionPayloadDenebAndBlobsBundle object with a hasher
func (e *ExecutionPayloadDenebAndBlobsBundle) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Payload'
if err = e.Payload.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'BlobsBundle'
if err = e.BlobsBundle.HashTreeRootWith(hh); err != nil {
return
}
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the ExecutionPayloadHeader object
func (e *ExecutionPayloadHeader) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(e)

File diff suppressed because it is too large Load Diff

View File

@@ -97,6 +97,11 @@ message ExecutionPayloadCapellaWithValue {
bytes value = 2;
}
message ExecutionPayloadDenebAndBlobsBundle {
ExecutionPayloadDeneb payload = 1;
BlobsBundle blobs_bundle = 2;
}
message ExecutionPayloadDenebWithValueAndBlobsBundle {
ExecutionPayloadDeneb payload = 1;
bytes value = 2;

View File

@@ -124,6 +124,7 @@ ssz_capella_objs = [
"SignedBeaconBlockCapella",
"SignedBlindedBeaconBlockCapella",
"Withdrawal",
"SignedBuilderBidCapella",
]
ssz_deneb_objs = [
@@ -145,6 +146,7 @@ ssz_deneb_objs = [
"SignedBeaconBlockContentsDeneb",
"SignedBeaconBlockDeneb",
"SignedBlindedBeaconBlockDeneb",
"SignedBuilderBidDeneb",
]
ssz_electra_objs = [
@@ -175,7 +177,8 @@ ssz_electra_objs = [
"SignedBeaconBlockElectra",
"SignedBlindedBeaconBlockElectra",
"SignedConsolidation",
"SingleAttestation"
"SingleAttestation",
"SignedBuilderBidElectra",
]
ssz_fulu_objs = [
@@ -297,6 +300,7 @@ ssz_gen_marshal(
"SignedValidatorRegistrationV1",
"ValidatorRegistrationV1",
"BuilderBid",
"SignedBuilderBid",
"DepositSnapshot",
],
)

View File

@@ -1613,6 +1613,115 @@ func (b *BlindedBeaconBlockBodyCapella) HashTreeRootWith(hh *ssz.Hasher) (err er
return
}
// MarshalSSZ ssz marshals the SignedBuilderBidCapella object
func (s *SignedBuilderBidCapella) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBuilderBidCapella object to a target array
func (s *SignedBuilderBidCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(100)
// Offset (0) 'Message'
dst = ssz.WriteOffset(dst, offset)
if s.Message == nil {
s.Message = new(BuilderBidCapella)
}
offset += s.Message.SizeSSZ()
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
dst = append(dst, s.Signature...)
// Field (0) 'Message'
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBuilderBidCapella object
func (s *SignedBuilderBidCapella) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 100 {
return ssz.ErrSize
}
tail := buf
var o0 uint64
// Offset (0) 'Message'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 != 100 {
return ssz.ErrInvalidVariableOffset
}
// Field (1) 'Signature'
if cap(s.Signature) == 0 {
s.Signature = make([]byte, 0, len(buf[4:100]))
}
s.Signature = append(s.Signature, buf[4:100]...)
// Field (0) 'Message'
{
buf = tail[o0:]
if s.Message == nil {
s.Message = new(BuilderBidCapella)
}
if err = s.Message.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidCapella object
func (s *SignedBuilderBidCapella) SizeSSZ() (size int) {
size = 100
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BuilderBidCapella)
}
size += s.Message.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the SignedBuilderBidCapella object
func (s *SignedBuilderBidCapella) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBuilderBidCapella object with a hasher
func (s *SignedBuilderBidCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Message'
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
hh.PutBytes(s.Signature)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the BuilderBidCapella object
func (b *BuilderBidCapella) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)

View File

@@ -2151,6 +2151,115 @@ func (b *BlindedBeaconBlockBodyDeneb) HashTreeRootWith(hh *ssz.Hasher) (err erro
return
}
// MarshalSSZ ssz marshals the SignedBuilderBidDeneb object
func (s *SignedBuilderBidDeneb) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBuilderBidDeneb object to a target array
func (s *SignedBuilderBidDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(100)
// Offset (0) 'Message'
dst = ssz.WriteOffset(dst, offset)
if s.Message == nil {
s.Message = new(BuilderBidDeneb)
}
offset += s.Message.SizeSSZ()
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
dst = append(dst, s.Signature...)
// Field (0) 'Message'
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBuilderBidDeneb object
func (s *SignedBuilderBidDeneb) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 100 {
return ssz.ErrSize
}
tail := buf
var o0 uint64
// Offset (0) 'Message'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 != 100 {
return ssz.ErrInvalidVariableOffset
}
// Field (1) 'Signature'
if cap(s.Signature) == 0 {
s.Signature = make([]byte, 0, len(buf[4:100]))
}
s.Signature = append(s.Signature, buf[4:100]...)
// Field (0) 'Message'
{
buf = tail[o0:]
if s.Message == nil {
s.Message = new(BuilderBidDeneb)
}
if err = s.Message.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidDeneb object
func (s *SignedBuilderBidDeneb) SizeSSZ() (size int) {
size = 100
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BuilderBidDeneb)
}
size += s.Message.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the SignedBuilderBidDeneb object
func (s *SignedBuilderBidDeneb) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBuilderBidDeneb object with a hasher
func (s *SignedBuilderBidDeneb) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Message'
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
hh.PutBytes(s.Signature)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the BuilderBidDeneb object
func (b *BuilderBidDeneb) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)

View File

@@ -887,6 +887,115 @@ func (b *BuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) {
return
}
// MarshalSSZ ssz marshals the SignedBuilderBidElectra object
func (s *SignedBuilderBidElectra) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBuilderBidElectra object to a target array
func (s *SignedBuilderBidElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(100)
// Offset (0) 'Message'
dst = ssz.WriteOffset(dst, offset)
if s.Message == nil {
s.Message = new(BuilderBidElectra)
}
offset += s.Message.SizeSSZ()
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
dst = append(dst, s.Signature...)
// Field (0) 'Message'
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBuilderBidElectra object
func (s *SignedBuilderBidElectra) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 100 {
return ssz.ErrSize
}
tail := buf
var o0 uint64
// Offset (0) 'Message'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 != 100 {
return ssz.ErrInvalidVariableOffset
}
// Field (1) 'Signature'
if cap(s.Signature) == 0 {
s.Signature = make([]byte, 0, len(buf[4:100]))
}
s.Signature = append(s.Signature, buf[4:100]...)
// Field (0) 'Message'
{
buf = tail[o0:]
if s.Message == nil {
s.Message = new(BuilderBidElectra)
}
if err = s.Message.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBidElectra object
func (s *SignedBuilderBidElectra) SizeSSZ() (size int) {
size = 100
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BuilderBidElectra)
}
size += s.Message.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the SignedBuilderBidElectra object
func (s *SignedBuilderBidElectra) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBuilderBidElectra object with a hasher
func (s *SignedBuilderBidElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Message'
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
hh.PutBytes(s.Signature)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the SignedBeaconBlockContentsElectra object
func (s *SignedBeaconBlockContentsElectra) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)

View File

@@ -190,6 +190,115 @@ func (v *ValidatorRegistrationV1) HashTreeRootWith(hh *ssz.Hasher) (err error) {
return
}
// MarshalSSZ ssz marshals the SignedBuilderBid object
func (s *SignedBuilderBid) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBuilderBid object to a target array
func (s *SignedBuilderBid) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(100)
// Offset (0) 'Message'
dst = ssz.WriteOffset(dst, offset)
if s.Message == nil {
s.Message = new(BuilderBid)
}
offset += s.Message.SizeSSZ()
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
dst = append(dst, s.Signature...)
// Field (0) 'Message'
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBuilderBid object
func (s *SignedBuilderBid) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 100 {
return ssz.ErrSize
}
tail := buf
var o0 uint64
// Offset (0) 'Message'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 != 100 {
return ssz.ErrInvalidVariableOffset
}
// Field (1) 'Signature'
if cap(s.Signature) == 0 {
s.Signature = make([]byte, 0, len(buf[4:100]))
}
s.Signature = append(s.Signature, buf[4:100]...)
// Field (0) 'Message'
{
buf = tail[o0:]
if s.Message == nil {
s.Message = new(BuilderBid)
}
if err = s.Message.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBuilderBid object
func (s *SignedBuilderBid) SizeSSZ() (size int) {
size = 100
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BuilderBid)
}
size += s.Message.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the SignedBuilderBid object
func (s *SignedBuilderBid) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBuilderBid object with a hasher
func (s *SignedBuilderBid) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Message'
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'Signature'
if size := len(s.Signature); size != 96 {
err = ssz.ErrBytesLengthFn("--.Signature", size, 96)
return
}
hh.PutBytes(s.Signature)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the BuilderBid object
func (b *BuilderBid) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)