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

lock forkchoice on calls to Ancestor #12162

Merged
merged 2 commits into from Mar 20, 2023
Merged

lock forkchoice on calls to Ancestor #12162

merged 2 commits into from Mar 20, 2023

Conversation

potuz
Copy link
Contributor

@potuz potuz commented Mar 20, 2023

Lock forkchoice on calls to Ancestor().

Fixes #12161

The function Ancestor() currently exposed in forkchoice is only accessed when processing attestations currently from the sync package. The single entry point is the function ancestor from the blockchain package. It would be safe to lock within forkchoice. However, as discussed on slack, we are moving to a system in which

  1. Forkchoice should be only visible from withing the blockchain package (and possibly the stategen package)
  2. Blockchain package locks forkchoice on appropriate calls
  3. External packages that want to call forkchoice to get information (specifically RPC package) should do so via the blockchain package, through calls in chain-info.go that expose forkchoice with the appropriate locks.

This PR does the minimal amount of work to fix #12161 while adhering to the above design: we lock on a blockchain method (which is now exposed and moved to the chain-info.go file) and set a new interface within it with this exposed method.

In future PRs we should move methods that are simple wrappers to forkchoice, from different interfaces, to this interface and do not expose Forkchoicer() which gives access to all of forkchoice to other packages. This is a larger project that will require time.

@potuz potuz requested a review from a team as a code owner March 20, 2023 15:20
@potuz potuz added the Ready For Review A pull request ready for code review label Mar 20, 2023
Copy link
Member

@prestonvanloon prestonvanloon left a comment

Choose a reason for hiding this comment

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

LGTM

@potuz potuz merged commit 3536669 into develop Mar 20, 2023
5 checks passed
@delete-merged-branch delete-merged-branch bot deleted the ancestor-root-lock branch March 20, 2023 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beacon node crash
3 participants