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

swapd: fee estimate from syncer (electrum) #533

Merged
merged 11 commits into from
Jul 11, 2022

Conversation

zkao
Copy link
Member

@zkao zkao commented Jul 4, 2022

No description provided.

src/swapd/runtime.rs Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2022

Codecov Report

Merging #533 (559571d) into main (17a5687) will decrease coverage by 0.1%.
The diff coverage is 0.0%.

@@           Coverage Diff           @@
##            main    #533     +/-   ##
=======================================
- Coverage   12.1%   12.1%   -0.1%     
=======================================
  Files         34      34             
  Lines      10529   10573     +44     
=======================================
  Hits        1277    1277             
- Misses      9252    9296     +44     
Impacted Files Coverage Δ
src/swapd/runtime.rs 0.0% <0.0%> (ø)
src/swapd/syncer_client.rs 0.0% <0.0%> (ø)
src/syncerd/bitcoin_syncer.rs 0.0% <0.0%> (ø)
src/syncerd/syncer_state.rs 86.0% <0.0%> (-0.1%) ⬇️
src/syncerd/types.rs 24.6% <0.0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17a5687...559571d. Read the comment docs.

@zkao
Copy link
Member Author

zkao commented Jul 4, 2022 via email

@zkao
Copy link
Member Author

zkao commented Jul 4, 2022

Most of the tasks are watch tasks. So those are easy to handle, because u subscribe very well ahead of time.

While coding, one simplification that I did and that might still be around is, for example, that the act of sending a broadcast task actually broadcasts a tx. Haven't searched for those.

@zkao zkao force-pushed the fee_management0 branch 6 times, most recently from 9a2639b to b295c6c Compare July 9, 2022 12:43
@zkao zkao marked this pull request as ready for review July 9, 2022 12:43
@zkao
Copy link
Member Author

zkao commented Jul 9, 2022

So far, fee estimation happens only once, FIXME

@zkao zkao force-pushed the fee_management0 branch 4 times, most recently from 483ca52 to a329856 Compare July 9, 2022 14:14
@zkao zkao added the mainnet label Jul 9, 2022
@zkao zkao force-pushed the fee_management0 branch from a329856 to 4003861 Compare July 10, 2022 12:57
@zkao
Copy link
Member Author

zkao commented Jul 10, 2022

discussion on handling bitcoin fees happened on #534

@zkao zkao force-pushed the fee_management0 branch 3 times, most recently from 51630bb to 5f47d2f Compare July 10, 2022 16:53
@zkao zkao force-pushed the fee_management0 branch 3 times, most recently from e1117ad to c71e7c9 Compare July 10, 2022 23:00
@TheCharlatan
Copy link
Member

From the logs:

[2022-07-11T08:38:45Z INFO  farcaster_node::swapd::runtime] 0xe2ad…44ae | Accepting swap as Maker from Taker through peerd peerd<03ee5e61d42bc0f932c0e7d09e0df6ab8b2dde43d86131645cd4b074a738a56803@0.0.0.0:9376>
[2022-07-11T08:38:45Z DEBUG microservices::esb::controller] swap<0xe2ad…44ae> -> farcasterd: progress: Accepting swap 0xe2ad…44ae as Maker from Taker through peerd peerd<03ee5e61d42bc0f932c0e7d09e0df6ab8b2dde43d86131645cd4b074a738a56803@0.0.0.0:9376>
[2022-07-11T08:38:45Z ERROR microservices::esb::controller] ESB request processing error: error sending message from swap<0xe2ad…44ae> to Bitcoin (Local) syncer. Details: service is offline or not responding
[2022-07-11T08:38:45Z DEBUG syncerd] MSG RPC socket ipc://tests/fc1/msg.rpc
[2022-07-11T08:38:45Z DEBUG syncerd] CTL RPC socket ipc://tests/fc1/ctl.rpc
[2022-07-11T08:38:45Z DEBUG syncerd] Starting runtime ...

Seems like the problem is when Bob is Maker, the swap daemon receives MakeSwap before the syncers are up. Either this requires another sleep before the EstimateFee Task is spawned, or we wait for some kind of Hello from the syncer before spawning syncer tasks in the swap daemon, or we spawn the syncers once the offers are open instead of when the swap is initialized.

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

i had an embarrassing number of bugs -- hopefully this is the last

