init: Remove dead code in LoadChainTip #15999

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:1905-initNoDead changing 1 files +1 −11
  1. MarcoFalke commented at 9:55 PM on May 9, 2019: member

    LoadChainTip sets ::ChainActive() based on pcoinsTip's best block. LoadChainTip is never called when that block is null, so we can remove all code from within that method that is only executed when that block is null.

    Fixes #15967 Inconsistent locking behavior in LoadChainTip

  2. MarcoFalke added the label Refactoring on May 9, 2019
  3. MarcoFalke added the label Validation on May 9, 2019
  4. MarcoFalke force-pushed on May 9, 2019
  5. DrahtBot commented at 12:16 AM on May 10, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15921 (Tidy up ValidationState interface by jnewbery)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  6. gmaxwell commented at 2:51 AM on May 10, 2019: contributor

    This is essentially just reverting b0f32497b873cd1eaf0be86f8e265355aa86174f PR doesn't seem to address why this prior change was inapplicable.

  7. MarcoFalke commented at 11:48 AM on May 10, 2019: member

    See the immediate follow-up commit 13ab353829bfcf928a0dd88cc9841e6515eea111 that disabled the code. So the code was never executed and tested as part of a release. (And if it ever were executed it would immediately crash with an assert failure anyway.)

    If you want to enable that code, it needs to be properly reviewed and tested.

  8. practicalswift commented at 7:51 PM on May 12, 2019: contributor

    Concept ACK

  9. in src/validation.cpp:3957 in fa32fd052b outdated
    3963 | -            LogPrintf("%s: failed to activate chain (%s)\n", __func__, FormatStateMessage(state));
    3964 | -            return false;
    3965 | -        }
    3966 | -    }
    3967 | -
    3968 | +    assert(!pcoinsTip->GetBestBlock().IsNull());
    


    promag commented at 3:34 PM on May 13, 2019:

    Could move this up, before above condition?


    MarcoFalke commented at 3:54 PM on May 13, 2019:

    Done and added comment


    promag commented at 3:59 PM on May 13, 2019:

    Cool.

  10. init: Remove dead code in LoadChainTip fa86c8aec6
  11. MarcoFalke force-pushed on May 13, 2019
  12. promag commented at 3:59 PM on May 13, 2019: member

    utACK fa86c8aec611a9b9d2f53960c92419cf2a8bb92d.

  13. practicalswift commented at 4:33 PM on May 13, 2019: contributor

    utACK fa86c8aec611a9b9d2f53960c92419cf2a8bb92d

  14. ryanofsky approved
  15. ryanofsky commented at 7:17 PM on May 15, 2019: member

    utACK fa86c8aec611a9b9d2f53960c92419cf2a8bb92d. LoadChainTip isn't called currently when pcoinsTip best block is null due to this line: https://github.com/bitcoin/bitcoin/blob/2d16fb7a2b6a9e5a2535295d2de03e27c2438d1f/src/init.cpp#L1573, and the assert should prevent it from being erroneously called in the future.

  16. jamesob approved
  17. jamesob commented at 7:31 PM on May 15, 2019: member

    utACK https://github.com/bitcoin/bitcoin/pull/15999/commits/fa86c8aec611a9b9d2f53960c92419cf2a8bb92d

    Single use of LoadChainTip() is here, and is only called when pcoinsTip has contents; verify with git grep LoadChainTip\(.

  18. laanwj commented at 10:53 AM on May 17, 2019: member

    utACK fa86c8aec611a9b9d2f53960c92419cf2a8bb92d It's only confusing to have this if it isn't ever reached—the code can always be re-introduced later when necessary.

  19. MarcoFalke merged this on May 17, 2019
  20. MarcoFalke closed this on May 17, 2019

  21. MarcoFalke referenced this in commit a822a0e4f6 on May 17, 2019
  22. MarcoFalke deleted the branch on May 17, 2019
  23. deadalnix referenced this in commit 094184ba43 on Jun 19, 2020
  24. ftrader referenced this in commit d225244b90 on Aug 17, 2020
  25. kittywhiskers referenced this in commit 73ccadda7a on Oct 10, 2021
  26. kittywhiskers referenced this in commit d82c1b700e on Oct 10, 2021
  27. kittywhiskers referenced this in commit 07110eeaeb on Oct 10, 2021
  28. kittywhiskers referenced this in commit b3bc1e04db on Oct 16, 2021
  29. kittywhiskers referenced this in commit 993a65ef0d on Oct 16, 2021
  30. kittywhiskers referenced this in commit 31b2b53b9b on Oct 16, 2021
  31. Munkybooty referenced this in commit 9a7b4cab65 on Oct 17, 2021
  32. kittywhiskers referenced this in commit 52390ef58e on Oct 21, 2021
  33. kittywhiskers referenced this in commit 51f73b558f on Oct 22, 2021
  34. Munkybooty referenced this in commit 08710599bf on Oct 22, 2021
  35. Munkybooty referenced this in commit 083b301262 on Oct 22, 2021
  36. Munkybooty referenced this in commit a8807d2dce on Oct 23, 2021
  37. Munkybooty referenced this in commit 5a319a15ce on Oct 26, 2021
  38. Munkybooty referenced this in commit 69c9144d01 on Oct 28, 2021
  39. pravblockc referenced this in commit ec20de16ab on Nov 18, 2021
  40. DrahtBot locked this on Dec 16, 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-14 21:14 UTC

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