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

Fresh download of blockchain in unclosed instance fails estimatesmartfee. #22404

Closed
dscotese opened this issue Jul 5, 2021 · 4 comments
Closed
Labels

Comments

@dscotese
Copy link
Contributor

dscotese commented Jul 5, 2021

If you start a fresh copy of bitcoin-qt without any blockchain data, wait until the entire blockchain is downloaded, and then open a console window and try estimatesmartfee, the answer is

{
  "errors": [
    "Insufficient data or no feerate found"
  ],
  "blocks": 1
}

I expected n estimate of the fee appropriate to the passed in number of blocks using the fees from the recently downloaded (and therefore newest) blocks.

I will not try to reproduce this issue because it takes several hours to download the blockchain.

This is Windows 10 with Bitcoin Core 0.21.1.

I don't believe this is a failure of the system or an anomaly in the environment, but rather an oversite in the processing of blocks when "catching up." I suspect that the process recognizes that the block received has been around a while and therefore doesn't bother updating the information required to answer estimatesmartfee. This makes sense because tracking that information for every received block would slow down the process too much.

Proposed solution: If one of the startup tasks were to identify the blockheight at which tracking fees would become useful, then the process could start tracking them once the blockheight was there. Otherwise, other layers that rely on estimatesmartfee (like ACINQ's Eclair Lightning node) have to wait an extra hour even though bitcoind has all the information it needs.

If there is information required by estaimatesmartfee that is not available to a node which has just finished downloading the blockchain, please add a comment explaining what it is.

@dscotese dscotese added the Bug label Jul 5, 2021
@jarolrod
Copy link
Member

jarolrod commented Jul 5, 2021

you have to wait around for a couple of blocks after being synced before fee estimation will work

@maflcko maflcko closed this as completed Jul 5, 2021
@dscotese
Copy link
Contributor Author

dscotese commented Jul 5, 2021

you have to wait around for a couple of blocks after being synced before fee estimation will work

I don't. I can go to any block explorer and compute a fee estimate from the last several blocks and their timestamps. The code can do the same thing, but it doesn't. Perhaps someone will explain why it doesn't.

@maflcko
Copy link
Member

maflcko commented Jul 5, 2021

Deriving the fees from the blocks makes it susceptible to miner attacks. The Bitcoin Core fee estimation uses the mempool transactions.

@achow101
Copy link
Member

achow101 commented Jul 5, 2021

Your assumption about how Bitcoin Core's fee estimation is incorrect. Bitcoin Core estimates the fee by observing how long transactions stay in its mempool. It tracks the fee rate for an unconfirmed transaction and how many blocks pass from the time it entered the mempool to when it is finally included in a block. This is how it can give estimate for different block targets. So in order for fee estimation to work, your node must have a mempool and must have seen transactions go from unconfirmed to confirm. It cannot derive fee information from just blocks. Doing so would allow miners to rig fee estimation by packing a couple blocks full of super high fee transactions and cause such fee estimators to estimate extremely high fees unnecessarily.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants