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

Open
wants to merge 44 commits into
base: epf-light-client
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 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
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Fix `engine_exchangeCapabilities` implementation.
- Updated the default `scrape-interval` in `Client-stats` to 2 minutes to accommodate Beaconcha.in API rate limits.
- Switch to compounding when consolidating with source==target.
- Changed `GetLightClientUpdatesByRange` API to read from the DB instead of computing.
- Revert block db save when saving state fails.
- Return false from HasBlock if the block is being synced.
- Cleanup forkchoice on failed insertions.
Expand All @@ -43,6 +44,9 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve

- Fixed mesh size by appending `gParams.Dhi = gossipSubDhi`
- Fix skipping partial withdrawals count.
- recover from panics when writing the event stream [pr](https://github.com/prysmaticlabs/prysm/pull/14545)
- Return the correct light client payload proof. [PR](https://github.com/prysmaticlabs/prysm/pull/14565)
- Set fields of wrapped proto object in light client setters. [PR](https://github.com/prysmaticlabs/prysm/pull/14573)
- wait for the async StreamEvent writer to exit before leaving the http handler, avoiding race condition panics [pr](https://github.com/prysmaticlabs/prysm/pull/14557)
- Certain deb files were returning a 404 which made building new docker images without an existing
cache impossible. This has been fixed with updates to rules_oci and bazel-lib.
Expand Down
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
41 changes: 30 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) {
Copy link
Contributor Author

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.

currentEpoch := slots.ToEpoch(currentSlot)

syncCommitteeSize := params.BeaconConfig().SyncCommitteeSize
Expand Down Expand Up @@ -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{},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an empty header here. because the return light_client.NewWrappedHeader(m) would throw an error otherwise.

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,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

NextSyncCommittee: nextSyncCommittee,
NextSyncCommitteeBranch: nextSyncCommitteeBranch,
FinalityBranch: finalityBranch,
Expand Down Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The execution.EmptyExecutionPayload(version.Capella) returns something that is different than enginev1.ExecutionPayloadHeaderCapella and it would throw an error when casting. so I just created one here. and it's only for this case.

Copy link
Contributor

@rupam-04 rupam-04 Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The execution.EmptyExecutionPayload(version.Capella) returns something that is different than enginev1.ExecutionPayloadHeaderCapella and it would throw an error when casting. so I just created one here. and it's only for this case.

The execution.EmptyExecutionPayload() function returns an empty payload, not the payload header. There's no function for the latter, but we can implement it. After that, a typecasting works fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we implement the function if we need the EmptyExecutionPayloadHeader somewhere else as well. for now it's only here and this code should do the trick.

payloadProof = emptyPayloadProof()
} else {
Expand Down
Loading
Loading