Closed kilrau closed 5 years ago
Idea from the call: at the moment raiden re-queries the preimage on restart from the resolver. We make it continuously query the preimage from xud.
Question: Can we also tell raiden to cancel(refund) the payment? This would solve https://github.com/ExchangeUnion/xud/issues/1123 . Current behaviour is that payments without preimage get refunded after locktime, which is 20660 blocks - too long.
Refund is a different issue. The resolver
can provide the secret
or claim that it doesn't have it.
So the plan is:
a. if no resolver
is configured - use normal raiden flow (target should ask initiator for the secret)
b. if resolver
is configured - try to resolve:
b.i - if you got the secret
- continue with the raiden flow - send the secret
back to get the mediator/initiator.
b.ii- if you got a response that the resolver
does not have the secret
- continue with the raiden flow - request the secret
from the initiator
b.iii - else (we got some kind of an error (connection, exception, etc) )
b.iii.1 - if current block is above expiration block - 2* reveal timeout
continue with the raiden flow - request the secret
from the initiator
b.iii.2 sleep 5 seconds
b. back to b.
@kilrau @sangaman please confirm/comment
Feedback:
a. if no resolver is configured - use normal raiden flow (target should ask initiator for the secret)
Definitely, everything should be raiden default if there is no resolver configured.
b. if resolver is configured - try to resolve:
Addition: try to resolve and retry in 1s (?) interval until there is a response.
b.i - if you got the secret - continue with the raiden flow - send the secret back to get the mediator/initiator.
Continue with the regular swap flow, but I guess that's what you mean.
b.ii- if you got a response that the
resolver
does not have thesecret
- continue with the raiden flow - request thesecret
from theinitiator
b.iii - else (we got some kind of an error (connection, exception, etc) ) b.iii.1 - if current block is aboveexpiration block - 2* reveal timeout
continue with the raiden flow - request thesecret
from theinitiator
b.iii.2 sleep 5 seconds b. back to b.
I believe raiden should handle this worst case too, otherwise caught in infinite loop: if request secret from the initiator fails, e.g. it's indeed a swap flow, xud crashed and for some reason lost the secret. xud comes back up, now tells raiden it doesn't have the secret (even though it should), raiden requests from initiator, but this one also does not have the secret. In this case there is no other way than to cancel the swap and payment.
In case both the target
(xud) and the initiator
do not have the secret, the payment is canceled after the timeout.
This is how it is today. What is new here is that if the resolver is configured the target raiden will keep trying to resolve and will not go back to the initiator until: a. the resolver confirms that it has not such secret b. getting close to the timeout.
No infinite loop here
Ok. Last thing: in which intervals should raiden retry pulling the secret from xud? 1s?
As I wrote above:
b.iii.2 sleep 5 seconds
I think it can be shorter, but yeah let's go for 5s for now. @sangaman Please give some feedback too.
So the plan is: a. if no resolver is configured - use normal raiden flow (target should ask initiator for the secret) b. if resolver is configured - try to resolve: b.i - if you got the secret - continue with the raiden flow - send the secret back to get the mediator/initiator. b.ii- if you got a response that the resolver does not have the secret - continue with the raiden flow - request the secret from the initiator b.iii - else (we got some kind of an error (connection, exception, etc) ) b.iii.1 - if current block is above expiration block - 2* reveal timeout continue with the raiden flow - request the secret from the initiator b.iii.2 sleep 5 seconds b. back to b.
This plan looks good to me. The only part I'm not completely clear on is expiration block - 2* reveal timeout
- my thinking is that we want to keep retrying xud until shortly before expiration. I think 5 seconds is fine too for a retry interval.
Enhancement of https://github.com/ExchangeUnion/xud/pull/1081:
When
xud
crashes betweenSwapCreated
andSwapCompleted
: we currently can't attempt to resume swaps with raiden since there is currently no way to "push" a preimage to raiden so that it can settle a payment.This issue is about adding this functionality, e.g. as a raiden endpoint and subsequently enhance ExchangeUnion/xud#1081 to utilize it.