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

Fix mutual close #343

Merged
merged 3 commits into from
Jan 14, 2022
Merged

Fix mutual close #343

merged 3 commits into from
Jan 14, 2022

Conversation

marsella
Copy link
Contributor

@marsella marsella commented Jan 4, 2022

Closes #337

Before, the merchant's close() function called finalize_mutual_close. Now, the merchant's watcher calls it.

The most substantial change here is an addition of MutualCloseBalances to the merchant database. The merchant watcher cannot tell from the contract itself what the final mutual close balances are, so we need to persist them via the database instead. These changes include

  • updating the database schema to include this optional field (sqlx-data.json is the generated file)
  • updating the database Rust type to include the field
  • adding a getter and setter for the field for a specific channel id

Observation: the getters for each field of the database are a bit clumsy -- they're all identical except for the item being queried. Would it be better to have a single getter for the whole row, and have the caller pull out the field relevant to them?

Testing: I think this scenario is not currently caught by the e2e testing infrastructure. Should determine whether it is and either fix it in this PR or make a new issue + PR to address it.

Copy link
Contributor

@gijsvl gijsvl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In regard to your comments:

  • I think we should take your suggestion and check if this is covered by e2e testing, we can't keep postponing testing to new PRs in my opinion, just because the pile of testing we still have to do just grows, it's not making it easier.
  • The separate getters are fine as long as we don't do multiple getters just one after another... Every query takes time, we should make sure we make 1 query at a time and if we can combine queries we should do so. But querying everything at once if it is not necessary might also be unnecessary.

src/bin/merchant/main.rs Show resolved Hide resolved
updates the merchant database to have getter/setter for this data
and calls those functions appropriately
adds two additional statuses from which a customer unilateral close could be called and documents why
@marsella
Copy link
Contributor Author

marsella commented Jan 11, 2022

Testing comments remain important, but we've discussed and it seems like they will be better addressed by a significant update to the testing infrastructure, rather than trying to jerry-rig the script we currently have. See #69 for the plan to address this issue.

Force-push to rebase to main and fix a compile issue with the CI.

@marsella marsella merged commit 3db5475 into main Jan 14, 2022
@marsella marsella deleted the fix-mutual-close branch January 14, 2022 16:24
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

Successfully merging this pull request may close these issues.

Update merchant watcher to respond to mutual close
2 participants