-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
feat: load state from Uint8Array #6057
Conversation
Performance Report✔️ no performance regression detected Full benchmark results
|
This reverts commit a420c54.
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.
Generally look good! Some minor comments
const currentShufflingDecisionBlock = getShufflingDecisionBlock(state, currentEpoch); | ||
const currentShufflingIn = opts?.shufflingGetter?.(currentEpoch, currentShufflingDecisionBlock); | ||
const nextShufflingDecisionBlock = getShufflingDecisionBlock(state, nextEpoch); | ||
const nextShufflingIn = opts?.shufflingGetter?.(nextEpoch, nextShufflingDecisionBlock); |
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.
What does the In
suffix mean? Can you comment above this block detailing the rationale and purpose of these lines?
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.
those are shufflings comeing from ShufflingCache
provided by BeaconChain. Will refactor to cachedNextShuffling
and add more comments 👍
seedValidator: CompositeViewDU<typeof ssz.phase0.Validator>, | ||
newValidatorBytes: Uint8Array | ||
): CompositeViewDU<typeof ssz.phase0.Validator> { | ||
if (isSameValidator(seedValidator, newValidatorBytes)) { |
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.
Extend this checks for the 3 cases: same pk, same withdrawals_creds, and same pk + same withdrawals_creds
* ✔ byteArrayEquals 123687377 3.077884 ops/s 324.8985 ms/op - 1 runs 64.5 s | ||
* ✔ Buffer.compare 123687377 114.7834 ops/s 8.712061 ms/op - 13 runs 12.1 s | ||
*/ | ||
describe("compare Uint8Array", () => { |
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.
You should extend this comparision tests to various checks:
- compare equal byte arrays
- compare byte arrays different at all bytes (2 rand arrays)
- compare byte arrays different only on the last byte
for (let i = 0; i < validatorCount; i++) { | ||
const validator = validators[i]; | ||
|
||
// Note: Not usable for fork-choice balances since in-active validators are not zero'ed | ||
effectiveBalanceIncrements[i] = Math.floor(validator.effectiveBalance / EFFECTIVE_BALANCE_INCREMENT); | ||
|
||
if (isActiveValidator(validator, previousEpoch)) { | ||
if (previousShufflingIn == null && isActiveValidator(validator, previousEpoch)) { |
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 detail more the motivation of this change?
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.
Looks good! Let's heavy test on the next PR round
@naviechan will coordinate with you on #6042 |
🎉 This PR is included in v1.12.0 🎉 |
Motivation
Description
loadValidators()
api which use the samevalidators
tree of seed state and return modified validators. This comes from the fact that validators are rarely changedinactivityScores
are rarely changed as monitored on mainnetloadCachedBeaconState()
api which callloadState()
and update modified validators to the pubkey cachepart of #5968
TODO: coordinate with #6042