Open LefterisJP opened 6 years ago
We do not currently enforce this. We actually allow locks with an expiration > settlement timout and have a test for it : https://github.com/raiden-network/raiden-contracts/blob/master/raiden_contracts/tests/test_channel_unlock.py#L904-L910
@hackaugusto , I remember this was an edge case that you explained some time ago. Can you add some details as to why this was/is still needed?
I remember this was an edge case that you explained some time ago. Can you add some details as to why this was/is still needed?
I don't recall, this is what I can say about the expiration:
To actually enforce a small expiration on-chain, we would need to add the start block in the lock structure, otherwise we don't know how large the expiration window was. With the current lock structure it is possible to reject lock's which still have an expiration larger than the settlement window while the channel was closed, that would mean the mediators and target nodes must reject transfers with a large expiration.
@hackaugusto
For a mediator, sending a transfer to the payee with a large expiration is not acceptable, it means the payer channel can be settled and the payee transfer will be still valid, so the mediator may end up paying to the payee and not getting payed by the payer, the fix is describe above.
because the mediator can still unlock this transfer after the payer channel is settled, it's safe to send a transfer to the payee with large expiration.
it's safe to send a transfer to the payee with large expiration.
Not necessarily, we do have indeed changed the order, and now unlocks are allowed after the settlement, but the unlock may be called by anyone, and it's possible for this to happen:
s
e
, where e > s
x
blocks after the settlement window is over, we have e - (s + x)
blocks to register the secret, if the secret is registered in that window then the payment from B will go to A2
We should enforce this in the smart contracts.
So inside the
unlock()
function of the smart contracts we should not allow unlocking of locks whose expiration is crossing the settlement timeout.