Ensure Single Context Used for Beacon Node Cancelation on SIGTERM #5671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What does this PR do? Why is it needed?
We were confusing the usage of the cli context with a regular context used by the beacon node in many different services. So when we would attempt to stop the beacon node process while it was doing some expensive operation, such as regenerating historical states, the node would not stop as it would not be able to understand the root context had been canceled. This PR simplifies the code and ensures we have a global, single ctx for the beacon node in node/node.go which is propagated down to all running services.
This PR also adds a check for ctx.Err() on each iteration of regenerating historical states, which is an expensive operation.
Which issues(s) does this PR fix?
Fixes #5470