Generalize the remove-outputs check for fully-prunable transactions. #3163

pull sipa wants to merge 1 commits into bitcoin:master from sipa:allunspendable changing 2 files +9 −6
  1. sipa commented at 7:30 PM on October 26, 2013: member

    Instead of explicitly testing for the presence of any output, and dealing with this case specially, just interpret it as an empty CCoins.

    The case previously caught using the HaveCoins check, is now handled by the generic outs != outsBlock test.

    This fixes #3156 and replaces #3143.

  2. sipa commented at 8:23 PM on October 26, 2013: member

    Tested it myself. I can reproduce the failed disconnect at startup in master, but no problem appears with this patch.

  3. gmaxwell commented at 8:37 PM on October 26, 2013: contributor

    I can also confirm that it makes the startup problem go away. Perhaps we should add a couple of test cases with these in a reorg in pulltester before we call it cured? (E.g. four transactions: 1 op_return, 2 op_return, 1 op_return and one regular, in both orders. Mine them, reorg them out, put them back in later.)

  4. sipa commented at 9:35 PM on October 26, 2013: member

    @gmaxwell PullTester doesn't seem to be running the comparison tool anymore.

  5. petertodd commented at 4:01 AM on October 28, 2013: contributor

    Odd, I tried to reproduce the problem in git master with ./bitcoind -checkblocks=10500, which is more than enough to check the failing block, but I'm not seeing the error. Tried default checklevel, and checklevel=4 as well.

  6. gmaxwell commented at 4:09 AM on October 28, 2013: contributor

    @petertodd not odd at all, the reorg test is memory limited and only goes as far back as the dbcache size allows. Effectively the checklevel is lower for blocks further back than that.

  7. petertodd commented at 4:31 AM on October 28, 2013: contributor

    Ah. With -dbcache set appropriately I can reproduce the bug on master, and this pull-req fixes it.

    I think this patch needs some comments explaining what's going on re: the immediately pruned case, but otherwise looks good. Maybe something like the following:

    Check that all outputs are available and match the outputs in the block itself
    exactly. Note that transactions with only provably unspendable outputs won't
    have outputs available even in the block itself, so we handle that case
    specially with outsEmpty.
    

    Finally it'd be ideal if GetCoins() had an assert checking that the database never had an empty CCoins structure in it, although you'd need to either do this three times: CCoinsViewCache::GetCoins(), CCoinsViewDB::GetCoins() and CCoinsViewMemPool::GetCoins() or make a wrapper function in CCoinsView()

  8. jgarzik commented at 1:41 PM on October 28, 2013: contributor

    ACK... let's get this merged.

    This fixes testnet for me.

  9. sipa commented at 1:57 PM on October 28, 2013: member

    @petertodd An empty CCoins cannot even be serialized - there is no storage format that corresponds to. Enough as a guarantee that it doesn't occur in the database? :)

  10. Generalize the remove-outputs check for fully-prunable transactions.
    Instead of explicitly testing for the presence of any output, and
    dealing with this case specially, just interpret it as an empty
    CCoins.
    
    The case previously caught using the HaveCoins check, is now handled
    by the generic outs != outsBlock test.
    170e02deaf
  11. sipa commented at 2:01 PM on October 28, 2013: member

    Updated with peter's suggestions.

  12. petertodd commented at 2:08 PM on October 28, 2013: contributor

    @sipa That's a pretty good guarantee!

    ACK

  13. Diapolo commented at 2:11 PM on October 28, 2013: none

    Currently integrating this in a local build to also see if it helps :).

  14. jgarzik commented at 2:11 PM on October 28, 2013: contributor

    retested and re-ACK w/ updated equality check

  15. BitcoinPullTester commented at 3:24 PM on October 28, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/170e02deaf2bb1f8f79ffafbb4ff7f62cb933c62 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.

  16. gmaxwell commented at 3:34 PM on October 28, 2013: contributor

    ACK

  17. gmaxwell referenced this in commit 377cd74930 on Oct 28, 2013
  18. gmaxwell merged this on Oct 28, 2013
  19. gmaxwell closed this on Oct 28, 2013

  20. Bushstar referenced this in commit 001c4338bf on Apr 8, 2020
  21. 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-17 15:15 UTC

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