-
Notifications
You must be signed in to change notification settings - Fork 673
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
Fix/net slow lock #2266
Fix/net slow lock #2266
Conversation
…p thread and into the relayer thread
…roblocks, but can read an existing trie
…ing trie, so handle as a 404
…ie that can disappear)
… thread, and have the relay thread pass back the list of unconfirmed transactions to the p2p thread so it can service requests to them via the RPC interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM! Just make sure that the neon_integrations microblock test still works with the latest change.
It passes locally at least. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Flaky tests pass locally. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR addresses #2258 by moving management of unconfirmed state and microblock mining back into the relayer thread (now that it's safe to do this).
The p2p thread will drive microblock mining using a
RunMicroblockTenure
relayer directive, which will be sent to wake up the relayer every so often to mine the next microblock (according to the microblock interval from the config file).The p2p thread can no longer manage the unconfirmed state trie on its own, so I modified the
UnconfirmedState
struct to have a "read-only" mode that will allow it to be used to query an existing trie in the underlying MARF. To make this happen safely, I also added a new Clarity API methodbegin_read_only_checked()
, which unlikebegin_read_only()
can fail if, for example, the given trie doesn't exist. This is necessary because the relayer thread can delete the unconfirmed trie while the p2p thread is using it to service requests; these requests should fail gracefully if this happens.Because the p2p thread needs to know which transactions went into the unconfirmed state trie (so it can handle
/v2/transactions/unconfirmed/{:txid}
), I took the path of least resistance and made it so that the relay thread will share a copy of its unconfirmed state's mined transaction list with the p2p thread via a mutex guard. It's not the prettiest solution, but it requires fewer lines of code an introduces fewer failure modes than the alternatives I could think of.