Skip to content

Commit

Permalink
Update light-client consensus types (#14652)
Browse files Browse the repository at this point in the history
* update diff

* deps

* changelog

* remove `SetNextSyncCommitteeBranchElectra`
  • Loading branch information
rupam-04 authored Nov 21, 2024
1 parent c285715 commit 956d9d1
Show file tree
Hide file tree
Showing 11 changed files with 691 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Non-blocking payload attribute event handling in beacon api [pr](https://github.com/prysmaticlabs/prysm/pull/14644).
- Updated light client protobufs. [PR](https://github.com/prysmaticlabs/prysm/pull/14650)
- Added `Eth-Consensus-Version` header to `ListAttestationsV2` and `GetAggregateAttestationV2` endpoints.
- Updated light client consensus types. [PR](https://github.com/prysmaticlabs/prysm/pull/14652)

### Deprecated

Expand Down
1 change: 1 addition & 0 deletions config/fieldparams/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
SyncCommitteeBranchDepth = 5 // SyncCommitteeBranchDepth defines the number of leaves in a merkle proof of a sync committee.
SyncCommitteeBranchDepthElectra = 6 // SyncCommitteeBranchDepthElectra defines the number of leaves in a merkle proof of a sync committee.
FinalityBranchDepth = 6 // FinalityBranchDepth defines the number of leaves in a merkle proof of the finalized checkpoint root.
FinalityBranchDepthElectra = 7 // FinalityBranchDepthElectra defines the number of leaves in a merkle proof of the finalized checkpoint root.
PendingDepositsLimit = 134217728 // Maximum number of pending balance deposits in the beacon state.
PendingPartialWithdrawalsLimit = 134217728 // Maximum number of pending partial withdrawals in the beacon state.
PendingConsolidationsLimit = 262144 // Maximum number of pending consolidations in the beacon state.
Expand Down
1 change: 1 addition & 0 deletions config/fieldparams/minimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
SyncCommitteeBranchDepth = 5 // SyncCommitteeBranchDepth defines the number of leaves in a merkle proof of a sync committee.
SyncCommitteeBranchDepthElectra = 6 // SyncCommitteeBranchDepthElectra defines the number of leaves in a merkle proof of a sync committee.
FinalityBranchDepth = 6 // FinalityBranchDepth defines the number of leaves in a merkle proof of the finalized checkpoint root.
FinalityBranchDepthElectra = 7 // FinalityBranchDepthElectra defines the number of leaves in a merkle proof of the finalized checkpoint root.
PendingDepositsLimit = 134217728 // Maximum number of pending balance deposits in the beacon state.
PendingPartialWithdrawalsLimit = 64 // Maximum number of pending partial withdrawals in the beacon state.
PendingConsolidationsLimit = 64 // Maximum number of pending consolidations in the beacon state.
Expand Down
19 changes: 17 additions & 2 deletions consensus-types/interfaces/light_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import (
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
pb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
"google.golang.org/protobuf/proto"
)

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 LightClientFinalityBranchElectra = [fieldparams.FinalityBranchDepthElectra][fieldparams.RootLength]byte

type LightClientHeader interface {
ssz.Marshaler
Proto() proto.Message
Version() int
Beacon() *pb.BeaconBlockHeader
Execution() (ExecutionData, error)
Expand All @@ -31,29 +34,41 @@ type LightClientBootstrap interface {

type LightClientUpdate interface {
ssz.Marshaler
Proto() proto.Message
Version() int
AttestedHeader() LightClientHeader
SetAttestedHeader(header LightClientHeader) error
NextSyncCommittee() *pb.SyncCommittee
SetNextSyncCommittee(sc *pb.SyncCommittee)
NextSyncCommitteeBranch() (LightClientSyncCommitteeBranch, error)
SetNextSyncCommitteeBranch(branch [][]byte) error
NextSyncCommitteeBranchElectra() (LightClientSyncCommitteeBranchElectra, error)
FinalizedHeader() LightClientHeader
FinalityBranch() LightClientFinalityBranch
SetFinalizedHeader(header LightClientHeader) error
FinalityBranch() (LightClientFinalityBranch, error)
FinalityBranchElectra() (LightClientFinalityBranchElectra, error)
SetFinalityBranch(branch [][]byte) error
SyncAggregate() *pb.SyncAggregate
SetSyncAggregate(sa *pb.SyncAggregate)
SignatureSlot() primitives.Slot
SetSignatureSlot(slot primitives.Slot)
}

type LightClientFinalityUpdate interface {
ssz.Marshaler
Proto() proto.Message
Version() int
AttestedHeader() LightClientHeader
FinalizedHeader() LightClientHeader
FinalityBranch() LightClientFinalityBranch
FinalityBranch() (LightClientFinalityBranch, error)
FinalityBranchElectra() (LightClientFinalityBranchElectra, error)
SyncAggregate() *pb.SyncAggregate
SignatureSlot() primitives.Slot
}

type LightClientOptimisticUpdate interface {
ssz.Marshaler
Proto() proto.Message
Version() int
AttestedHeader() LightClientHeader
SyncAggregate() *pb.SyncAggregate
Expand Down
2 changes: 2 additions & 0 deletions consensus-types/light-client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
"//consensus-types:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//consensus-types/primitives:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//runtime/version:go_default_library",
"//time/slots:go_default_library",
"@org_golang_google_protobuf//proto:go_default_library",
],
)
8 changes: 4 additions & 4 deletions consensus-types/light-client/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewWrappedBootstrapAltair(p *pb.LightClientBootstrapAltair) (interfaces.Lig
if p == nil {
return nil, consensustypes.ErrNilObjectWrapped
}
header, err := NewWrappedHeaderAltair(p.Header)
header, err := NewWrappedHeader(p.Header)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func NewWrappedBootstrapCapella(p *pb.LightClientBootstrapCapella) (interfaces.L
if p == nil {
return nil, consensustypes.ErrNilObjectWrapped
}
header, err := NewWrappedHeaderCapella(p.Header)
header, err := NewWrappedHeader(p.Header)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func NewWrappedBootstrapDeneb(p *pb.LightClientBootstrapDeneb) (interfaces.Light
if p == nil {
return nil, consensustypes.ErrNilObjectWrapped
}
header, err := NewWrappedHeaderDeneb(p.Header)
header, err := NewWrappedHeader(p.Header)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -233,7 +233,7 @@ func NewWrappedBootstrapElectra(p *pb.LightClientBootstrapElectra) (interfaces.L
if p == nil {
return nil, consensustypes.ErrNilObjectWrapped
}
header, err := NewWrappedHeaderDeneb(p.Header)
header, err := NewWrappedHeader(p.Header)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 956d9d1

Please sign in to comment.