mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
**What type of PR is this?**
Bug fix
**What does this PR do? Why is it needed?**
In (electra) `ProcessEffectiveBalanceUpdates`, a `0x00...` validator
with a balance > 33.25 ETH enters in the
```go
if balance+downwardThreshold < val.EffectiveBalance() || val.EffectiveBalance()+upwardThreshold < balance {
...
}
```
condition.
The validator is copied (`newVal = val.Copy()`) and returned, **even if
the effective balance did not actually change**.
As a consequence, this validator is considered as "dirty" in the
validators field trie, and all the corresponding branches are
re-computed when computing the hash trie root of the the validators
field trie of the beacon state.
This PR adopts the same behavior as before Electra:
6f437b561a/beacon-chain/core/electra/effective_balance_updates.go (L32-L63)
and copies/considers dirty the validator only if its effective balance
changed.
**Which issues(s) does this PR fix?**
- https://github.com/OffchainLabs/prysm/issues/16630
**Other notes for review**
The first commit only introduces a new metric showing the issue.
The second commit actually solves the issue.
**Before this PR:**
**~9.400 validators** considered as dirty on mainnet every epoch
<img width="942" height="308" alt="image"
src="https://github.com/user-attachments/assets/31da9c92-aa0f-4d71-a402-92ed62738803"
/>
**After this PR:**
**~15 validators** considered as dirty on mainnet every epoch (reduction
of ~x620).
<img width="946" height="312" alt="image"
src="https://github.com/user-attachments/assets/afc5e72a-ccda-4636-87d9-dab2fbbf5c1c"
/>
**Acknowledgements**
- [x] I have read
[CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md).
- [x] I have included a uniquely named [changelog fragment
file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd).
- [x] I have added a description with sufficient context for reviewers
to understand this PR.
- [x] I have tested that my changes work as expected and I added a
testing plan to the PR description (if applicable).
---------
Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>