-
Notifications
You must be signed in to change notification settings - Fork 2
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
Migrate Bisq pricenodes from earn.com fee estimation API to our own self-hosted mempool fee estimation API service #27
Comments
Have you considered using the estimatesmartfee call from Bitcoin Core? |
If my understanding is correct, all Bisq nodes have access to Bitcoin Core (either to a local node, or through a service interface exposed by a full node). In that case, why not just use Bitcoin Core's mechanism for fee estimation? They already expose it through their API: estimatesmartfee. The fee estimation call can take different parameters: for example, the caller can indicate in how many blocks they wish to have the tx confirmed, or the estimation mode (conservative or not). Using this API in Bitcoin Core would achieve 2 things for Bisq:
I've already used it in other projects via the Java interface exposed by bitcoin-rpc-client, seems to be a good match for Bisq's use-case. |
100% agree with this proposal. Furthermore, I think it would be a great idea to allow offer makers to set their own custom fee when creating an offer. It could of course offer a hardcoded min limit (just like the 2 sat/byte min limit when withdrawing funds from the bisq wallet). On the other end, for the offer taker, there should be a way (warning popup maybe) of letting them know something like: "Before confirming the taking of this offer please be advised that the deposit transactions will take about X more hours to confirm". Just my 2 BSQ sats... |
@eigentsmis I agree with your second idea as I would like to set my own mining fees, but I would put that on the back burner until a better estimator is found for the majority of trades. |
Bisq nodes are connected to one or more Bitcoin Core nodes via the Bitcoin p2p protocol. They have no access to these nodes' RPC interfaces, and |
Thanks for the explanation @cbeams Until a better solution for the fee estimation is found, I prepared a workaround (which was actually already requested a few times) that allows users to manually override the fee estimation with a custom fee (bisq-network/bisq#4231). Initial tests look promising (custom fee can be set to anything between 2 and 5000 sats/byte), but I may well have overlooked smth, so the change is up for review. |
The current situation is pretty extreme, I agree. At time of writing,
while earn.com is reporting 110 sats/byte as the "fastest and cheapest" rate: Based on that value, Bisq is currently requiring 94 sats/byte. Clearly way too much with the mempool having been relatively uncongested for many hours. I see a couple alternative options here to what @wiz proposes. The first is that we switch from using the earn.com API to using the whatthefee.com API. We considered doing this in late 2017 when @FelixWeis was first standing up the service, but never did it in the end, and fees have been pretty low for the most part since. This change would be the lowest-risk, because it's just swapping out one API for another. No new moving parts to establish, no role duties to modify, etc. Even if we do go ahead with @wiz's proposal, I would still propose that we do this first (and it doesn't have to be whatthefee; any reputable estimation service with a web API would be up for discussion). For reference, here are https://whatthefee.io/ current estimations: The second alternative I'd offer is to make running a (possibly pruned) full node a requirement for pricenode operators such that the pricenode can call directly into the full node's |
@softsimon is the author of this algorithm so I'll ask him to respond as to why it's better than using the one in core, he is the best person to explain it |
I am not quite sure how estimatesmartfee operates, but mempool.space uses a fully mempool based fee estimation while most traditional estimators are based on probability. |
Replacing earn.com with another TTP / CPOF is not an acceptable solution IMO. If we wanted to do that we could simply query the mempool.space API at https://mempool.space/api/v1/fees/recommended which is the same as https://bitcoinfees.earn.com/api/v1/fees/recommended but this would just make everyone trust my node, which is why I'm proposing that all pricenodes run their own open-source backends for local fee estimation in the spirit of decentralization. AFAIK all pricenode operators already operate bitcoin nodes, so this is very easy to arrange. |
https://bitcoinfees.earn.com/api/v1/fees/recommended https://mempool.space/api/v1/fees/recommended So. The mempool is almost empty, not even a half block full in queue, yet earn.com recommends 110 to get into the next block. 1 is enough the next 10 minutes to get into the next block if you actually just look at the mempool. |
Fee estimation has been a known issue since 2017: bisq-network/bisq#1077 And its the 3rd most commented issue in Bisq, ever. So there is lots of interest from users. Looks straightforward enough to fix + would directly improve every Bisq trade in every market, for both sellers and buyers. Its especially bad for Bisq contributors who want to convert their BSQ to fiat, cause they have to go through 2 trades (BSQ-BTC then BTC-fiat), so they pay the unnecessarily higher (100x) miner fees twice. In addition, every Bisq trade has 3 on-chain bitcoin transactions. So for every trade, both parties pay each 300x the normal mining fee (instead of just 3x, one per tx). Why is it not prioritised? (not listed on either Critical Bugs or Master Projects boards) I can help with dev if necessary. |
Would it help if a dedicated funding mechanism was set up specifically for resolving this issue? I would be more than willing to kick in some funds toward it. |
I'm working on a PR now to switch to the mempool.space API as a stopgap measure. |
You read my mind :) I went ahead and already prepared a PR in the meantime: bisq-network/bisq#4235 Please have a look, it might be good enough and you might not need to do any extra work. |
Yep, reviewing it now, per bisq-network/bisq#4235 (comment). |
@wiz, I see that you created bisq-network/proposals#219 to establish a new Mempool API Operator role, but before we go ahead with that, I'd like to further vet this proposal. First, I want to address the risk of querying N fee estimation services vs 1. Yes, this is good for decentralization, but it also introduces the risk of getting divergent fee estimates from different mempool.space nodes. Each service is talking to its own full node with its own mempool, and for a variety of reasons may report different estimates. So long as they are within a reasonable range of one another, that's fine, but if we start getting minority reports that are very high or very low, we will have a more difficult time tracking down and solving these problems. Imagine having to analyze users' logs after the fact to see which pricenode (and therefore which mempool.space node) they were talking to. To mitigate this risk, I would suggest writing a simple script that periodically polls N different (existing) mempool.space services to see how their fee estimates diverge over time. Getting the logs from running this for a week or so would give us a sense what to expect. Ideally, these mempool services would be running against bitcoin nodes that use the same bitcoin.conf. Going back to the suggestion to create a mempool operator role, I'd actually suggest that running such a service and its backing fullnode become part of the normal duties of running a pricenode. I don't see the advantage in having a separate group of operators manage mempool nodes if the only thing we use them for is a backend for our pricenodes. Indeed, we would want all those mempool and bitcoind nodes to be configured in precisely the same way to avoid divergent results as much as possible. If we're agreed that this would be the way to go, then we should ask all @bisq-network/pricenode-operators if they're willing to run these services, and if they are, then they should just set them up now, and we can run the script I talked about above against them to make sure that divergent results aren't going to be a problem. When we've de-risked that, then we could go ahead with the implementation. Which brings us to the tasks section, and what's missing from it. As mentioned in bisq-network/bisq#4235 (review), the pricenode code will need to be modified to allow for configuring a specific mempool.space backend. Indeed this will be a required argument, as there is no one, correct fallback value. So, to summarize:
|
You're right, and this is actually the reason why we need to separate pricenodes from mempool nodes - all pricenodes should query all mempool nodes, and average the returned values. The more mempool nodes we have, the more they will average out in the event one is off for some reason and converge on consensus. For example, take the following script:
It currently outputs the following suggested fees:
This weighted average, combined a with good monitoring system that runs the same script and sends alerts for any deviations to us should be sufficient enough IMO. I can add this service check to my monitoring system which will graph the results over time. I can also set it to graph the average deviation from mean of each mempool node.
I'd prefer having it separate for the simple reason that not all pricenode operators will run mempool nodes, and vice-versa. For example, it's easy to have existing bitcoin node operators also become mempool node operators, and some may do this, but it is not so easy for existing pricenode operators to also become mempool node operators because they would need to setup a bitcoin node for this if they don't already have one.
Instead of doing it that way, I'd like to have a hard-coded list of our 5 nodes, similar to how Bisq nodes have a hard-coded list of seednodes and pricenodes and bitcoin nodes, so that every pricenode will query all mempool nodes and average the results together. I've assigned this task to @cd2357 and he is working on it now. We will document it along with the other github issues you want created. |
As the new fee estimation API does not require this parameter anymore, remove it and all references to it. See bisq-network/projects#27
As the new fee estimation API does not require this parameter anymore, remove it and all references to it. See bisq-network/projects#27
As the new fee estimation API does not require this parameter anymore, remove it and all references to it. See bisq-network/projects#27
As the new fee estimation API does not require this parameter anymore, remove it and all references to it. See bisq-network/projects#27
As the new fee estimation API does not require this parameter anymore, remove it and all references to it. See bisq-network/projects#27
As the new fee estimation API does not require this parameter anymore, remove it and all references to it. See bisq-network/projects#27
Description
This is a project proposal to migrate Bisq pricenodes away from using the earn.com fee estimation API in favor of an open-source self-hosted mempool fee estimation API backend, that we can decentralize further by having all Bisq btcnode operators run.
Rationale
Whenever the Bitcoin market sees major price action, trading volume suddenly spikes, which results in a huge rush of new transactions into the Bitcoin mempool, and "next block" fees rise very quickly:
This sudden rise in mempool fees causes a major issue in Bisq whereby any trades taken during the time when the mempool fees start to rise use far too low of a fee, and they do not get confirmed for several hours or even days later, until the mempool clears out. The cause of this issue is that Bisq currently uses Earn.com fee estimation API which is slow and not well maintained. The https://mempool.space backend uses realtime data from Bitcoin nodes, so it is extremely fast to return realtime fee estimates, compared to the Earn.com API which is always lagging behind:
This issue was first reported by @ManfredKarrer in bisq-network/bisq#1077 but at the time, a better mempool fee estimation API service did not exist. But now we have a great open-source and self-hosted solution, the mempool project. Of course I am bias, since I am a maintainer/contributor to this project, but IMO it really is the best mempool project for Bitcoin and we have worked very hard making it so.
Recently during the past few days we have seen this issue reproduce again, and now users are complaining in support that their deposit TX have still not confirmed even after waiting for 12 hours. So therefore I propose that we pull the trigger on ditching Earn.com API once and for all.
Criteria for delivery
After all Bisq pricenodes upgrade to the new code that will query our federated btcnode mempool fee estimation backend service, we can consider it delivered.
Measures of success
After all Bisq nodes start receiving the self-hosted mempool fee data, and users no longer experience this issue due to sudden fee spikes, we can consider it a success.
Risks
I've been running the mempool backend and hosting https://mempool.space for over 6 months, and it has never crashed, so I feel it is quite stable to run in production. However, we could keep Earn.com API as a backup data source to mitigate the risk of any issues with our own self-hosted API service.
Tasks
Estimates
Dev: $2000 USD
Ops: $1000 USD
The text was updated successfully, but these errors were encountered: