Skip to content

Conversation

dimitaracev
Copy link
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

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 5, 2023

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.

@dimitaracev dimitaracev force-pushed the validation-replace-min-bip9-height-to-min-bip9-start-time branch from e6b570b to 3460721 Compare April 5, 2023 22:17
@dimitaracev dimitaracev changed the title validation: Replicate MinBIP9WarningHeight with MinBIP9WarningStartTime validation: Replace MinBIP9WarningHeight with MinBIP9WarningStartTime Apr 5, 2023
@@ -84,7 +84,8 @@ class CMainParams : public CChainParams {
consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
consensus.MinBIP9WarningHeight = 483840; // segwit activation height + miner confirmation window
// Preferably to be updated with every release to avoid checking older blocks for warnings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is to be updated every release, there need to be clear rules as how to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😄.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more that MinBIP9WarningHeight might be lower, 0 in particular.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@dimitaracev dimitaracev force-pushed the validation-replace-min-bip9-height-to-min-bip9-start-time branch 2 times, most recently from d477d40 to 8d39803 Compare June 12, 2023 16:34
@dimitaracev
Copy link
Contributor Author

dimitaracev commented Jun 12, 2023

Went with the approach proposed by @ajtowns .

@dimitaracev dimitaracev force-pushed the validation-replace-min-bip9-height-to-min-bip9-start-time branch from 8d39803 to eea2952 Compare June 12, 2023 17:59
@luke-jr
Copy link
Member

luke-jr commented Jul 4, 2023

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?

@achow101
Copy link
Member

Are you still working on this?

@dimitaracev dimitaracev force-pushed the validation-replace-min-bip9-height-to-min-bip9-start-time branch from eea2952 to 8fa7ece Compare October 16, 2023 20:31
@dimitaracev
Copy link
Contributor Author

dimitaracev commented Oct 16, 2023

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 5, 2024

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

@TheCharlatan
Copy link
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.

@achow101
Copy link
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.

@achow101 achow101 closed this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants