validation: Replace MinBIP9WarningHeight with MinBIP9WarningStartTime #27427

pull dimitaracev wants to merge 1 commits into bitcoin:master from dimitaracev:validation-replace-min-bip9-height-to-min-bip9-start-time changing 3 files +11 −1
  1. dimitaracev commented at 9:56 pm on April 5, 2023: contributor

    This PR addresses comment. Replaces CChainParams::MinBIP9WarningHeight with CChainParams::MinBIP9WarningStartTime. It is then used in WarningBitsConditionChecker::BeginTime to only check block headers that are newer. This helps reduce the block headers that are being scanned for warnings.

    cc @ajtowns

  2. DrahtBot commented at 9:56 pm on April 5, 2023: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK TheCharlatan

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30560 (refactor: Add consteval uint256 constructor by hodlinator)
    • #30377 (refactor: Add consteval uint256{“str”} by hodlinator)
    • #27433 (getblocktemplate improvements for segwit and sigops by Sjors)
    • #26201 (Remove Taproot activation height by Sjors)

    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.

  3. DrahtBot added the label Validation on Apr 5, 2023
  4. dimitaracev force-pushed on Apr 5, 2023
  5. dimitaracev renamed this:
    validation: Replicate MinBIP9WarningHeight with MinBIP9WarningStartTime
    validation: Replace MinBIP9WarningHeight with MinBIP9WarningStartTime
    on Apr 5, 2023
  6. in src/kernel/chainparams.cpp:87 in 3460721fa7 outdated
    83@@ -84,7 +84,8 @@ class CMainParams : public CChainParams {
    84         consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
    85         consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
    86         consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
    87-        consensus.MinBIP9WarningHeight = 483840; // segwit activation height + miner confirmation window
    88+        // Preferably to be updated with every release to avoid checking older blocks for warnings
    


    maflcko commented at 7:15 am on April 6, 2023:
    If this is to be updated every release, there need to be clear rules as how to do that.

    dimitaracev commented at 5:08 pm on April 8, 2023:
    IMO, it makes sense for it to to be updated to the day of the release with the assumption that the main chain does not contain any warning bits up until then. What are your thoughts?

    ajtowns commented at 5:01 am on April 11, 2023:
    Setting it to N will prevent warnings that would otherwise be triggered by version bits being set in blocks up to N+2015; so you pick a value where a reorg back to N+2015 or lower is sufficiently unlikely (for similar values of “sufficiently unlikely” as we’d use to bury successfully activated soft forks) and that getblockchaininfo from above that height doesn’t already include an Unknown new rules activated warning. (If it does, it’s obviously important to verify that the new rules that were signalled aren’t something we should enforce first. Once that’s figured out, it’s then fine to ignore the signalling).

    ajtowns commented at 5:04 am on April 11, 2023:
    (Maybe it would be better to do std::max(MinBIP9WarningHeight, nMinerConfirmationWindow) - nMinerConfirmationWindow in WarningBitsConditionChecker::BeginTime() ; then you’re just ignoring version bits prior to MinBIP9WarningHeight)

    dimitaracev commented at 9:32 pm on April 22, 2023:
    I think std::max(MinBIP9WarningHeight, nMinerConfirmationWindow) is unnecessary since I doubt that nMinerConfirmationWindow would be higher than MinBIP9WarningHeight. As for the rest, it makes sense since it removes the burden of having to keep in mind that a parameter would need adjusting in the future. I initially changed it to a timestamp due to your comment on the other PR :smile:.

    ajtowns commented at 3:46 am on June 13, 2023:
    It’s more that MinBIP9WarningHeight might be lower, 0 in particular.

    ajtowns commented at 3:55 pm on July 5, 2023:

    I’m not sure what I was trying to suggest in the comment above: having BeginTime() return a height doesn’t make sense. Maybe I confused myself by using N as a block height when the PR at the time was already time based?

    I think BeginTime() { return MinBIP9WarningTime > nPowTargetTimespan ? MinBIP9WarningTime - nPowTargetTimespan : MinBIP9WarningTime; } might make reasonable sense, with the idea being to check that there aren’t any warning reported, then set MinBIP9WarningTime to a timestamp from a few months ago (and use the same timestamp for mainnet and testnet, with 0 for signet and regtest).

  7. dimitaracev force-pushed on Jun 12, 2023
  8. dimitaracev force-pushed on Jun 12, 2023
  9. DrahtBot added the label CI failed on Jun 12, 2023
  10. dimitaracev commented at 4:40 pm on June 12, 2023: contributor
    Went with the approach proposed by @ajtowns .
  11. dimitaracev force-pushed on Jun 12, 2023
  12. DrahtBot removed the label CI failed on Jun 12, 2023
  13. luke-jr commented at 7:21 pm on July 4, 2023: member
    The current PR doesn’t make sense to me. It’s treating a height as a time? But no block would have a time before a height… So this just adds calculations that do nothing?
  14. achow101 commented at 4:57 pm on September 20, 2023: member
    Are you still working on this?
  15. dimitaracev force-pushed on Oct 16, 2023
  16. dimitaracev commented at 8:36 pm on October 16, 2023: contributor

    Are you still working on this?

    Yes, was quite busy these past couple of months.

    The current PR doesn’t make sense to me. It’s treating a height as a time? But no block would have a time before a height… So this just adds calculations that do nothing?

    You are correct, it was initially implemented as MinBIP9WarningTime but changed due to a suggestion by @ajtowns . The implementation now uses time instead of height.

  17. validation: change WarningBitsConditionChecker::BeginTime 31a810ff25
  18. dimitaracev force-pushed on Oct 16, 2023
  19. DrahtBot added the label CI failed on Oct 16, 2023
  20. DrahtBot removed the label CI failed on Oct 16, 2023
  21. DrahtBot added the label CI failed on Jan 13, 2024
  22. achow101 requested review from TheCharlatan on Apr 9, 2024
  23. DrahtBot added the label Needs rebase on Aug 5, 2024
  24. DrahtBot commented at 11:03 pm on August 5, 2024: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

  25. TheCharlatan commented at 7:32 am on August 26, 2024: contributor
    Concept ACK, but needs rebase and the title and description should be updated, since this is no longer replacing the height, but is instead adding logic to the start time of a period.
  26. achow101 commented at 2:33 pm on October 15, 2024: member
    Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened.
  27. achow101 closed this on Oct 15, 2024


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: 2024-11-21 09:12 UTC

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