-
Notifications
You must be signed in to change notification settings - Fork 994
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
remove eip6110flag for validator index cache #14173
Conversation
@@ -179,7 +179,7 @@ func (b *BeaconState) ValidatorIndexByPubkey(key [fieldparams.BLSPubkeyLength]by | |||
b.lock.RLock() | |||
defer b.lock.RUnlock() | |||
|
|||
if features.Get().EIP6110ValidatorIndexCache { | |||
if b.Version() >= version.Electra { |
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 do we do about validatorMultiValue and the valMapHandler?
@@ -761,6 +762,8 @@ func InitializeFromProtoUnsafeElectra(st *ethpb.BeaconStateElectra) (state.Beaco | |||
valMapHandler: stateutil.NewValMapHandler(st.Validators), | |||
} | |||
|
|||
b.SaveValidatorIndices() |
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.
is this appropriate for initialization?
Do you need the feature flag for testing? Consider renaming the flag if the justification is that other eip features use ValidatorByPubkey |
I believe we actually need it now not behind a feature flag, asking the team for more thoughts and review |
stateFieldLeaves: make(map[types.FieldIndex]*fieldtrie.FieldTrie, fieldCount), | ||
rebuildTrie: make(map[types.FieldIndex]bool, fieldCount), | ||
valMapHandler: stateutil.NewValMapHandler(st.Validators), | ||
validatorIndexCache: newFinalizedValidatorIndexCache(), //only populates when finalizing, otherwise it falls back to validator set |
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.
Shouldn't you copy the comment to all other state types?
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.
Is this an electra specific behaviour?
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.
it's electra specific but i was afraid there might be panics if not initialized
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.
it's not Electra-specific, this field is present in all states
@@ -110,7 +109,7 @@ func (b *BeaconState) SetHistoricalRoots(val [][]byte) error { | |||
|
|||
// SaveValidatorIndices save validator indices of beacon chain to cache | |||
func (b *BeaconState) SaveValidatorIndices() { | |||
if !features.Get().EIP6110ValidatorIndexCache { | |||
if b != nil && b.Version() < version.Electra { |
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 b
is nil, the function will continue and panic at the next line. It should be b == nil ||
instead. Either way I think nil-checking receivers is too paranoid and actually harmful here. You should never call this method on a nil beacon state, so it's better just to panic and inform the developer that there is a bug here.
What type of PR is this?
Other
What does this PR do? Why is it needed?
because this cache is used for not only EIP6110 but also some others like 7521 we would like a way to use it out of the box without the need for a feature flag. longer term we need to revisit if we should solely depend on the cache or utilize the existing state features.
continuation of #14146
Which issues(s) does this PR fix?
Fixes #
Other notes for review