-
Notifications
You must be signed in to change notification settings - Fork 19
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
Swap: Handle monero under- and overfunding #534
Swap: Handle monero under- and overfunding #534
Conversation
Codecov Report
@@ Coverage Diff @@
## main #534 +/- ##
=======================================
- Coverage 12.0% 11.9% -0.1%
=======================================
Files 34 34
Lines 10308 10403 +95
=======================================
+ Hits 1241 1243 +2
- Misses 9067 9160 +93
Continue to review full report at Codecov.
|
fed2148
to
b1267e8
Compare
8bee5dd
to
c876590
Compare
45f1a6d
to
9966c04
Compare
2fc6120
to
5d0a9d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was reviewing but i messed up and cancelled the review, so i just added 2 commits instead
@TheCharlatan can u diff the 4 last commits with ur version and review it? |
c2c3dc3
to
ec83f67
Compare
@TheCharlatan, will the 5% funding error margin break the tests, here or in the bitcoin one? |
It will break the test here: https://github.com/farcaster-project/farcaster-node/pull/534/files#diff-2dcb9e59d484446ce89de83ae51f011d9be045e37de5168024e0ab4134e9d07cR1073 I am not sure what this extra error margin is supposed to achieve. To my eyes, it just complicates everything even more. |
i agree 5% is outrageous, that is why i put FIXME flags, just for now i find it strange that one would abort a swap if the error is negligible such as 1 atomic unit or 1 sat |
The counterparty will reject the swap anyway, if you underfund, so aborting early will save time and fees. If you overfund, yeah, the counterparty is free to accept it, and a margin of error might make sense there. I'd rather have consistent behavior though and reject any user-induced error. |
This was not clear to me. Will the counterparty reject the swap? |
if there is 1 sat missing? |
I guess you meant that the software is not handling it correctly elsewhere, I suppose Not that the counterparty (as a human being) will deliberately choose to abort a swap <- this is what I read |
Yes, I mean the software. Here Bob rejects the funding amount if it does not match what he is expecting: https://github.com/farcaster-project/farcaster-node/blob/main/src/swapd/runtime.rs#L1141 |
hmm, on these kind of thing i always add an epsilon (error margin) for negligible errors. i can fix the rest, but it seems you think its a bad idea, can you elaborate why |
ec83f67
to
abf3aa9
Compare
I'll just rattle down some reasons here. As a swapper, I want to swap the exact amount, no more and no less. This is money, introducing error margins is usually a bad idea and leads to unknown side effects. If you add an error margin, then why not just swap at the limits all the time? We have an entire protocol to establish exact amounts and I don't support relaxing this here at the lowest level. If you want to trade within a margin, you should establish that in the negotiation and then commit to a fixed amount for the swap. |
hmm, ok, we disagree on this one. but i see what you're saying working for monero but i dont see that currently working for bitcoin, as we have the 1st transaction from the external wallet, and we might not know exactly how much to pay on fees |
868da05
to
e4b650f
Compare
It's not implemented currently, but Alice should check the exact amount in the Lock transaction's output and abort if it is incorrect in my opinion. EDIT: Which means we have to explain to the user why he is paying extra in fees for the funding transaction. |
so i guess what you're saying means: bob must pay fees in lock tx matching exactly what was requested and included in the amount of the funding tx? |
e4b650f
to
6252d13
Compare
removed the offending commits, but in general, i would be totally ok if someone robs me epsilon, since epsilon is negligible |
@TheCharlatan if you're OK with the additional commits, please merge or signal me to merge |
it also means we know exactly the size of the lock tx, is that a true assertion? |
I’m not against an epsilon if we want one. If we do it it should only account for fee variation until we use RBF and merge funding and lock txs. IMO It is fair to check the exact amount against what was agreed in the trade in both lock txs outputs, for accordant that’s easy, for arbitrating it require bumping funding, which is what we already do IIRC. we should be able to exactly know the lock size as it’s a 1-1 in-out tx with all the keys and scripts controlled by the protocol. Currently core errors when creating a smaller lock output than what was requested in the offer. We have to fix this if epsilon allow lower. Also Alice while signing cancel checks the set of core arbitrating txs, so she already checks the exact amount in arbitrating lock. If I try to do the sequence of actions to get the lock on chain:
In my understanding having epsilon in the current setup (no use of RBF and interactive PSBT with the user) would allow to correct the lock fee at Is there something I missed in the sequence? For me the question is do we want to double estimate fees (at |
@h4sh3d so vsize for the bitcoin Lock is always 94 vB? |
Going by @h4sh3d 's argument for accounting for fee variation, I am even more against having an epsilon for Monero, since the fees don't matter in this case and should be burdened on the funder of the AccLock completely. For fhe ArbLock and the Bitcoin funding I am still not sold, even by Joels argument. Establishing a sane epsilon value that accounts for fee variation is complex. If we introduce an epsilon it should be the difference in the estimated fee between time |
If the size is deterministic, i'd just not take a new fee at |
actually, the person could take ages to publish the funding tx, and maybe |
So I currently see the following three reasons why a party may underfund:
The proposal to handle this by introducing an epsilon tolerance introduces more problems than it superficially solves and weakens the protocol from a few perspectives. In particular, error margins will handle High level objections:
Specifically regarding user error:
For bona fide user error, the error would typically be a typo. That this typo is a mere sat is very unlikely - I'm sure missing or adding a decimal is more likely. Likewise for any other typos that would fall within some error tolerance, even if the error tolerance is 5%, it's still a small subset of typos that are addressed by this proposal. For handling fee fluctuations:Although it might make us less efficient on fees, instead of burdening Alice with the cost of handling the fee estimate being off, you could also just increase the amount Bob funds with. That is: instead of Bob paying
My preference here would be My preference for this is also that it leaves responsibility & ownership of correctly handling fee fluctuations with Bob - who is in control of creating these transactions, instead of outsourcing the ultimate cost to Alice. |
as far as i get, the vars of interest are: and
there is an implicit assumption that this discussion belongs to #533 |
I approved this for merging, but since I added commits, I'd like ACK for merging, or someone else merges, thank you |
Addresses #531 .
@zkao let me know what you think of Alice blocking the publishing of the buy transaction in case she overfunds. I'm not married to the idea and would be happy to remove this part of the logic.