mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
feat: (light client)add new consensus types for Electra (#14527)
* add `LightClientBootstrapElectra` to proto
* add `LightClientUpdateElectra` to proto
* implement `bootstrapElectra`
* add ssz support for `LightClientBootstrapElectra`
* remove unused type
* update `CHANGELOG.md`
* implement `updateElectra`
* refactor: remove `CurrentSyncCommitteeBranchElectra()` from `LightClientBootstrap`
* remove `NewWrappedHeaderElectra`
* Update consensus-types/light-client/bootstrap.go
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
* Update consensus-types/light-client/update.go
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
* add `CurrentSyncCommitteeBranchElectra()` to `LightClientBootstrap`
* add `NextSyncCommitteeBranchElectra()` to `LightClientUpdate`
* revert changes to unrelated pb/ssz files
* Revert "revert changes to unrelated pb/ssz files"
This reverts commit 5ceaaf5ba6.
* more refactors
* even more refactors
---------
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
This commit is contained in:
@@ -27,6 +27,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
|
||||
- Add Bellatrix tests for light client functions.
|
||||
- Add Discovery Rebooter Feature.
|
||||
- Added GetBlockAttestationsV2 endpoint.
|
||||
- Light client support: Consensus types for Electra
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
type LightClientExecutionBranch = [fieldparams.ExecutionBranchDepth][fieldparams.RootLength]byte
|
||||
type LightClientSyncCommitteeBranch = [fieldparams.SyncCommitteeBranchDepth][fieldparams.RootLength]byte
|
||||
type LightClientSyncCommitteeBranchElectra = [fieldparams.SyncCommitteeBranchDepthElectra][fieldparams.RootLength]byte
|
||||
type LightClientFinalityBranch = [fieldparams.FinalityBranchDepth][fieldparams.RootLength]byte
|
||||
|
||||
type LightClientHeader interface {
|
||||
@@ -24,7 +25,8 @@ type LightClientBootstrap interface {
|
||||
Version() int
|
||||
Header() LightClientHeader
|
||||
CurrentSyncCommittee() *pb.SyncCommittee
|
||||
CurrentSyncCommitteeBranch() LightClientSyncCommitteeBranch
|
||||
CurrentSyncCommitteeBranch() (LightClientSyncCommitteeBranch, error)
|
||||
CurrentSyncCommitteeBranchElectra() (LightClientSyncCommitteeBranchElectra, error)
|
||||
}
|
||||
|
||||
type LightClientUpdate interface {
|
||||
@@ -32,7 +34,8 @@ type LightClientUpdate interface {
|
||||
Version() int
|
||||
AttestedHeader() LightClientHeader
|
||||
NextSyncCommittee() *pb.SyncCommittee
|
||||
NextSyncCommitteeBranch() LightClientSyncCommitteeBranch
|
||||
NextSyncCommitteeBranch() (LightClientSyncCommitteeBranch, error)
|
||||
NextSyncCommitteeBranchElectra() (LightClientSyncCommitteeBranchElectra, error)
|
||||
FinalizedHeader() LightClientHeader
|
||||
FinalityBranch() LightClientFinalityBranch
|
||||
SyncAggregate() *pb.SyncAggregate
|
||||
|
||||
@@ -22,6 +22,8 @@ func NewWrappedBootstrap(m proto.Message) (interfaces.LightClientBootstrap, erro
|
||||
return NewWrappedBootstrapCapella(t)
|
||||
case *pb.LightClientBootstrapDeneb:
|
||||
return NewWrappedBootstrapDeneb(t)
|
||||
case *pb.LightClientBootstrapElectra:
|
||||
return NewWrappedBootstrapElectra(t)
|
||||
default:
|
||||
return nil, fmt.Errorf("cannot construct light client bootstrap from type %T", t)
|
||||
}
|
||||
@@ -83,8 +85,12 @@ func (h *bootstrapAltair) CurrentSyncCommittee() *pb.SyncCommittee {
|
||||
return h.p.CurrentSyncCommittee
|
||||
}
|
||||
|
||||
func (h *bootstrapAltair) CurrentSyncCommitteeBranch() interfaces.LightClientSyncCommitteeBranch {
|
||||
return h.currentSyncCommitteeBranch
|
||||
func (h *bootstrapAltair) CurrentSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return h.currentSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
func (h *bootstrapAltair) CurrentSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return [6][32]byte{}, consensustypes.ErrNotSupported("CurrentSyncCommitteeBranchElectra", version.Altair)
|
||||
}
|
||||
|
||||
type bootstrapCapella struct {
|
||||
@@ -143,8 +149,12 @@ func (h *bootstrapCapella) CurrentSyncCommittee() *pb.SyncCommittee {
|
||||
return h.p.CurrentSyncCommittee
|
||||
}
|
||||
|
||||
func (h *bootstrapCapella) CurrentSyncCommitteeBranch() interfaces.LightClientSyncCommitteeBranch {
|
||||
return h.currentSyncCommitteeBranch
|
||||
func (h *bootstrapCapella) CurrentSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return h.currentSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
func (h *bootstrapCapella) CurrentSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return [6][32]byte{}, consensustypes.ErrNotSupported("CurrentSyncCommitteeBranchElectra", version.Capella)
|
||||
}
|
||||
|
||||
type bootstrapDeneb struct {
|
||||
@@ -203,6 +213,74 @@ func (h *bootstrapDeneb) CurrentSyncCommittee() *pb.SyncCommittee {
|
||||
return h.p.CurrentSyncCommittee
|
||||
}
|
||||
|
||||
func (h *bootstrapDeneb) CurrentSyncCommitteeBranch() interfaces.LightClientSyncCommitteeBranch {
|
||||
return h.currentSyncCommitteeBranch
|
||||
func (h *bootstrapDeneb) CurrentSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return h.currentSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
func (h *bootstrapDeneb) CurrentSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return [6][32]byte{}, consensustypes.ErrNotSupported("CurrentSyncCommitteeBranchElectra", version.Deneb)
|
||||
}
|
||||
|
||||
type bootstrapElectra struct {
|
||||
p *pb.LightClientBootstrapElectra
|
||||
header interfaces.LightClientHeader
|
||||
currentSyncCommitteeBranch interfaces.LightClientSyncCommitteeBranchElectra
|
||||
}
|
||||
|
||||
var _ interfaces.LightClientBootstrap = &bootstrapElectra{}
|
||||
|
||||
func NewWrappedBootstrapElectra(p *pb.LightClientBootstrapElectra) (interfaces.LightClientBootstrap, error) {
|
||||
if p == nil {
|
||||
return nil, consensustypes.ErrNilObjectWrapped
|
||||
}
|
||||
header, err := NewWrappedHeaderDeneb(p.Header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
branch, err := createBranch[interfaces.LightClientSyncCommitteeBranchElectra](
|
||||
"sync committee",
|
||||
p.CurrentSyncCommitteeBranch,
|
||||
fieldparams.SyncCommitteeBranchDepthElectra,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &bootstrapElectra{
|
||||
p: p,
|
||||
header: header,
|
||||
currentSyncCommitteeBranch: branch,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
return h.p.MarshalSSZTo(dst)
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) MarshalSSZ() ([]byte, error) {
|
||||
return h.p.MarshalSSZ()
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) SizeSSZ() int {
|
||||
return h.p.SizeSSZ()
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) Version() int {
|
||||
return version.Electra
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) Header() interfaces.LightClientHeader {
|
||||
return h.header
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) CurrentSyncCommittee() *pb.SyncCommittee {
|
||||
return h.p.CurrentSyncCommittee
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) CurrentSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return [5][32]byte{}, consensustypes.ErrNotSupported("CurrentSyncCommitteeBranch", version.Electra)
|
||||
}
|
||||
|
||||
func (h *bootstrapElectra) CurrentSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return h.currentSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
@@ -100,8 +100,12 @@ func (u *updateAltair) NextSyncCommittee() *pb.SyncCommittee {
|
||||
return u.p.NextSyncCommittee
|
||||
}
|
||||
|
||||
func (u *updateAltair) NextSyncCommitteeBranch() interfaces.LightClientSyncCommitteeBranch {
|
||||
return u.nextSyncCommitteeBranch
|
||||
func (u *updateAltair) NextSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return u.nextSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
func (u *updateAltair) NextSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return [6][32]byte{}, consensustypes.ErrNotSupported("NextSyncCommitteeBranchElectra", version.Altair)
|
||||
}
|
||||
|
||||
func (u *updateAltair) FinalizedHeader() interfaces.LightClientHeader {
|
||||
@@ -192,8 +196,12 @@ func (u *updateCapella) NextSyncCommittee() *pb.SyncCommittee {
|
||||
return u.p.NextSyncCommittee
|
||||
}
|
||||
|
||||
func (u *updateCapella) NextSyncCommitteeBranch() interfaces.LightClientSyncCommitteeBranch {
|
||||
return u.nextSyncCommitteeBranch
|
||||
func (u *updateCapella) NextSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return u.nextSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
func (u *updateCapella) NextSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return [6][32]byte{}, consensustypes.ErrNotSupported("NextSyncCommitteeBranchElectra", version.Capella)
|
||||
}
|
||||
|
||||
func (u *updateCapella) FinalizedHeader() interfaces.LightClientHeader {
|
||||
@@ -284,8 +292,12 @@ func (u *updateDeneb) NextSyncCommittee() *pb.SyncCommittee {
|
||||
return u.p.NextSyncCommittee
|
||||
}
|
||||
|
||||
func (u *updateDeneb) NextSyncCommitteeBranch() interfaces.LightClientSyncCommitteeBranch {
|
||||
return u.nextSyncCommitteeBranch
|
||||
func (u *updateDeneb) NextSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return u.nextSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
func (u *updateDeneb) NextSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return [6][32]byte{}, consensustypes.ErrNotSupported("NextSyncCommitteeBranchElectra", version.Deneb)
|
||||
}
|
||||
|
||||
func (u *updateDeneb) FinalizedHeader() interfaces.LightClientHeader {
|
||||
@@ -303,3 +315,99 @@ func (u *updateDeneb) SyncAggregate() *pb.SyncAggregate {
|
||||
func (u *updateDeneb) SignatureSlot() primitives.Slot {
|
||||
return u.p.SignatureSlot
|
||||
}
|
||||
|
||||
type updateElectra struct {
|
||||
p *pb.LightClientUpdateElectra
|
||||
attestedHeader interfaces.LightClientHeader
|
||||
nextSyncCommitteeBranch interfaces.LightClientSyncCommitteeBranchElectra
|
||||
finalizedHeader interfaces.LightClientHeader
|
||||
finalityBranch interfaces.LightClientFinalityBranch
|
||||
}
|
||||
|
||||
var _ interfaces.LightClientUpdate = &updateElectra{}
|
||||
|
||||
func NewWrappedUpdateElectra(p *pb.LightClientUpdateElectra) (interfaces.LightClientUpdate, error) {
|
||||
if p == nil {
|
||||
return nil, consensustypes.ErrNilObjectWrapped
|
||||
}
|
||||
attestedHeader, err := NewWrappedHeaderDeneb(p.AttestedHeader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalizedHeader, err := NewWrappedHeaderDeneb(p.FinalizedHeader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
scBranch, err := createBranch[interfaces.LightClientSyncCommitteeBranchElectra](
|
||||
"sync committee",
|
||||
p.NextSyncCommitteeBranch,
|
||||
fieldparams.SyncCommitteeBranchDepthElectra,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalityBranch, err := createBranch[interfaces.LightClientFinalityBranch](
|
||||
"finality",
|
||||
p.FinalityBranch,
|
||||
fieldparams.FinalityBranchDepth,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &updateElectra{
|
||||
p: p,
|
||||
attestedHeader: attestedHeader,
|
||||
nextSyncCommitteeBranch: scBranch,
|
||||
finalizedHeader: finalizedHeader,
|
||||
finalityBranch: finalityBranch,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (u *updateElectra) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
return u.p.MarshalSSZTo(dst)
|
||||
}
|
||||
|
||||
func (u *updateElectra) MarshalSSZ() ([]byte, error) {
|
||||
return u.p.MarshalSSZ()
|
||||
}
|
||||
|
||||
func (u *updateElectra) SizeSSZ() int {
|
||||
return u.p.SizeSSZ()
|
||||
}
|
||||
|
||||
func (u *updateElectra) Version() int {
|
||||
return version.Electra
|
||||
}
|
||||
|
||||
func (u *updateElectra) AttestedHeader() interfaces.LightClientHeader {
|
||||
return u.attestedHeader
|
||||
}
|
||||
|
||||
func (u *updateElectra) NextSyncCommittee() *pb.SyncCommittee {
|
||||
return u.p.NextSyncCommittee
|
||||
}
|
||||
|
||||
func (u *updateElectra) NextSyncCommitteeBranch() (interfaces.LightClientSyncCommitteeBranch, error) {
|
||||
return [5][32]byte{}, consensustypes.ErrNotSupported("NextSyncCommitteeBranch", version.Electra)
|
||||
}
|
||||
|
||||
func (u *updateElectra) NextSyncCommitteeBranchElectra() (interfaces.LightClientSyncCommitteeBranchElectra, error) {
|
||||
return u.nextSyncCommitteeBranch, nil
|
||||
}
|
||||
|
||||
func (u *updateElectra) FinalizedHeader() interfaces.LightClientHeader {
|
||||
return u.finalizedHeader
|
||||
}
|
||||
|
||||
func (u *updateElectra) FinalityBranch() interfaces.LightClientFinalityBranch {
|
||||
return u.finalityBranch
|
||||
}
|
||||
|
||||
func (u *updateElectra) SyncAggregate() *pb.SyncAggregate {
|
||||
return u.p.SyncAggregate
|
||||
}
|
||||
|
||||
func (u *updateElectra) SignatureSlot() primitives.Slot {
|
||||
return u.p.SignatureSlot
|
||||
}
|
||||
|
||||
@@ -159,6 +159,8 @@ ssz_electra_objs = [
|
||||
"BlindedBeaconBlockElectra",
|
||||
"Consolidation",
|
||||
"IndexedAttestationElectra",
|
||||
"LightClientBootstrapElectra",
|
||||
"LightClientUpdateElectra",
|
||||
"PendingDeposit",
|
||||
"PendingDeposits",
|
||||
"PendingConsolidation",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 3a2dbf56ebf4e81fbf961840a4cd2addac9047b17c12bad04e60879df5b69277
|
||||
// Hash: 5ca1c2c4e61b47b1f8185b3e9c477ae280f82e1483b88d4e11fa214452da5117
|
||||
package eth
|
||||
|
||||
import (
|
||||
@@ -4252,3 +4252,409 @@ func (p *PendingConsolidation) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the LightClientBootstrapElectra object
|
||||
func (l *LightClientBootstrapElectra) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(l)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the LightClientBootstrapElectra object to a target array
|
||||
func (l *LightClientBootstrapElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(24820)
|
||||
|
||||
// Offset (0) 'Header'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
if l.Header == nil {
|
||||
l.Header = new(LightClientHeaderDeneb)
|
||||
}
|
||||
offset += l.Header.SizeSSZ()
|
||||
|
||||
// Field (1) 'CurrentSyncCommittee'
|
||||
if l.CurrentSyncCommittee == nil {
|
||||
l.CurrentSyncCommittee = new(SyncCommittee)
|
||||
}
|
||||
if dst, err = l.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (2) 'CurrentSyncCommitteeBranch'
|
||||
if size := len(l.CurrentSyncCommitteeBranch); size != 6 {
|
||||
err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 6)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < 6; ii++ {
|
||||
if size := len(l.CurrentSyncCommitteeBranch[ii]); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.CurrentSyncCommitteeBranch[ii]", size, 32)
|
||||
return
|
||||
}
|
||||
dst = append(dst, l.CurrentSyncCommitteeBranch[ii]...)
|
||||
}
|
||||
|
||||
// Field (0) 'Header'
|
||||
if dst, err = l.Header.MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the LightClientBootstrapElectra object
|
||||
func (l *LightClientBootstrapElectra) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 24820 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o0 uint64
|
||||
|
||||
// Offset (0) 'Header'
|
||||
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
if o0 != 24820 {
|
||||
return ssz.ErrInvalidVariableOffset
|
||||
}
|
||||
|
||||
// Field (1) 'CurrentSyncCommittee'
|
||||
if l.CurrentSyncCommittee == nil {
|
||||
l.CurrentSyncCommittee = new(SyncCommittee)
|
||||
}
|
||||
if err = l.CurrentSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Field (2) 'CurrentSyncCommitteeBranch'
|
||||
l.CurrentSyncCommitteeBranch = make([][]byte, 6)
|
||||
for ii := 0; ii < 6; ii++ {
|
||||
if cap(l.CurrentSyncCommitteeBranch[ii]) == 0 {
|
||||
l.CurrentSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24820][ii*32:(ii+1)*32]))
|
||||
}
|
||||
l.CurrentSyncCommitteeBranch[ii] = append(l.CurrentSyncCommitteeBranch[ii], buf[24628:24820][ii*32:(ii+1)*32]...)
|
||||
}
|
||||
|
||||
// Field (0) 'Header'
|
||||
{
|
||||
buf = tail[o0:]
|
||||
if l.Header == nil {
|
||||
l.Header = new(LightClientHeaderDeneb)
|
||||
}
|
||||
if err = l.Header.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the LightClientBootstrapElectra object
|
||||
func (l *LightClientBootstrapElectra) SizeSSZ() (size int) {
|
||||
size = 24820
|
||||
|
||||
// Field (0) 'Header'
|
||||
if l.Header == nil {
|
||||
l.Header = new(LightClientHeaderDeneb)
|
||||
}
|
||||
size += l.Header.SizeSSZ()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the LightClientBootstrapElectra object
|
||||
func (l *LightClientBootstrapElectra) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(l)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the LightClientBootstrapElectra object with a hasher
|
||||
func (l *LightClientBootstrapElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'Header'
|
||||
if err = l.Header.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (1) 'CurrentSyncCommittee'
|
||||
if err = l.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (2) 'CurrentSyncCommitteeBranch'
|
||||
{
|
||||
if size := len(l.CurrentSyncCommitteeBranch); size != 6 {
|
||||
err = ssz.ErrVectorLengthFn("--.CurrentSyncCommitteeBranch", size, 6)
|
||||
return
|
||||
}
|
||||
subIndx := hh.Index()
|
||||
for _, i := range l.CurrentSyncCommitteeBranch {
|
||||
if len(i) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.Append(i)
|
||||
}
|
||||
hh.Merkleize(subIndx)
|
||||
}
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the LightClientUpdateElectra object
|
||||
func (l *LightClientUpdateElectra) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(l)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the LightClientUpdateElectra object to a target array
|
||||
func (l *LightClientUpdateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(25184)
|
||||
|
||||
// Offset (0) 'AttestedHeader'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
if l.AttestedHeader == nil {
|
||||
l.AttestedHeader = new(LightClientHeaderDeneb)
|
||||
}
|
||||
offset += l.AttestedHeader.SizeSSZ()
|
||||
|
||||
// Field (1) 'NextSyncCommittee'
|
||||
if l.NextSyncCommittee == nil {
|
||||
l.NextSyncCommittee = new(SyncCommittee)
|
||||
}
|
||||
if dst, err = l.NextSyncCommittee.MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (2) 'NextSyncCommitteeBranch'
|
||||
if size := len(l.NextSyncCommitteeBranch); size != 6 {
|
||||
err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 6)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < 6; ii++ {
|
||||
if size := len(l.NextSyncCommitteeBranch[ii]); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.NextSyncCommitteeBranch[ii]", size, 32)
|
||||
return
|
||||
}
|
||||
dst = append(dst, l.NextSyncCommitteeBranch[ii]...)
|
||||
}
|
||||
|
||||
// Offset (3) 'FinalizedHeader'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
if l.FinalizedHeader == nil {
|
||||
l.FinalizedHeader = new(LightClientHeaderDeneb)
|
||||
}
|
||||
offset += l.FinalizedHeader.SizeSSZ()
|
||||
|
||||
// Field (4) 'FinalityBranch'
|
||||
if size := len(l.FinalityBranch); size != 6 {
|
||||
err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < 6; ii++ {
|
||||
if size := len(l.FinalityBranch[ii]); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.FinalityBranch[ii]", size, 32)
|
||||
return
|
||||
}
|
||||
dst = append(dst, l.FinalityBranch[ii]...)
|
||||
}
|
||||
|
||||
// Field (5) 'SyncAggregate'
|
||||
if l.SyncAggregate == nil {
|
||||
l.SyncAggregate = new(SyncAggregate)
|
||||
}
|
||||
if dst, err = l.SyncAggregate.MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (6) 'SignatureSlot'
|
||||
dst = ssz.MarshalUint64(dst, uint64(l.SignatureSlot))
|
||||
|
||||
// Field (0) 'AttestedHeader'
|
||||
if dst, err = l.AttestedHeader.MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (3) 'FinalizedHeader'
|
||||
if dst, err = l.FinalizedHeader.MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the LightClientUpdateElectra object
|
||||
func (l *LightClientUpdateElectra) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 25184 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o0, o3 uint64
|
||||
|
||||
// Offset (0) 'AttestedHeader'
|
||||
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
if o0 != 25184 {
|
||||
return ssz.ErrInvalidVariableOffset
|
||||
}
|
||||
|
||||
// Field (1) 'NextSyncCommittee'
|
||||
if l.NextSyncCommittee == nil {
|
||||
l.NextSyncCommittee = new(SyncCommittee)
|
||||
}
|
||||
if err = l.NextSyncCommittee.UnmarshalSSZ(buf[4:24628]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Field (2) 'NextSyncCommitteeBranch'
|
||||
l.NextSyncCommitteeBranch = make([][]byte, 6)
|
||||
for ii := 0; ii < 6; ii++ {
|
||||
if cap(l.NextSyncCommitteeBranch[ii]) == 0 {
|
||||
l.NextSyncCommitteeBranch[ii] = make([]byte, 0, len(buf[24628:24820][ii*32:(ii+1)*32]))
|
||||
}
|
||||
l.NextSyncCommitteeBranch[ii] = append(l.NextSyncCommitteeBranch[ii], buf[24628:24820][ii*32:(ii+1)*32]...)
|
||||
}
|
||||
|
||||
// Offset (3) 'FinalizedHeader'
|
||||
if o3 = ssz.ReadOffset(buf[24820:24824]); o3 > size || o0 > o3 {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
// Field (4) 'FinalityBranch'
|
||||
l.FinalityBranch = make([][]byte, 6)
|
||||
for ii := 0; ii < 6; ii++ {
|
||||
if cap(l.FinalityBranch[ii]) == 0 {
|
||||
l.FinalityBranch[ii] = make([]byte, 0, len(buf[24824:25016][ii*32:(ii+1)*32]))
|
||||
}
|
||||
l.FinalityBranch[ii] = append(l.FinalityBranch[ii], buf[24824:25016][ii*32:(ii+1)*32]...)
|
||||
}
|
||||
|
||||
// Field (5) 'SyncAggregate'
|
||||
if l.SyncAggregate == nil {
|
||||
l.SyncAggregate = new(SyncAggregate)
|
||||
}
|
||||
if err = l.SyncAggregate.UnmarshalSSZ(buf[25016:25176]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Field (6) 'SignatureSlot'
|
||||
l.SignatureSlot = github_com_prysmaticlabs_prysm_v5_consensus_types_primitives.Slot(ssz.UnmarshallUint64(buf[25176:25184]))
|
||||
|
||||
// Field (0) 'AttestedHeader'
|
||||
{
|
||||
buf = tail[o0:o3]
|
||||
if l.AttestedHeader == nil {
|
||||
l.AttestedHeader = new(LightClientHeaderDeneb)
|
||||
}
|
||||
if err = l.AttestedHeader.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Field (3) 'FinalizedHeader'
|
||||
{
|
||||
buf = tail[o3:]
|
||||
if l.FinalizedHeader == nil {
|
||||
l.FinalizedHeader = new(LightClientHeaderDeneb)
|
||||
}
|
||||
if err = l.FinalizedHeader.UnmarshalSSZ(buf); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the LightClientUpdateElectra object
|
||||
func (l *LightClientUpdateElectra) SizeSSZ() (size int) {
|
||||
size = 25184
|
||||
|
||||
// Field (0) 'AttestedHeader'
|
||||
if l.AttestedHeader == nil {
|
||||
l.AttestedHeader = new(LightClientHeaderDeneb)
|
||||
}
|
||||
size += l.AttestedHeader.SizeSSZ()
|
||||
|
||||
// Field (3) 'FinalizedHeader'
|
||||
if l.FinalizedHeader == nil {
|
||||
l.FinalizedHeader = new(LightClientHeaderDeneb)
|
||||
}
|
||||
size += l.FinalizedHeader.SizeSSZ()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the LightClientUpdateElectra object
|
||||
func (l *LightClientUpdateElectra) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(l)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the LightClientUpdateElectra object with a hasher
|
||||
func (l *LightClientUpdateElectra) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'AttestedHeader'
|
||||
if err = l.AttestedHeader.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (1) 'NextSyncCommittee'
|
||||
if err = l.NextSyncCommittee.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (2) 'NextSyncCommitteeBranch'
|
||||
{
|
||||
if size := len(l.NextSyncCommitteeBranch); size != 6 {
|
||||
err = ssz.ErrVectorLengthFn("--.NextSyncCommitteeBranch", size, 6)
|
||||
return
|
||||
}
|
||||
subIndx := hh.Index()
|
||||
for _, i := range l.NextSyncCommitteeBranch {
|
||||
if len(i) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.Append(i)
|
||||
}
|
||||
hh.Merkleize(subIndx)
|
||||
}
|
||||
|
||||
// Field (3) 'FinalizedHeader'
|
||||
if err = l.FinalizedHeader.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (4) 'FinalityBranch'
|
||||
{
|
||||
if size := len(l.FinalityBranch); size != 6 {
|
||||
err = ssz.ErrVectorLengthFn("--.FinalityBranch", size, 6)
|
||||
return
|
||||
}
|
||||
subIndx := hh.Index()
|
||||
for _, i := range l.FinalityBranch {
|
||||
if len(i) != 32 {
|
||||
err = ssz.ErrBytesLength
|
||||
return
|
||||
}
|
||||
hh.Append(i)
|
||||
}
|
||||
hh.Merkleize(subIndx)
|
||||
}
|
||||
|
||||
// Field (5) 'SyncAggregate'
|
||||
if err = l.SyncAggregate.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (6) 'SignatureSlot'
|
||||
hh.PutUint64(uint64(l.SignatureSlot))
|
||||
|
||||
hh.Merkleize(indx)
|
||||
return
|
||||
}
|
||||
|
||||
714
proto/prysm/v1alpha1/light_client.pb.go
generated
714
proto/prysm/v1alpha1/light_client.pb.go
generated
File diff suppressed because it is too large
Load Diff
@@ -61,6 +61,12 @@ message LightClientBootstrapDeneb {
|
||||
repeated bytes current_sync_committee_branch = 3 [(ethereum.eth.ext.ssz_size) = "5,32"];
|
||||
}
|
||||
|
||||
message LightClientBootstrapElectra {
|
||||
LightClientHeaderDeneb header = 1;
|
||||
SyncCommittee current_sync_committee = 2;
|
||||
repeated bytes current_sync_committee_branch = 3 [(ethereum.eth.ext.ssz_size) = "6,32"];
|
||||
}
|
||||
|
||||
message LightClientUpdateAltair {
|
||||
LightClientHeaderAltair attested_header = 1;
|
||||
SyncCommittee next_sync_committee = 2;
|
||||
@@ -91,6 +97,16 @@ message LightClientUpdateDeneb {
|
||||
uint64 signature_slot = 7 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
}
|
||||
|
||||
message LightClientUpdateElectra {
|
||||
LightClientHeaderDeneb attested_header = 1;
|
||||
SyncCommittee next_sync_committee = 2;
|
||||
repeated bytes next_sync_committee_branch = 3 [(ethereum.eth.ext.ssz_size) = "6,32"];
|
||||
LightClientHeaderDeneb finalized_header = 4;
|
||||
repeated bytes finality_branch = 5 [(ethereum.eth.ext.ssz_size) = "6,32"];
|
||||
SyncAggregate sync_aggregate = 6;
|
||||
uint64 signature_slot = 7 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives.Slot"];
|
||||
}
|
||||
|
||||
message LightClientFinalityUpdateAltair {
|
||||
LightClientHeaderAltair attested_header = 1;
|
||||
LightClientHeaderAltair finalized_header = 2;
|
||||
|
||||
Reference in New Issue
Block a user