getmininginfo pooledtx: uninitialized? #794

issue gavinandresen opened this issue on February 3, 2012
  1. gavinandresen commented at 2:42 AM on February 3, 2012: contributor

    Running some more fuzzing tests, I noticed a bug in the new getmininginfo information:

    gavin$ ./bitcoind -datadir=testnet-box/3 getmininginfo { "blocks" : 218, "currentblocksize" : 1000, "currentblocktx" : 0, "difficulty" : 0.12500000, "errors" : "", "generate" : true, "genproclimit" : 1, "hashespersec" : 0, "pooledtx" : 18446744073709551613, "testnet" : true }

    I think hashespersec should be greater than zero, also...

  2. TheBlueMatt commented at 2:46 AM on February 3, 2012: member

    Does #766 fix it?

  3. gavinandresen commented at 2:59 AM on February 3, 2012: contributor

    Haven't tried #766. Test setup is:

    3 testnet-in-a-box nodes, with node 1 sending fuzzed transactions to 2. Node 3 is listening in and CPU mining.

    valgrind doesn't complain about uninitialized vars (you have to compile openssl and bdb specially to make valgrind not trip on them), and getmininginfo returns reasonable info at first.

    But it is reproducible, pooledtx goes wacky after a while.

  4. luke-jr commented at 3:12 AM on February 3, 2012: member

    My best guess is a missing-lock condition reading the variable from getmininginfo while the other thread is updating it. Does it go back to normal after the misread?

  5. jgarzik commented at 3:23 AM on February 3, 2012: contributor

    hashespersec should be zero, unless the internal reference miner is running.

  6. jgarzik commented at 4:21 AM on February 3, 2012: contributor

    I guess generate=true, but are all the blocks downloaded?

  7. dooglus commented at 11:06 AM on February 9, 2012: contributor

    In the dup I just closed I noticed that the pooledtx went crazy around the same time as a new block was found.

  8. dooglus commented at 12:01 PM on February 9, 2012: contributor

    The 'crazy' number 18446744073709551613 is in fact just -3 printed as an unsigned 64 bit int.

    The bug is caused by CTransaction::RemoveFromMemoryPool() doing --nPooledTx for every transaction in the newly found block whether or not it was in our memory pool or not.

    CBlock::SetBestChain does this: // Delete redundant memory transactions BOOST_FOREACH(CTransaction& tx, vtx) tx.RemoveFromMemoryPool();

    and CTransaction::RemoveFromMemoryPool() doesn't check whether we have each transaction or not - it erase()s it anyway, and decrements the counter.

  9. dooglus referenced this in commit 74f28bf1fd on Feb 9, 2012
  10. gavinandresen closed this on Feb 10, 2012

  11. sipa referenced this in commit b0cfef3214 on Feb 11, 2012
  12. rebroad commented at 10:18 AM on May 31, 2012: contributor

    How often does it happen that it tried to remove a transaction that wasn't in the memory pool?

  13. dooglus commented at 10:19 AM on May 31, 2012: contributor

    It doesn't. My change comment was sloppy.

  14. rebroad commented at 10:20 AM on May 31, 2012: contributor

    oh... what would have been the unsloppy comment?

  15. dooglus commented at 10:32 AM on May 31, 2012: contributor

    "Only attempt to remove transactions from memory pool when [...]" would be better.

    When a new block is found, the code was attempting to remove each of the transactions in the block from the memory pool of pending transactions. This would quietly succeed, doing nothing, for transactions which weren't in the memory pool, but it was decrementing the pool size counter even if it didn't remove the transaction, leading to the pool size counter wrapping around to a huge value.

    So my change checks to see if each transaction is in the memory pool before attempting to remove it from the pool.

  16. rebroad commented at 10:40 AM on May 31, 2012: contributor

    ah, thanks. now I understand. I guess this could be a location in the code where I could make a patch that restricts relaying blocks that are not including free transactions. I think it would be good to give this option to full node operators who aren't mining. So far various patches have been included that help raise mining fees. Such a patch would help to encourage miners to include free txs thereby lowering mining fees. I believe it should be down to the node operators to decide/vote on mining fees rather than the developers. I suspect that the value of bitcoin could be affected by such a change. Perhaps the more mining fees go up, the higher the value of a bitcoin increases too? If so, that would explain a motivation for the developers (who probably own substantial bitcoins) to see the mining fees increase.

  17. dooglus commented at 10:46 AM on May 31, 2012: contributor

    This isn't the place to discuss the issue.

    I would suggest making a thread in the development board here: https://bitcointalk.org/index.php?board=6.0 to discuss it.

    [ But I doubt reducing mining fees from their currently very low level would have any impact on the value of bitcoins. A concern is that unless transaction fees increase to match the falling rewards for mining, many miners will stop mining, leaving the network more vulnerable to attack. ]

  18. coblee referenced this in commit c5a5165b1a on Jul 17, 2012
  19. coblee referenced this in commit 426f440532 on Jul 17, 2012
  20. ptschip referenced this in commit 0d18a4ec28 on Oct 13, 2017
  21. MarcoFalke 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-16 03:16 UTC

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