removeForReorg calls once-per-disconnect-> once-per-reorg #6656

pull TheBlueMatt wants to merge 5 commits into bitcoin:master from TheBlueMatt:mempoolonreorg changing 6 files +88 −60
  1. TheBlueMatt commented at 11:35 PM on September 9, 2015: contributor

    Based on #6595

  2. Add failing test checking timelocked-txn removal during reorg 85871dd5a1
  3. Fix removal of time-locked transactions during reorg 2276af1501
  4. Fix comment in removeForReorg b394d266de
  5. Make indentation in ActivateBestChainStep readable 49a09add82
  6. removeForReorg calls once-per-disconnect-> once-per-reorg 66aea039a6
  7. TheBlueMatt cross-referenced this on Sep 9, 2015 from issue Take the training wheels off anti-fee-sniping by petertodd
  8. dcousens commented at 2:45 AM on September 10, 2015: contributor

    For those unaware, you can view the diff without whitespace changes by adding ?w=0 to the url.

    utACK.

  9. btcdrak commented at 9:18 AM on September 10, 2015: contributor

    utACK

  10. sdaftuar commented at 1:42 PM on September 10, 2015: member

    What do you think about moving the calls to mempool.removeForReorg() that are inside ActivateBestChainStep() to ActivateBestChain()? I think that would probably make things a bit cleaner.

  11. TheBlueMatt commented at 11:24 PM on September 10, 2015: contributor

    @sdaftuar I'd feel bad calling removeForReorg and iterating over the mempool after each new block (instead of only if we actually called Disconnect). It would simplify the code some, but not much? I dunno, do you think its worth it?

  12. sipa commented at 11:28 PM on September 10, 2015: member

    It should be in Step, I think. In between the calls to Step cs_main is released, so the result is observable. I don't think we want to release cs_main while the mempool is in an inconsistent state.

  13. TheBlueMatt commented at 11:31 PM on September 10, 2015: contributor

    I believe @sdaftuar meant to put the call before cs_main was released in ActivateBestChain so that you dont have to do it before every return statement.

  14. sipa commented at 11:31 PM on September 10, 2015: member

    Ah, no opinion.

  15. sdaftuar commented at 12:43 AM on September 11, 2015: member

    Yeah that's what I had in mind, except my thought was to continue to use the blocksDisconnected bool to signal the caller it should make the call to mempool.removeForReorg() (ie pass in a new bool by reference and populate it in ActivateBestChainStep). It just seems less error prone for future changes to the code to not have to guard every place ActivateBestChainStep returns (and since ActivateBestChainStep asserts that the caller holds cs_main, so it doesn't seem inherently strange to do it in the caller).

  16. sdaftuar commented at 2:48 PM on September 11, 2015: member

    @TheBlueMatt: this is what I had in mind: https://github.com/sdaftuar/bitcoin/commit/cc4b7b0959c8fe3e12337cb1bfd642ad7f042449

    Eh, maybe it's just personal taste which formulation is better, you can take it or leave it. I'll think about additional testing.

  17. petertodd commented at 5:42 PM on September 21, 2015: contributor

    Looks like this needs a rebase now that #6654 is merged.

  18. laanwj added the label Consensus on Sep 23, 2015
  19. TheBlueMatt commented at 12:26 AM on September 26, 2015: contributor

    This needs a more involved rebase, because it requires a more thourough checking that it is still correct. Closing for now, someone can come along and fix it again later.

  20. TheBlueMatt closed this on Sep 26, 2015

  21. sdaftuar cross-referenced this on Oct 30, 2015 from issue [Mempool] Improve removal of invalid transactions after reorgs by sdaftuar
  22. bitcoin 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-05-20 06:55 UTC