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

Add cache to Eth1 RPC functions #5347

Merged
merged 9 commits into from Apr 9, 2020

Conversation

0xKiwi
Copy link
Contributor

@0xKiwi 0xKiwi commented Apr 8, 2020

Resolves #5340

This PR improves the RPC functions by adding a cache to both.

@0xKiwi 0xKiwi requested a review from a team as a code owner April 8, 2020 02:49
@@ -72,8 +80,9 @@ func (s *Service) BlockTimeByHeight(ctx context.Context, height *big.Int) (uint6
// This is a naive implementation that will use O(ETH1_FOLLOW_DISTANCE) calls to cache
// or ETH1. This is called for multiple times but only changes every
// SlotsPerEth1VotingPeriod (1024 slots) so the whole method should be cached.
// How should caching the whole method be done?
Copy link
Member

Choose a reason for hiding this comment

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

? do we need this comment

Copy link
Contributor Author

@0xKiwi 0xKiwi Apr 8, 2020

Choose a reason for hiding this comment

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

Just for personal tracking as I try to figure out whats needed, will remove before the PR is ready for review.

@@ -29,6 +29,8 @@ import (

// eth1DataNotification is a latch to stop flooding logs with the same warning.
var eth1DataNotification bool
var cachedEth1VotingStartTime uint64
var cachedEth1Data *ethpb.Eth1Data
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This caching is very simple, should we cache it on the beacon node side or is on the validator end fine?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be fine if it lives in the beacon node side, that way many validator clients connected to one beacon node can benefit

@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #5347 into master will increase coverage by 28.94%.
The diff coverage is 68.42%.

@@             Coverage Diff             @@
##           master    #5347       +/-   ##
===========================================
+ Coverage   12.56%   41.51%   +28.94%     
===========================================
  Files         112      233      +121     
  Lines        8740    19385    +10645     
===========================================
+ Hits         1098     8047     +6949     
- Misses       7454     9949     +2495     
- Partials      188     1389     +1201     

@0xKiwi 0xKiwi requested review from rauljordan and nisdas April 9, 2020 15:57
@0xKiwi 0xKiwi added the Ready For Review A pull request ready for code review label Apr 9, 2020
@rauljordan rauljordan merged commit 159ef3d into prysmaticlabs:master Apr 9, 2020
nisdas added a commit that referenced this pull request May 16, 2020
prylabs-bulldozer bot pushed a commit that referenced this pull request May 16, 2020
* Revert "Add cache to Eth1 RPC functions (#5347)"

This reverts commit 159ef3d.
michaelhly pushed a commit to michaelhly/prysm that referenced this pull request May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BlockFetcher RPC functions are inefficient
3 participants