Decrypt completed sync transactions outside mNxsMutex - #358
Conversation
33ed4d6 to
d7e6eaf
Compare
csoler
left a comment
There was a problem hiding this comment.
I think the logic here has a flaw: the list of uncompleted transactions is also used as a waiting list because the decryption of transactions needs the private part of GxsId keys (requested through decryptSingleNxsItem()) and these are loaded asynchronously (see p3IdService::getPrivateKey()). These are requested to friends in parallel when needed and therefore processTransactionForDecryption() does not always return true nor succeed. Therefore the outcome of this function needs to be accounted for and the items (or the transaction) should remain in the list if decryption doesn't work.
What could be done: if processTransactionForDecryption() fails, put back the transaction in mTransactions after locking mNxsMtx.
or...
just keep the code as it is. It all depends on how much the change is actually improving the software.
|
The Putting the transaction back wouldn't restore it either: in the item loop the encrypted item is One detail on the async keys: So the patch removes dead code, and the decryption outcome is no more accounted for after it than before. On whether it is worth it — instrumented build with the decryption timed separately, GXS channels (service Correcting my own PR description while I am here: it says items whose keys are unavailable "stay encrypted and are dropped at validation". They don't — they are deleted right there in If you want the waiting list to actually exist, I'm happy to do it as a follow-up: have |
7c600ca to
196542e
Compare
processTransactions() ran processTransactionForDecryption() -- per-item circle RSA decryption of completed incoming transactions -- while holding mNxsMutex. On channels with circle-restricted groups this was measured at 1-3 s of pure RSA per sync cycle (2026 ms of a 2028 ms pass, ~225 s accumulated over a 73-minute session), blocking every other user of the service (tick, item reception, API) for the whole duration. Take the completed transactions out of the active map under the mutex, decrypt them after it is released -- the thread is their only owner at that point -- and re-take it only to queue them into mComplTransactions. Behavior is otherwise unchanged: processTransactionForDecryption() replaces encrypted items in place and always returns true nowadays; items whose keys are unavailable stay encrypted and are dropped at validation, as before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
196542e to
6b6ed44
Compare
processTransactions() ran processTransactionForDecryption() — per-item circle RSA decryption of completed incoming transactions — while holding mNxsMutex. On a node subscribed to circle-restricted channels this was measured at 1–3 s of RSA per sync cycle (about 225 s accumulated over a 73-minute session), blocking every other user of the service (tick, item reception, API) for the duration.
Completed transactions now leave the active map under the mutex, are decrypted after it is released — the thread is their sole owner at that point — and are queued into mComplTransactions under a brief relock. Behavior is otherwise unchanged: items whose keys are unavailable stay encrypted and are dropped at validation, as before.
🤖 Generated with Claude Code