Skip to content

Smart fees for wallet CreateTransaction#4250

Merged
gavinandresen merged 3 commits intobitcoin:masterfrom
gavinandresen:smartfee_wallet
Jul 3, 2014
Merged

Smart fees for wallet CreateTransaction#4250
gavinandresen merged 3 commits intobitcoin:masterfrom
gavinandresen:smartfee_wallet

Conversation

@gavinandresen
Copy link
Contributor

The wallet now uses the mempool fee estimator with a new
command-line option: -txconfirmtarget (default: 1) instead
of using hard-coded fees or priorities.

A new bitcoind that hasn't seen enough transactions to estimate
will fall back to the old hard-coded minimum priority or
transaction fee.

-paytxfee option overrides -txconfirmtarget.

Relaying and mining code isn't changed.

For Qt, the coin control dialog now uses priority estimates to
label transaction priority (instead of hard-coded constants);
unspent outputs were consistently labeled with a much higher
priority than is justified by the free transactions actually
being accepted into blocks.

I did not implement any GUI for setting -txconfirmtarget; I would
suggest getting rid of the "Pay transaction fee" GUI and replace
it with either "target number of confirmations" or maybe
a "faster confirmation <--> lower fee" slider or select box.

Built on #3959 ; only the last commit is new.

@jgarzik
Copy link
Contributor

jgarzik commented Jun 6, 2014

ACK

@gavinandresen
Copy link
Contributor Author

Rebased just to get pull-tester to re-test.

src/init.cpp Outdated
Copy link

Choose a reason for hiding this comment

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

AFAIK we ordered the commands here alphabetically.

Copy link
Member

Choose a reason for hiding this comment

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

@Diapolo If that's the goal at least add a comment at the top of HelpMessage() that they're meant to be sorted alphabetically per category. Otherwise, it will not stay sorted very long.

Copy link

Choose a reason for hiding this comment

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

If we can get to that consensus I'm going to add a short hint yes.

Copy link
Member

Choose a reason for hiding this comment

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

No need for "consensus", this is way too unimportant to vote about, just do it

Copy link

Choose a reason for hiding this comment

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

@petertodd
Copy link
Contributor

This would be extremely dangerous to implement right now as there is no ceiling on the estimated fee. A sybil attacker could easily skew your idea of what fees to pay upwards arbitrarily high, or for that matter, a fluke high estimate at startup. fRejectInsaneFee isn't even set when AcceptToMemoryPool() is called in the CWallet::CommitTransaction() codepath so the fee could be essentially anything.

Needs a -maxfee option with a sane default.

@gavinandresen
Copy link
Contributor Author

Not vulnerable to Sybil attacks-- attacker would have to produce bogus blocks with valid POW to affect estimates.

On Jun 21, 2014, at 11:23 AM, Peter Todd [email protected] wrote:

This would be extremely dangerous to implement right now as there is no ceiling on the estimated fee. A sybil attacker could easily skew your idea of what fees to pay upwards arbitrarily high, or for that matter, a fluke high estimate at startup. fRejectInsaneFee isn't even set when AcceptToMemoryPool() is called in the CWallet::CommitTransaction() codepath so the fee could be essentially anything.

Needs a -maxfee option with a sane default.


Reply to this email directly or view it on GitHub.

@petertodd
Copy link
Contributor

Steps to reproduce:

  1. Delete fee_estimates.dat
  2. ./bitcoind -minrelaytxfee=0.1 -limitfreerelay=0 (and hack out priority code I think too)
  3. Create a transaction with 1BTC fee.
  4. Wait for confirmation.
  5. Observe that 'estimatefee 1' returns 5.208 BTC/KB
  6. Send some funds.
  7. Observe that Bitcoin happily sent a transaction with a 1BTC fee without even blinking based on a single transaction confirming that happened to have a high fee.

You can do the above with a second node -connect'ed to the first if you really want to see what a sybil attack would look like.

@gmaxwell
Copy link
Contributor

In my experience talking to people the uncertainty they suffer around fees causes them a lot more problems than the fees themselves... people basically clawing their eyes out in panic when fees are non-zero because they just don't know what they are. We'd probably save a lot of stress for users by supporting a setting of a hard maximum fee per transaction and a setting for a hard maximum fee per KB, ... and avoid the kind of trouble petertodd is pointing to above by setting them to some prudent values like the sendrawtransaction sanity check.

Copy link
Member

Choose a reason for hiding this comment

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

This could be const static

@laanwj
Copy link
Member

laanwj commented Jun 27, 2014

Code changes look good to me. Haven't tested.

@laanwj
Copy link
Member

laanwj commented Jul 1, 2014

BTW:

  • After this, CFeeRate CTransaction::minTxFee can be moved to wallet.cpp, as it is no longer used in main.cpp.
  • Similarly, -mintxfee option could be moved to the Wallet options category in HelpMessage.

@sipa
Copy link
Member

sipa commented Jul 1, 2014

I think all fee related code (CFeeRate, CTransaction::minTxFee, ...) can move out of core.

@laanwj
Copy link
Member

laanwj commented Jul 1, 2014

Moving the minrelayfee would involve more work though, as it's used in many functions in main still.

@sipa
Copy link
Member

sipa commented Jul 1, 2014

Yes, to main. There's no need for it to be in core.

Copy link

Choose a reason for hiding this comment

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

May I suggest to add a DEFAULT_TX_CONFIRMTARGET and use that where currently 1 is used. It's also nice to use this in the help string, because when changing a default we don't need to change the help string.

See e.g. -blockmaxsize=<n> in init.cpp.

The wallet now uses the mempool fee estimator with a new
command-line option: -txconfirmtarget (default: 1) instead
of using hard-coded fees or priorities.

A new bitcoind that hasn't seen enough transactions to estimate
will fall back to the old hard-coded minimum priority or
transaction fee.

-paytxfee option overrides -txconfirmtarget.

Relaying and mining code isn't changed.

For Qt, the coin control dialog now uses priority estimates to
label transaction priority (instead of hard-coded constants);
unspent outputs were consistently labeled with a much higher
priority than is justified by the free transactions actually
being accepted into blocks.

I did not implement any GUI for setting -txconfirmtarget; I would
suggest getting rid of the "Pay transaction fee" GUI and replace
it with either "target number of confirmations" or maybe
a "faster confirmation <--> lower fee" slider or select box.
Require at least 11 samples before giving fee/priority estimates.

And have wallet-created transactions go throught the fee-sanity-check
code path.
@gavinandresen
Copy link
Contributor Author

Rebased, and nits picked (fee variables moved from core to wallet/main).

If pull-tester is happy I'm going to pull.

@Diapolo: I didn't bother with DEFAULT_TX_CONFIRMTARGET because one is the obvious choice for a default, and I doubt we'll ever decide that two or three or eleven makes more sense than one.

@jgarzik
Copy link
Contributor

jgarzik commented Jul 3, 2014

lightly tested ACK

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4250_13fc83c77bb9108c00dd7709ce17719edb763273/ for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@gavinandresen gavinandresen merged commit 13fc83c into bitcoin:master Jul 3, 2014
@laanwj
Copy link
Member

laanwj commented Jul 4, 2014

Posthumous ACK.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants