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

Calculate max epoch and churn for slashings once #14990

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Feb 26, 2025

What type of PR is this?

Optimization

What does this PR do? Why is it needed?

When processing a slashing, we need to know the max exit epoch and the validator churn. The function that returns these values is MaxExitEpochAndChurn, which internally calls ReadFromEveryValidator on the state, which is an expensive operation. Currently we call MaxExitEpochAndChurn for every proposer slashing and every validator index of an attester slashing. It can get very expensive especially in the case of an attester slashing with many validators being slashed. Since MaxExitEpochAndChurn only requires the state, it can be called just once before any slashing processing.

Here is an image showing that processing slashings was very CPU intensive on Holesky

image

Acknowledgements

@rkapka rkapka requested a review from a team as a code owner February 26, 2025 15:58
@rkapka rkapka changed the title Calculate max epoch and churn for slashing once Calculate max epoch and churn for slashings once Feb 26, 2025
@rkapka rkapka force-pushed the fix-max-epoch-calculation-once branch from 153cab1 to 9a90cdb Compare February 26, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants