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

remove eip6110flag for validator index cache #14173

Merged
merged 13 commits into from
Jul 22, 2024
Merged

Conversation

james-prysm
Copy link
Contributor

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

@james-prysm james-prysm requested a review from a team as a code owner July 2, 2024 18:14
@@ -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 {
Copy link
Contributor Author

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?

@james-prysm james-prysm added Electra electra hardfork Ready For Review A pull request ready for code review labels Jul 2, 2024
@@ -761,6 +762,8 @@ func InitializeFromProtoUnsafeElectra(st *ethpb.BeaconStateElectra) (state.Beaco
valMapHandler: stateutil.NewValMapHandler(st.Validators),
}

b.SaveValidatorIndices()
Copy link
Contributor Author

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?

@prestonvanloon
Copy link
Member

Do you need the feature flag for testing?

Consider renaming the flag if the justification is that other eip features use ValidatorByPubkey

@james-prysm
Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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 {
Copy link
Contributor

@rkapka rkapka Jul 12, 2024

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.

@james-prysm james-prysm requested a review from rkapka July 15, 2024 15:23
@james-prysm james-prysm added this pull request to the merge queue Jul 22, 2024
Merged via the queue into develop with commit aa868e5 Jul 22, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Electra electra hardfork Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants