raiden-network / spec

Spec of the Raiden Network protocol
8 stars 19 forks source link

Don't allow unlocking of locks whose expiration crosses settlement timeout #81

Open LefterisJP opened 6 years ago

LefterisJP commented 6 years ago

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.

loredanacirstea commented 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?

hackaugusto commented 6 years ago

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.

nkbai commented 6 years ago

@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.

hackaugusto commented 6 years ago

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: