fix: Run attestation requests within a tokio runtime #1229
Merged
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.
Closes #1224
This PR solves the problem of the attestation generating logic happening outside of a tokio runtime by creating the root runtime first thing in
StartCmd::run
and calling.enter()
to enter the runtime context and keep it for the remainder of therun()
function.Forgive me, team, for I have sinned. I have opened this PR without adding test coverage of the change. While the change is trivial and should be easy to review, I did not find any easy way to test this. And since this bug currently breaks the node, it would be nice to get the fix through before refactoring the code to make this testable.
I have created a follow-up (#1227) to ensure this part of the code is easier to test, but I fear that will be a significant effort to refactor and we might need to push it until after the soft launch. Unless we're hitting many more bugs during E2E testing at which point we can reconsider prioritizing this refactor.
Also this bug is a deja-vu. We fixed a similar issue in #612 but for some reason, the runtime guard introduced there is not around anymore. This also shows why it's important to have tests to guard against regressions. @DSharifi - was there any reason to kill the runtime guard that you recall?