@zkao zkao force-pushed the fee_management0 branch from bde6dd4 to 99e153f Compare July 11, 2022 11:52
@zkao zkao force-pushed the fee_management0 branch from 99e153f to 46e762f Compare July 11, 2022 11:53
src/swapd/runtime.rs Outdated Show resolved Hide resolved
@TheCharlatan
Copy link
Member

The parallel swap test is failing now, no idea why, upon investigation it seems like 0.5 seconds are too fast for it. I bumped it to 2.0 and it is working again.

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

2022-07-11T12:46:55.3239843Z [2022-07-11T12:46:55Z ERROR farcaster_node::swapd::runtime] Incorrect amount funded. Required: 1.00000124 BTC, Funded: 1.00000123 BTC. Do not fund this swap anymore, will abort and atttempt to sweep the Bitcoin to the provided address.
2022-07-11T12:58:13.9790261Z [2022-07-11T12:58:13Z DEBUG microservices::esb::controller] swap<0x575d…5dc0> -> farcasterd: progress: Too big amount funded. Required: 1.000000000000 XMR, Funded: 1.000000000001 XMR. Do not fund this swap anymore, will attempt to refund.

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

i understand u guys dont want epsilon, but then how do i ensure all amounts are always exact at the sat or atomic unit level? reference from this discussion: #534

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

@zkao zkao force-pushed the fee_management0 branch from 0a6e9b3 to bff0ec5 Compare July 11, 2022 14:07
@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

picked the dropped commits with epsilon for amounts, i know that is heavily objected, and the intend here is to move forward, not to challenge anyone

those commits can be dropped or later reverted as far a another solution is provided

@zkao zkao force-pushed the fee_management0 branch from c612340 to 7957b79 Compare July 11, 2022 15:09
@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

i changed the epsilon to 2 sat or 2 pnero

test for monero fixed, did not find test for btc

@TheCharlatan
Copy link
Member

2022-07-11T12:46:55.3239843Z [2022-07-11T12:46:55Z ERROR farcaster_node::swapd::runtime] Incorrect amount funded. Required: 1.00000124 BTC, Funded: 1.00000123 BTC. Do not fund this swap anymore, will abort and atttempt to sweep the Bitcoin to the provided address.
2022-07-11T12:58:13.9790261Z [2022-07-11T12:58:13Z DEBUG microservices::esb::controller] swap<0x575d…5dc0> -> farcasterd: progress: Too big amount funded. Required: 1.000000000000 XMR, Funded: 1.000000000001 XMR. Do not fund this swap anymore, will attempt to refund.

@zkao , from which tests are these logs? Aren't they from the overfunding tests and therefore expected and correct behavior?
There are two overfunding tests, one for Alice, one for Bob, so in the entire log, you should see exactly these two occurences once.

The Bob incorrect funding test is here: https://github.com/farcaster-project/farcaster-node/blob/main/tests/functional-swap.rs#L75
The Alice overfunding funding test is here: https://github.com/farcaster-project/farcaster-node/blob/main/tests/functional-swap.rs#L259

Please state which test is failing because of these errors before proceeding.

i understand u guys dont want epsilon, but then how do i ensure all amounts are always exact at the sat or atomic unit level? reference from this discussion: #534

In which scenario is the funding amount not exact right now?

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

oh, thats great, there are parallel new error that i did not undertand, will drop commits

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

have to understand what is wrong in bff0ec5

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

ah, it still is the syncer too late thingy

@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

i will add to pending requests, but i'd want a more general solution later

@zkao zkao force-pushed the fee_management0 branch 2 times, most recently from 43371ae to 4b878f7 Compare July 11, 2022 16:29
@zkao zkao force-pushed the fee_management0 branch from 4b878f7 to f6a042f Compare July 11, 2022 16:36
@zkao
Copy link
Member Author

zkao commented Jul 11, 2022

oh, boy, am i stupid, when syncer becomes online and triggers the pending requests, we already hit Msg::Reveal, too late

not using pending request

just left a longer sleep for bob maker to wait for the bitcoin syncer -- will grep sleep eventually and clean them all

Copy link
Member

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

Thank you for bearing through this one, I am happy we are this far now :)

@TheCharlatan TheCharlatan merged commit 50e8991 into farcaster-project:main Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants