-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lock free payment validator refactor
This patch contains a significant number of changes to payment validator and in fact a complete re-design of how it moves information around, although the core logic itself remains the same. Instead of having payment validator state stored in a lazy static and then accessed by a lock from various places, it's now stored in a single scope, the rita fast loop. This dramatically simplifies the way information flows through the program, prviously when a payment was made by payment controller the entire state of payment validator was accessed via a lock and updated, now that data is simply passed as a function argument. The one case where cross thread interaction is required is passing information from the actix endpoints into the rita client thread. Instead of using a lock over all of the payment validator state this has now been replaced with a lock free queue that payment validator dequeues from during validation. This did require two changes to how Rita behaves. Payments that are not yet validated are no longer included in the rita exit debts endpoint. We made that change to prevent clients from paying the exit twice if it was running slowly. The lock free changes make this slow operation much less probable and also repeated payments are a symptom of the low timeout bug we have just recently encountered and fixed. Second when a client sent in a transaction that was a duplicate we would return an error, we no longer do so. Instead we return ok and drop the tx as a duplicate later. Both of these changes required access to the entire program state in random other threads and contributed to slower operation and deadlocks. Ideally I'd like this to be the model for how to refactor other Rita modules going forward. There's a lot of cruft still left over from the original Actix actors structure, which we essentially replicated as closely as possible when moving to individual threads in Async await. Now we have to do the second part of that refinement. As a final note Althea paymetns have been modified to expect a MsgMicroTX and payment_controller needs to be updated to send one.
- Loading branch information
Showing
10 changed files
with
755 additions
and
808 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.