-
Notifications
You must be signed in to change notification settings - Fork 999
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
LC Updates by Range to read from DB #14531
base: epf-light-client
Are you sure you want to change the base?
Changes from all commits
47fe2d3
b446e03
03fa1e2
5689d45
454bcd7
dedfacb
64d978b
b1831ca
3bef6f5
aff629f
2f16a91
5caba41
4866873
e240505
2c4ea0b
e728c22
ccd5106
9dab7a9
3832d95
60f0591
7427c30
a0a2af2
1a8f20c
52f37ec
0e7deff
3144e3f
fec1678
497c50a
c1d525b
2300bf9
f8cb14c
36256e6
172a96a
c9c4f46
c9fedf1
4ab398f
ba64324
692f827
3db34bd
ad95732
ba1fac4
59e9acd
03fd48c
9c5baed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,7 +159,7 @@ func NewLightClientUpdateFromBeaconState( | |
updateAttestedPeriod := slots.SyncCommitteePeriod(slots.ToEpoch(attestedBlock.Block().Slot())) | ||
|
||
// update = LightClientUpdate() | ||
result, err := createDefaultLightClientUpdate(currentSlot) | ||
result, err := CreateDefaultLightClientUpdate(currentSlot) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "could not create default light client update") | ||
} | ||
|
@@ -243,7 +243,7 @@ func NewLightClientUpdateFromBeaconState( | |
return result, nil | ||
} | ||
|
||
func createDefaultLightClientUpdate(currentSlot primitives.Slot) (interfaces.LightClientUpdate, error) { | ||
func CreateDefaultLightClientUpdate(currentSlot primitives.Slot) (interfaces.LightClientUpdate, error) { | ||
currentEpoch := slots.ToEpoch(currentSlot) | ||
|
||
syncCommitteeSize := params.BeaconConfig().SyncCommitteeSize | ||
|
@@ -278,24 +278,40 @@ func createDefaultLightClientUpdate(currentSlot primitives.Slot) (interfaces.Lig | |
var m proto.Message | ||
if currentEpoch < params.BeaconConfig().CapellaForkEpoch { | ||
m = &pb.LightClientUpdateAltair{ | ||
AttestedHeader: &pb.LightClientHeaderAltair{}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an empty header here. because the |
||
NextSyncCommittee: nextSyncCommittee, | ||
NextSyncCommitteeBranch: nextSyncCommitteeBranch, | ||
FinalityBranch: finalityBranch, | ||
} | ||
} else if currentEpoch < params.BeaconConfig().DenebForkEpoch { | ||
m = &pb.LightClientUpdateCapella{ | ||
AttestedHeader: &pb.LightClientHeaderCapella{ | ||
Beacon: &pb.BeaconBlockHeader{}, | ||
Execution: &enginev1.ExecutionPayloadHeaderCapella{}, | ||
ExecutionBranch: executionBranch, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above. |
||
NextSyncCommittee: nextSyncCommittee, | ||
NextSyncCommitteeBranch: nextSyncCommitteeBranch, | ||
FinalityBranch: finalityBranch, | ||
} | ||
} else if currentEpoch < params.BeaconConfig().ElectraForkEpoch { | ||
m = &pb.LightClientUpdateDeneb{ | ||
AttestedHeader: &pb.LightClientHeaderDeneb{ | ||
Beacon: &pb.BeaconBlockHeader{}, | ||
Execution: &enginev1.ExecutionPayloadHeaderDeneb{}, | ||
ExecutionBranch: executionBranch, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
NextSyncCommittee: nextSyncCommittee, | ||
NextSyncCommitteeBranch: nextSyncCommitteeBranch, | ||
FinalityBranch: finalityBranch, | ||
} | ||
} else { | ||
m = &pb.LightClientUpdateElectra{ | ||
AttestedHeader: &pb.LightClientHeaderDeneb{ | ||
Beacon: &pb.BeaconBlockHeader{}, | ||
Execution: &enginev1.ExecutionPayloadHeaderDeneb{}, | ||
ExecutionBranch: executionBranch, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
NextSyncCommittee: nextSyncCommittee, | ||
NextSyncCommitteeBranch: nextSyncCommitteeBranch, | ||
FinalityBranch: finalityBranch, | ||
|
@@ -372,15 +388,18 @@ func BlockToLightClientHeader( | |
var payloadProof [][]byte | ||
|
||
if blockEpoch < params.BeaconConfig().CapellaForkEpoch { | ||
var ok bool | ||
|
||
p, err := execution.EmptyExecutionPayload(version.Capella) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "could not get payload header") | ||
} | ||
payloadHeader, ok = p.(*enginev1.ExecutionPayloadHeaderCapella) | ||
if !ok { | ||
return nil, errors.Wrapf(err, "payload header type %T is not %T", payloadHeader, &enginev1.ExecutionPayloadHeaderCapella{}) | ||
payloadHeader = &enginev1.ExecutionPayloadHeaderCapella{ | ||
ParentHash: make([]byte, fieldparams.RootLength), | ||
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength), | ||
StateRoot: make([]byte, fieldparams.RootLength), | ||
ReceiptsRoot: make([]byte, fieldparams.RootLength), | ||
LogsBloom: make([]byte, fieldparams.LogsBloomLength), | ||
PrevRandao: make([]byte, fieldparams.RootLength), | ||
ExtraData: make([]byte, 0), | ||
BaseFeePerGas: make([]byte, fieldparams.RootLength), | ||
BlockHash: make([]byte, fieldparams.RootLength), | ||
TransactionsRoot: make([]byte, fieldparams.RootLength), | ||
WithdrawalsRoot: make([]byte, fieldparams.RootLength), | ||
} | ||
Comment on lines
390
to
403
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest we implement the function if we need the |
||
payloadProof = emptyPayloadProof() | ||
} else { | ||
|
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.
Made this function public because it's useful in other places as well. specially in tests.