-
Notifications
You must be signed in to change notification settings - Fork 90
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
app/eth2wrap: implement and wire validator cache #2121
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2121 +/- ##
=======================================
Coverage ? 53.56%
=======================================
Files ? 174
Lines ? 22547
Branches ? 0
=======================================
Hits ? 12078
Misses ? 9014
Partials ? 1455
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
LGTM!
app/eth2wrap/httpwrap.go
Outdated
@@ -36,6 +37,34 @@ type NodePeerCountProvider interface { | |||
NodePeerCount(ctx context.Context) (int, error) | |||
} | |||
|
|||
type ActiveValidators map[eth2p0.ValidatorIndex]eth2p0.BLSPubKey |
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.
nit: missing godoc
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.
another nit: maybe this type should live in valcache.go
?
06af57b
to
bd93590
Compare
resp[val.Index] = val.Validator.PublicKey | ||
} | ||
|
||
c.active = resp |
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'd suggest to lock mutex around this (when c.active
is updated) and not above as we are calling eth2Cl
after locking mutex.
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.
no the point here is to lock while only one call to populate the cache is done
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.
Got it 👍
This is a second attempt at caching active validators. Instead of caching the
eth2client.ValidatorProvider
endpoints which return fullValidator
objects that are not actually immutable by epoch, rather implement a new set of client endpoint specifically for cached immutable active validators by current epoch that only return the validator index and pubkey which are immutable. The only race condition is the fact that we query this by "head", so could be for another slot that what we think is current, although this was already the case previously, so no new races are introdcued.This should significantly decrease BN load, especially if using the validatormock.
category: feature
ticket: #1396