-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
Cache and reuse old validator registration data if no params change #4447
Conversation
Performance Report✔️ no performance regression detected Full benchmark results
|
dd82d4e
to
ad96cfd
Compare
@@ -79,6 +80,8 @@ type ValidatorData = { | |||
*/ | |||
export class ValidatorStore { | |||
private readonly validators = new Map<PubkeyHex, ValidatorData>(); | |||
private readonly validatorRegistrationCache = new ValidatorRegistrationCache(); |
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.
Can you include a jsdoc comment here or on the class?
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.
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.
Why not add this inside ValidatorData
so it gets automatically pruned when removing validators?
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.
moved
fromHexString(feeRecipient), | ||
slot | ||
); | ||
return validatorStore.getValidatorRegistration(pubkeyHex, feeRecipient, slot); |
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.
the FB team requested not to create/send new registration objects unless params change.
@g11tech I still see we send every validator registration per epoch, is it expected?
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.
yes, they also only keep a registration for 2 epochs, so its recommended to refresh every epoch 👍
export class ValidatorRegistrationCache { | ||
private readonly validatorRegistrationMap = new Map< | ||
string, | ||
{validatorRegistration: bellatrix.SignedValidatorRegistrationV1; fullKey: string} |
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.
Add alias on type string such that
type PubkeyHex = string
/** `${feeRecipient}-${gasLimit}` */
type AttributesKey = string
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.
Since fullKey is nested by first level of pubkey, does it really need to include the pubkey?
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.
If you add this cache inside ValidatorData
you don't need the 2d Map. And then you can prune by number of attribute combinations which is what makes more sense. pubkeys are naturally bounded already
d8c06d3
to
45fab0b
Compare
Motivation
The FB team requested not to create/send new registration objects unless params change.
This PR caches the registration objects and reuses them to register them to builder.
Reference: