Files
prysm/proto/ssz_query/ssz_query.ssz.go
Jun Song 26d8b6b786 Initialize SSZ-QL package with support for fixed-size types (#15588)
* Add basic PathElement

* Add ssz_type.go

* Add basic sszInfo

* Add containerInfo

* Add basic analyzer without analyzing list/vector

* Add analyzer for homogeneous collection types

* Add offset/length calculator

* Add testutil package in encoding/ssz/query

* Add first round trip test for IndexedAttestationElectra

* Go mod tidy

* Add Print function for debugging purpose

* Add changelog

* Add testonly flag for testutil package & Nit for nogo

* Apply reviews from Radek

* Replace fastssz with prysmaticlabs one

* Add proto/ssz_query package for testing purpose

* Update encoding/ssz/query tests to decouple with beacon types

* Use require.* instead of assert.*

* Fix import name for proto ssz_query package

* Remove uint8/uint16 and some byte arrays in FixedTestContainer

* Add newline for files

* Fix comment about byte array in ssz_query.proto

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
2025-08-25 14:29:26 +00:00

239 lines
5.6 KiB
Go

// Code generated by fastssz. DO NOT EDIT.
package ssz_query
import (
ssz "github.com/prysmaticlabs/fastssz"
)
// MarshalSSZ ssz marshals the FixedNestedContainer object
func (f *FixedNestedContainer) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(f)
}
// MarshalSSZTo ssz marshals the FixedNestedContainer object to a target array
func (f *FixedNestedContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'Value1'
dst = ssz.MarshalUint64(dst, f.Value1)
// Field (1) 'Value2'
if size := len(f.Value2); size != 32 {
err = ssz.ErrBytesLengthFn("--.Value2", size, 32)
return
}
dst = append(dst, f.Value2...)
return
}
// UnmarshalSSZ ssz unmarshals the FixedNestedContainer object
func (f *FixedNestedContainer) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 40 {
return ssz.ErrSize
}
// Field (0) 'Value1'
f.Value1 = ssz.UnmarshallUint64(buf[0:8])
// Field (1) 'Value2'
if cap(f.Value2) == 0 {
f.Value2 = make([]byte, 0, len(buf[8:40]))
}
f.Value2 = append(f.Value2, buf[8:40]...)
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the FixedNestedContainer object
func (f *FixedNestedContainer) SizeSSZ() (size int) {
size = 40
return
}
// HashTreeRoot ssz hashes the FixedNestedContainer object
func (f *FixedNestedContainer) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(f)
}
// HashTreeRootWith ssz hashes the FixedNestedContainer object with a hasher
func (f *FixedNestedContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Value1'
hh.PutUint64(f.Value1)
// Field (1) 'Value2'
if size := len(f.Value2); size != 32 {
err = ssz.ErrBytesLengthFn("--.Value2", size, 32)
return
}
hh.PutBytes(f.Value2)
hh.Merkleize(indx)
return
}
// MarshalSSZ ssz marshals the FixedTestContainer object
func (f *FixedTestContainer) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(f)
}
// MarshalSSZTo ssz marshals the FixedTestContainer object to a target array
func (f *FixedTestContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'FieldUint32'
dst = ssz.MarshalUint32(dst, f.FieldUint32)
// Field (1) 'FieldUint64'
dst = ssz.MarshalUint64(dst, f.FieldUint64)
// Field (2) 'FieldBool'
dst = ssz.MarshalBool(dst, f.FieldBool)
// Field (3) 'FieldBytes32'
if size := len(f.FieldBytes32); size != 32 {
err = ssz.ErrBytesLengthFn("--.FieldBytes32", size, 32)
return
}
dst = append(dst, f.FieldBytes32...)
// Field (4) 'Nested'
if f.Nested == nil {
f.Nested = new(FixedNestedContainer)
}
if dst, err = f.Nested.MarshalSSZTo(dst); err != nil {
return
}
// Field (5) 'VectorField'
if size := len(f.VectorField); size != 24 {
err = ssz.ErrVectorLengthFn("--.VectorField", size, 24)
return
}
for ii := 0; ii < 24; ii++ {
dst = ssz.MarshalUint64(dst, f.VectorField[ii])
}
// Field (6) 'TrailingField'
if size := len(f.TrailingField); size != 56 {
err = ssz.ErrBytesLengthFn("--.TrailingField", size, 56)
return
}
dst = append(dst, f.TrailingField...)
return
}
// UnmarshalSSZ ssz unmarshals the FixedTestContainer object
func (f *FixedTestContainer) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 333 {
return ssz.ErrSize
}
// Field (0) 'FieldUint32'
f.FieldUint32 = ssz.UnmarshallUint32(buf[0:4])
// Field (1) 'FieldUint64'
f.FieldUint64 = ssz.UnmarshallUint64(buf[4:12])
// Field (2) 'FieldBool'
f.FieldBool, err = ssz.DecodeBool(buf[12:13])
if err != nil {
return err
}
// Field (3) 'FieldBytes32'
if cap(f.FieldBytes32) == 0 {
f.FieldBytes32 = make([]byte, 0, len(buf[13:45]))
}
f.FieldBytes32 = append(f.FieldBytes32, buf[13:45]...)
// Field (4) 'Nested'
if f.Nested == nil {
f.Nested = new(FixedNestedContainer)
}
if err = f.Nested.UnmarshalSSZ(buf[45:85]); err != nil {
return err
}
// Field (5) 'VectorField'
f.VectorField = ssz.ExtendUint64(f.VectorField, 24)
for ii := 0; ii < 24; ii++ {
f.VectorField[ii] = ssz.UnmarshallUint64(buf[85:277][ii*8 : (ii+1)*8])
}
// Field (6) 'TrailingField'
if cap(f.TrailingField) == 0 {
f.TrailingField = make([]byte, 0, len(buf[277:333]))
}
f.TrailingField = append(f.TrailingField, buf[277:333]...)
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the FixedTestContainer object
func (f *FixedTestContainer) SizeSSZ() (size int) {
size = 333
return
}
// HashTreeRoot ssz hashes the FixedTestContainer object
func (f *FixedTestContainer) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(f)
}
// HashTreeRootWith ssz hashes the FixedTestContainer object with a hasher
func (f *FixedTestContainer) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'FieldUint32'
hh.PutUint32(f.FieldUint32)
// Field (1) 'FieldUint64'
hh.PutUint64(f.FieldUint64)
// Field (2) 'FieldBool'
hh.PutBool(f.FieldBool)
// Field (3) 'FieldBytes32'
if size := len(f.FieldBytes32); size != 32 {
err = ssz.ErrBytesLengthFn("--.FieldBytes32", size, 32)
return
}
hh.PutBytes(f.FieldBytes32)
// Field (4) 'Nested'
if err = f.Nested.HashTreeRootWith(hh); err != nil {
return
}
// Field (5) 'VectorField'
{
if size := len(f.VectorField); size != 24 {
err = ssz.ErrVectorLengthFn("--.VectorField", size, 24)
return
}
subIndx := hh.Index()
for _, i := range f.VectorField {
hh.AppendUint64(i)
}
hh.Merkleize(subIndx)
}
// Field (6) 'TrailingField'
if size := len(f.TrailingField); size != 56 {
err = ssz.ErrBytesLengthFn("--.TrailingField", size, 56)
return
}
hh.PutBytes(f.TrailingField)
hh.Merkleize(indx)
return
}