Refactor CreateNewBlock transaction selection algorithm #1240

pull luke-jr wants to merge 6 commits into bitcoin:master from luke-jr:txn_prio changing 6 files +276 −73
  1. luke-jr commented at 1:39 PM on May 9, 2012: member
    • Transaction fees for children might help the parent transaction get confirmed
    • Transaction fees can boost the priority of transactions included
  2. GetFloatArg utility function 05db8ecfdb
  3. luke-jr commented at 1:40 PM on May 9, 2012: member

    So far, I have done some minimal testing by analyzing the output of getmemorypool.

  4. luke-jr commented at 1:31 PM on May 10, 2012: member

    Eligius has found 2 valid blocks (and none invalid) with this code (plus #1246, for safety) so far, at its default settings. I am now testing with a huge weigh toward transaction fees, to increase the likelihood of dependent transactions paying for their parents (and therefore risking any potential child-before-parent problems).

  5. luke-jr commented at 2:59 PM on May 10, 2012: member

    Things I need to address:

    1. False "may be used uninitialized" warnings
    2. Config option names differ between actual code and -help
    3. Second-pass priorities should be printed with -printpriority
    4. Fee influence should be multiplied by total input value (input please: is this a good idea? should the total input be reduced by the fee amount first?)
    5. -printpriority shouldn't require fDebug (is this ok?)
  6. luke-jr commented at 7:15 PM on May 11, 2012: member

    FWIW, 10 total valid blocks found with this (most recent is …30E6C09A4FF45348A0EF0AA1A), zero issues caught by #1246, and zero invalid blocks logged by bitcoind.

  7. luke-jr commented at 1:18 AM on May 12, 2012: member

    Integrated my 5 "things to address".

  8. luke-jr commented at 7:19 PM on May 19, 2012: member

    Eligius has been running this from block 179513 (56 blocks found) and EclipseMC from 180573 (11 blocks), totalling 67 valid blocks with no problems found.

    (EMC: 180788(1040); Eligius: …9DA7D49DC2539F9D299AF8E5A)

  9. luke-jr commented at 5:58 AM on May 23, 2012: member

    Also passes the unit tests I just wrote on #1246.

  10. luke-jr commented at 11:56 AM on May 30, 2012: member

    This seems to be be excessively slow, and possibly exploitable right now.

  11. sipa commented at 4:25 PM on May 30, 2012: member

    Define "this" ?

  12. luke-jr commented at 5:18 PM on May 30, 2012: member

    This pull request. Eligius is getting stuck in some huge dependency trees, it seems. Trying to figure it out, but don't have time just this second.

  13. Bugfix: %-12I64d is not valid and causes the parameter to be skipped, use %12"PRI64d" instead
    Conflicts:
    
    	src/walletdb.cpp
    5bb1a1f58c
  14. Refactor CreateNewBlock transaction selection algorithm
    - Transaction fees for children might help the parent transaction get confirmed
    - Transaction fees can boost the priority of transactions included
    fddbbe0a61
  15. Merge branch 'getfloatarg' into txn_prio_0.6.0 919e4442a8
  16. Make transaction priority weights user-configurable 02077ee878
  17. Merge branch 'txn_prio_0.6.0' into txn_prio
    Conflicts:
    	src/db.cpp
    	src/init.cpp
    	src/main.cpp
    	src/main.h
    e7e7df1ae0
  18. luke-jr commented at 8:05 PM on June 12, 2012: member

    Fixed the major performance hit from complex dependency trees. Still not as fast as the old algorithm, but not absurdly slow either. I'd say the ability to pay for "parent" transactions is worth it.

  19. luke-jr commented at 8:05 PM on June 12, 2012: member

    (Fix verified by about 10 days of testing on Eligius)

  20. sipa commented at 3:33 PM on June 14, 2012: member

    I certainly agree to the idea of this patch. I haven't checked the source yet though.

  21. gavinandresen commented at 1:39 AM on June 19, 2012: contributor

    Need to be very careful not to accidentally introduce a potential DoS attack by arranging transactions that require N^2 time or space to figure out fees/priority.

  22. luke-jr commented at 1:52 AM on June 19, 2012: member

    @gavinandresen I think SatoshiDice tested that for me (the fix from ~16 days ago)

  23. gavinandresen commented at 12:20 AM on July 13, 2012: contributor

    Could you write up a gist that explains what formula for priority you're using? And maybe talk about how it will handle transactions from old clients (who calculate priority the old way) ?

  24. luke-jr commented at 1:28 AM on July 13, 2012: member
    • DepthWeight = user configurable (default: 1.0)
    • FeeWeight = user configurable (default: 1.0)
    • DepthScore = sum(sum(value * depth) for each input)
    • FeeScore = sum(value for each input) * fee
    • WeighedScore = (DepthScore * DepthWeight) + (FeeScore * FeeWeight)
    • EffectiveSize = datasize + sum(datasize for each (transaction this depends on that is not yet in a block))
    • Priority = WeighedScore / EffectiveSize

    Old clients don't take priority into consideration at all right now AFAIK, nor does this code (or the code it's replacing) completely exclude transactions based on their priority.

  25. gavinandresen commented at 3:53 PM on July 13, 2012: contributor

    NACK, the priority formula would make it easy for somebody with (say) 100,000 BTC to pay tiny fees and get priority over higher-fee-paying transactions. That's a bad incentive, it would encourage people to do dangerous things like keep more funds in their 'hot' wallet or add extra inputs to their transactions (and just have bigger change outputs) to get higher priority.

  26. luke-jr commented at 3:56 PM on July 13, 2012: member

    So, should I take the input value out of FeeScore?

  27. jgarzik commented at 3:43 PM on August 1, 2012: contributor

    Sadly, in addition to being NAK'd this conflicts heavily with @gavinandresen 's work redoing CreateNewBlock() You should work with @gavinandresen to coordinate changes in that area, before posting another pull request relating to CreateNewBlock() + TX selection/fees.

  28. jgarzik closed this on Aug 1, 2012

  29. suprnurd referenced this in commit 471365bf6c on Dec 5, 2017
  30. lateminer referenced this in commit 8ce95a8025 on Jan 22, 2019
  31. lateminer referenced this in commit 310deb9b0d on May 6, 2020
  32. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me