Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
47fe2d3
change updatebyrange
Inspector-Butters Oct 8, 2024
b446e03
lcupdateresponse from consensus
Inspector-Butters Oct 8, 2024
03fa1e2
Merge branch 'prysmaticlabs:develop' into updates-by-range
Inspector-Butters Oct 9, 2024
5689d45
range altair test
Inspector-Butters Oct 10, 2024
454bcd7
Merge branch 'prysmaticlabs:develop' into updates-by-range
Inspector-Butters Oct 13, 2024
dedfacb
range forks tests
Inspector-Butters Oct 13, 2024
64d978b
Merge branch 'prysmaticlabs:develop' into updates-by-range
Inspector-Butters Oct 14, 2024
b1831ca
finish tests
Inspector-Butters Oct 14, 2024
3bef6f5
changelog
Inspector-Butters Oct 14, 2024
aff629f
remove unused functions
Inspector-Butters Oct 14, 2024
2f16a91
Update beacon-chain/rpc/eth/light-client/handlers.go
Inspector-Butters Oct 14, 2024
5caba41
Update beacon-chain/rpc/eth/light-client/handlers.go
Inspector-Butters Oct 14, 2024
4866873
use slice instead of array
Inspector-Butters Oct 14, 2024
e240505
Merge branch 'develop' into updates-by-range
Inspector-Butters Oct 14, 2024
2c4ea0b
refactor code
Inspector-Butters Oct 15, 2024
e728c22
Merge branch 'develop' into updates-by-range
Inspector-Butters Oct 15, 2024
ccd5106
Merge branch 'develop' into updates-by-range
Inspector-Butters Oct 16, 2024
9dab7a9
refactor tests
Inspector-Butters Oct 16, 2024
3832d95
Merge branch 'develop' into updates-by-range
Inspector-Butters Oct 16, 2024
60f0591
Merge branch 'develop' into updates-by-range
Inspector-Butters Oct 17, 2024
7427c30
refactor tests
Inspector-Butters Oct 17, 2024
a0a2af2
refactor tests
Inspector-Butters Oct 17, 2024
1a8f20c
add configCleanup in tests
Inspector-Butters Oct 21, 2024
52f37ec
refactor missing updates testcase
Inspector-Butters Oct 21, 2024
0e7deff
Light Client - use the new consensus types (#14549)
rkapka Oct 21, 2024
3144e3f
Merge remote-tracking branch 'upstream/epf-light-client' into updates…
Inspector-Butters Oct 21, 2024
fec1678
change updatesByRange to use new structs
Inspector-Butters Oct 21, 2024
497c50a
Light Client - use the new consensus types (#14549)
rkapka Oct 21, 2024
c1d525b
Merge branch 'epf-light-client' into updates-by-range
Inspector-Butters Oct 22, 2024
2300bf9
fix rpc/helpers_test
Inspector-Butters Oct 22, 2024
f8cb14c
Return the correct light client payload proof (#14565)
rkapka Oct 22, 2024
36256e6
merge
Inspector-Butters Oct 23, 2024
172a96a
Merge remote-tracking branch 'upstream/epf-light-client' into updates…
Inspector-Butters Oct 23, 2024
c9c4f46
Set fields of wrapped proto object in light client setters (#14573)
rkapka Oct 23, 2024
c9fedf1
fixing tests...
Inspector-Butters Oct 23, 2024
4ab398f
Merge remote-tracking branch 'upstream/epf-light-client' into updates…
Inspector-Butters Oct 23, 2024
ba64324
core tests fixed
Inspector-Butters Oct 24, 2024
692f827
kv tests fixed
Inspector-Butters Oct 24, 2024
3db34bd
fix TODOs for events (#14570)
rupam-04 Oct 25, 2024
ad95732
Merge remote-tracking branch 'upstream/epf-light-client' into updates…
Inspector-Butters Oct 25, 2024
ba1fac4
tests fixed
Inspector-Butters Oct 25, 2024
59e9acd
remove unused function
Inspector-Butters Oct 25, 2024
03fd48c
fix slice capacity
Inspector-Butters Oct 25, 2024
9c5baed
Merge branch 'epf-light-client' into updates-by-range
Inspector-Butters Oct 26, 2024
df616fb
address issues
Inspector-Butters Oct 28, 2024
70d021b
address issues
Inspector-Butters Oct 28, 2024
04c4d3b
fix circular import error
Inspector-Butters Oct 28, 2024
43919eb
remove unused func
Inspector-Butters Oct 28, 2024
d402dd1
fix changelog
Inspector-Butters Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions beacon-chain/core/light-client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ go_test(
"//consensus-types/blocks:go_default_library",
"//encoding/ssz:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//testing/require:go_default_library",
"//testing/util:go_default_library",
"@com_github_pkg_errors//:go_default_library",
Expand Down
43 changes: 32 additions & 11 deletions beacon-chain/core/light-client/lightclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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) {
Inspector-Butters marked this conversation as resolved.
Show resolved Hide resolved
currentEpoch := slots.ToEpoch(currentSlot)

syncCommitteeSize := params.BeaconConfig().SyncCommitteeSize
Expand Down Expand Up @@ -278,24 +278,42 @@ func createDefaultLightClientUpdate(currentSlot primitives.Slot) (interfaces.Lig
var m proto.Message
if currentEpoch < params.BeaconConfig().CapellaForkEpoch {
m = &pb.LightClientUpdateAltair{
AttestedHeader: &pb.LightClientHeaderAltair{
Beacon: &pb.BeaconBlockHeader{},
},
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,
},
Inspector-Butters marked this conversation as resolved.
Show resolved Hide resolved
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,
},
Inspector-Butters marked this conversation as resolved.
Show resolved Hide resolved
NextSyncCommittee: nextSyncCommittee,
NextSyncCommitteeBranch: nextSyncCommitteeBranch,
FinalityBranch: finalityBranch,
}
} else {
m = &pb.LightClientUpdateElectra{
AttestedHeader: &pb.LightClientHeaderDeneb{
Beacon: &pb.BeaconBlockHeader{},
Execution: &enginev1.ExecutionPayloadHeaderDeneb{},
ExecutionBranch: executionBranch,
},
Inspector-Butters marked this conversation as resolved.
Show resolved Hide resolved
NextSyncCommittee: nextSyncCommittee,
NextSyncCommitteeBranch: nextSyncCommitteeBranch,
FinalityBranch: finalityBranch,
Expand Down Expand Up @@ -372,15 +390,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),
}
Inspector-Butters marked this conversation as resolved.
Show resolved Hide resolved
payloadProof = emptyPayloadProof()
} else {
Expand Down
302 changes: 166 additions & 136 deletions beacon-chain/core/light-client/lightclient_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions beacon-chain/db/kv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ go_test(
"//config/params:go_default_library",
"//consensus-types/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//consensus-types/light-client:go_default_library",
"//consensus-types/primitives:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/dbval:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/eth/v1:go_default_library",
"//proto/eth/v2:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/testing:go_default_library",
"//runtime/version:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"//testing/util:go_default_library",
"//time/slots:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_golang_snappy//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions beacon-chain/db/kv/lightclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func encodeLightClientUpdate(update interfaces.LightClientUpdate) ([]byte, error
return nil, errors.Wrap(err, "could not marshal light client update")
}
fullEnc := make([]byte, len(key)+len(enc))
copy(fullEnc, key)
copy(fullEnc[len(key):], enc)
Inspector-Butters marked this conversation as resolved.
Show resolved Hide resolved
return snappy.Encode(nil, fullEnc), nil
}
Expand Down
Loading
Loading