-
Notifications
You must be signed in to change notification settings - Fork 988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Light client consensus types #14512
base: develop
Are you sure you want to change the base?
Light client consensus types #14512
Conversation
header interfaces.LightClientHeader | ||
currentSyncCommitteeBranch interfaces.LightClientSyncCommitteeBranch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added fields for object that would have to be re-created every time the getter is called. That's one pointer to a wrapper with one pointer field for each header, and at most 6*32 bytes
for branches.
if len(p.CurrentSyncCommitteeBranch) != interfaces.SyncCommitteeBranchNumOfLeaves { | ||
return nil, fmt.Errorf( | ||
"sync committee branch has %d leaves instead of expected %d", | ||
len(p.CurrentSyncCommitteeBranch), | ||
interfaces.SyncCommitteeBranchNumOfLeaves, | ||
) | ||
} | ||
branch := interfaces.LightClientSyncCommitteeBranch{} | ||
for i, leaf := range p.CurrentSyncCommitteeBranch { | ||
if len(leaf) != fieldparams.RootLength { | ||
return nil, fmt.Errorf("sync committee branch leaf at index %d has length %d instead of expected %d", i, len(leaf), fieldparams.RootLength) | ||
} | ||
branch[i] = bytesutil.ToBytes32(leaf) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern appears many times, I will de-duplicate it in a future commit
ExecutionBranchNumOfLeaves = 4 | ||
SyncCommitteeBranchNumOfLeaves = 5 | ||
FinalityBranchNumOfLeaves = 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should probably move this to fieldparams
, rename NumOfLeaves
to Depth
and rename SyncCommitteeBranch
to NextSyncCommitteeBranch
for clarity.
What type of PR is this?
Other
What does this PR do? Why is it needed?
This PR creates a foundation for changing how we interact with light client types in the codebase. Currently we use protobuf-generated objects everywhere, but this has some problems:
LightClientHeader
is defined using aoneof
, which makes it impossible to generate SSZ for this type or any type referencing the header. Without this, we can't return SSZ-serialized objects from the Beacon API.This PR's design is largely influenced by https://github.com/prysmaticlabs/prysm/blob/develop/consensus-types/blocks/execution.go. Main components:
v1alpha1
with one type per fork instead of using aoneof
. The reason for having them inv1alpha1
is that it is the default directory for protobuf definitions. Theeth/v1
andeth/v2
directories are an artifact of some previous work and should be removed ultimately.ssz.Marshaler
interface:LightClientHeader
LightClientBootstrap
LightClientUpdate
LightClientFinalityUpdate
LightClientOptimisticUpdate
Which issues(s) does this PR fix?
Part of #12991
Acknowledgements