Client side paymentId#1099
Client side paymentId#1099akumaigorodski wants to merge 8 commits intoACINQ:masterfrom akumaigorodski:client-side-payment-id
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1099 +/- ##
==========================================
- Coverage 82.6% 82.36% -0.24%
==========================================
Files 101 101
Lines 7692 7696 +4
Branches 301 307 +6
==========================================
- Hits 6354 6339 -15
- Misses 1338 1357 +19
|
|
Can you detail why that feature would be useful? |
|
@t-bast it's to eliminate a possible case of:
with this change enabled it becomes:
|
Have you observed eclair failing to return a UUID? I understand there is always a possibility of this happening but the payment code was designed to return the UUID as soon as possible and even before the payment is actually processed, looking at the interaction between the initiator and the lifecycle we could improve this by storing the |
It seems to me that this is what you really want to fix. |
|
To further clarify, in "3. for whatever reason this fails" I specifically mean my app failing to save UUID to app db, not Eclair failing to return a UUID (Eclair failing would be fine as will result in exception on app side which would also halt further progress).
For example, app db may get corrupted (or disk detached etc) which would allow users to withdraw funds without recording them in app db. |
But in such extreme cases you would basically have everything failing right?
This looks like quite a rare event honestly. And you still have the payment hash that allows your app to discover that payments were successfully made (by querying eclair for succeeded payments after the app DB is recovered). I'm not a big fan of letting clients generate that value TBH, so I'd like to make sure this really fixes an existing pain point before doing it. It seems to me that this can be recoverable from the app's side entirely without that change... |
|
@t-bast it's important to specify which db we mean here: one is Eclair internal db and it's irrelevant, the other one is my app db where I link payments to users' IDs. A worst case which is currently possible is:
So basically from my app perspective it's "send, then (maybe) save", I want it to be possible to "(maybe) save, then send if saved successfully". It's true that I have a payment hash before making a payment and can rely on it, but it feels awkward for these reasons:
|
|
Ok I have a better understanding of your use-case and the failure. It seems to me that if you fail to save something as important as a Can you detail why/how your app would keep running and accepting payment requests while the app DB is failing? If the app halts until the app DB is available again, then you don't need to generate the UUID client-side and I think you avoid a lot of potential recovery issues. But I'm probably missing more context from your app's point of view? |
|
Well in my case app does halt completely once any db error happens but even in this situation the very first problematic withdrawal will still get processed by Eclair before halting my app a few moments later, and it may happen to be a large withdrawal. |
|
Also I can imagine an app which does it's main thing in one process and withdrawals in another one, with this change applied app can be designed such that it may continue doing it's main thing while withdrawals fail while now it really has to shut down completely. |
But you don't have an issue in this case then, you are at a failing point where you have (in-memory) both the payment ID returned by eclair and the user ID. So you can save this anywhere (app storage, special log, etc) to reconcile once the DB is back online (or if the app keeps running until the DB is back online, it can simply be kept in memory in a hanging routine).
While I agree in principle, in reality we are talking of a very specific failure (the DB is failing). And I expect that if the DB is failing, even in the app's main thing you would need a DB to do any meaningful side-effect task so that would be failing as well... Sorry for nitpicking on this, but I wanted to understand in more details what your app was currently doing to see if I could suggest a change that would provide bigger overall benefits than fixing this specific case in eclair (because I think handling an unavailable/failing DB is a problem that concerns most features of an app and shouldn't be fixed feature by feature but rather holistically). This doesn't mean I'm completely opposed to this PR, don't worry ;) |
|
I think this is a typical case of db inconsistencies. The standard way to solve this would be to offer a I'm also not very keen on letting an external user/app choose internal payment identifiers (NB: in any case you should have checked for duplicate keys in |
Is this something a client app or Eclair should do? |
This is a bit of both: your app will send us this value in the |
|
#1130 offers an |
Currently API caller can only get payment UUID and then save it to app db while payment is being processed in Eclair, with this change API caller would be able to make UUID of their own and save it to app db prior to instructing Eclair to use it.