Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cooperative settlement (simple implementation and clear old code) #1383

Closed
hackaugusto opened this issue May 7, 2020 · 5 comments
Closed
Assignees
Milestone

Comments

@hackaugusto
Copy link
Contributor

#399 was commented out to be re-enabled in the future, but after a discussion with @karlb we realized that withdraw alone provides the same capabilities as coop settle. Instead of having two primitives it makes more sense to just have one.

The only drawback is that two withdraws would be more expensive then a single coop settle. This has to be measured and weighted to see if it is significant enough to keep coop settle around.

@karlb
Copy link
Contributor

karlb commented Jun 22, 2020

I've done some measurements to compare the gas cost of different approaches:

Classic Approaches

Two Withdraws

Don't implement anything new and expect both parties to do a withdraw if they don't want to use the channel, anymore.
Gas cost: 2 * 109_565 = 219_130
Result: open, empty channel

Coop Settle

Activate the cooperative settle function which is currently disabled in the contract. The code to handle coop settlement in Raiden is still missing, but would look similar to our current withdraw code.
Gas cost: 60_857
Result: settled channel

Hybrid Approaches

These two approaches reuse our current withdraw signatures, but both nodes coordinate to only have a single on-chain transaction. That reduces the number of different proofs we have to handle compared to the original coop settle, but apart from that is about as complex.
Potential attack: Instead of executing both withdraws, the transaction submitter could initiate only one withdraw (relatively harmless)

Two Withdraws in a Single Transaction

Add a small wrapper function to execute both withdraws in a single transaction.
Gas cost: 154_140
Result: open, empty channel

Coop Settle Based on Withdraw

Reuse the existing code to create and check withdraw proofs in a new coop settle function. The function would check both withdraw proofs, but instead of withdrawing, it settles the channel.
Gas cost: ~100_000
Result: settled channel

@karlb karlb added this to the Coruscant milestone Dec 15, 2020
@palango
Copy link
Contributor

palango commented Feb 18, 2021

@karlb Which of the hybrid approaches was the one that you and Augusto favored?

@karlb
Copy link
Contributor

karlb commented Feb 19, 2021

I don't think there was a clear favorite, but I would suggest going with "Coop Settle Based on Withdraw".

@palango
Copy link
Contributor

palango commented Feb 26, 2021

Also discussed in #1236

@palango palango mentioned this issue Jun 22, 2021
21 tasks
@karlb karlb changed the title Clear cooperativeSettle from the code Cooperative settlement (simple implementation and clear old code) Jun 29, 2021
@palango palango self-assigned this Jun 29, 2021
@palango
Copy link
Contributor

palango commented Jul 15, 2021

Fixed by #1474

@palango palango closed this as completed Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants