Skip to content

Update committee cache#16814

Merged
nalepae merged 4 commits into
developfrom
commmittee-cache
Jun 2, 2026
Merged

Update committee cache#16814
nalepae merged 4 commits into
developfrom
commmittee-cache

Conversation

@nalepae

@nalepae nalepae commented May 18, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?
Bug fix

What does this PR do? Why is it needed?
Before this PR, ActiveValidatorIndices and ActiveValidatorCount updates the committee cache in a synchronous fashion before returning, even if these 2 functions do not depend on this cache update.

This leads to two issues:

  1. If the context of the caller is cancelled during the cache update, then the cache update stops and an error is logged (linked issue). Note that the context cancellation error does not bubble up to callers, so there is no other functional impact than cache update interruption and error logging.
  2. These 2 functions are blocked for no reason until the end of the cache update, leading to effectiveness reduction.

This PR updates the committee cache asynchronously in the ActiveValidatorIndices and ActiveValidatorCount functions, solving the points 1 and 2.

Note

Ideally, the context used in fillCommitteeCacheAsync should be the service context, to ensure fast stop in case of node shutdown. However, doing this would change a lot of signatures functions to pass down the context. We chose instead to use a background context with a timeout.

Note

Before this PR, committeeCache.ActiveIndicesCount and committeeCache.ActiveIndices where blocking if an update was already in progress. With this PR, these functions are not blocking any more, but the blocking feature is now moved into the only respective caller functions ActiveValidatorIndices and ActiveValidatorCount.

Which issues(s) does this PR fix?

Other notes for review
Vertical blue line is node restart.
Vertical red line is the Could not update committee cache error.

On the left: V7.1.4-rc.1 + this fix
On the right: V7.1.4-rc.1

image

Acknowledgements

  • I have read CONTRIBUTING.md.
  • I have included a uniquely named changelog fragment file.
  • I have added a description with sufficient context for reviewers to understand this PR.
  • I have tested that my changes work as expected and I added a testing plan to the PR description (if applicable).

@nalepae nalepae force-pushed the commmittee-cache branch 3 times, most recently from 0c6ffe9 to e6c9ce5 Compare May 19, 2026 08:12
@nalepae nalepae marked this pull request as ready for review May 19, 2026 09:10
pull Bot pushed a commit to Hawthorne001/prysm that referenced this pull request May 19, 2026
…OffchainLabs#16816)

**What type of PR is this?**
Bug fix

**What does this PR do? Why is it needed?**

**Which issues(s) does this PR fix?**
This PR workarounds this issue:
- OffchainLabs#16809

The real fix is in this PR:
- OffchainLabs#16814

**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).
@nalepae nalepae force-pushed the commmittee-cache branch from e6c9ce5 to 3d72cce Compare May 20, 2026 08:19
potuz
potuz previously approved these changes May 20, 2026

@potuz potuz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good to me, my worry here is the fact that we move to unshuffle in the background and it makes it hard to diagnose if we are doing unnecessary work or not. We are still diagnosing the underlying issue that prompted this PR.

Comment on lines -525 to -528
}); err != nil {
return err
}
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This previous pattern is a genius of modern computer science :)

Comment on lines +748 to +749
working := make([]primitives.ValidatorIndex, len(indices))
copy(working, indices)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use slices.Clone()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho nice! I did not even know this function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 958662c.

)

var (
CommitteeCacheInProgressHit = promauto.NewCounter(prometheus.CounterOpts{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have another metric to track contention?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in afe08ed.

@nalepae nalepae enabled auto-merge June 2, 2026 12:23
@nalepae nalepae added this pull request to the merge queue Jun 2, 2026
Merged via the queue into develop with commit 134e020 Jun 2, 2026
23 checks passed
@nalepae nalepae deleted the commmittee-cache branch June 2, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants