-
Notifications
You must be signed in to change notification settings - Fork 38.7k
rpc: have getblocktemplate mintime account for timewarp #31600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31600. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
|
ckpool uses curtime: https://bitbucket.org/ckolivas/ckpool/src/bb7b0aebe08ed99d45b8701af2d65bfcdbef0932/src/bitcoin.c#lines-196 does this mean that currently, public-pool will create an invalid block on testnet4 if in a difficulty-adjustment period and timestamps have moved too far forward? |
|
@remcoros a testnet4 pool that uses At first glance, it seems that might happen with public-pool. The easiest workaround would be to use |
|
Concept ACK |
I think adding the example to the functional test is good, but it is not clear from the description what the griefing attack is that it seeks to prevent. |
0cf11cf to
f04e472
Compare
It doesn't prevent it, it merely demonstrates. It can only be prevented if the miner actually uses I expanded the comment. |
test/functional/mining_basic.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should also say that the next block miner also has to use their own wall clock time, or something from a hand-rolled calculation and not the one provided by the template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expanded the comment.
f04e472 to
5ba7700
Compare
sedited
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 5ba770089e9ecf82645ae60aa2bc7f26085a5573
tdb3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Planning to circle back and want to make sure #30941 isn't applicable anymore before closing.
|
I didn't know about #30941. Let me know if there's anything there that you'd like me to add here. After that I'll address the other feedback, in particular I should probably pick a higher number for |
Since the test approach has changed, I'm not seeing more to add. |
5ba7700 to
4d8dea9
Compare
|
Rebased, picked a different I also renamed |
tdb3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code review ACK 4d8dea9cb92efa362f72b0c2a5b89d312b452c0a
Comments were addressed. Clarity increased.
fjahr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 4d8dea9cb92efa362f72b0c2a5b89d312b452c0a
The comments in the tests are nice!
test/functional/mining_basic.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could have had anther info log here for completeness but completely optional
|
Would have been nice if the unrelated demonstrative functional test was not bundled with the bug fix. |
|
@darosior the test fails without the code changes (they're implicitly tested), so it's annoying to separate. If it gets uncomfortably close for v29 I'll do that though. |
|
Actually it's not entangled, so would be easy to take the last commit out if necessary. |
darosior
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 4d8dea9cb92efa362f72b0c2a5b89d312b452c0a on the code changes for the mintime bug fix. Not a fan of merging demonstration code for external (broken) software in the Bitcoin Core test suite, but the code in question is concise and related to what Core implements so.. 🤷
test/functional/mining_basic.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words for this "attack" to succeed the miner needs to run broken software that completely ignores values provided by our own software, which this functional test is supposed to check in the first place.
It's important to test that in the presence of a block as far in the future as possible our getblocktemplate would return a correct mintime, but i don't think the Bitcoin Core functional tests are an appropriate place to demonstrate however broken software that disregards values provided by Bitcoin Core may or may not behave.
Don't get me wrong from the purpose of the Delving thread it's great that you translated the situation you're concerned about into code. This is helpful for the purpose of this thread. But is it useful for the Bitcoin Core project to merge such demonstration code?..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is room for the functional tests to demonstrate some "common misconfigurations" to help avoid regressions, but agree that this case here is probably best documented and described elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in #31725
|
People who reviewed this PR may be interested in giving #31376 a look. |
|
"allowed" isn't necessarily consensus rules. It would be strictly BIP 23 compatible to just reject rpc submissions with an earlier time. I don't think we need to go that far though - probably fine to tolerate it |
Before bip94 there was an assumption that the minimum permitted timestamp is GetMedianTimePast() + 1. This commit splits a helper function out of UpdateTime() to obtain the minimum time in a way that takes the timewarp attack rule into account.
Previously in getblocktemplate only curtime took the timewarp rule into account. Mining pool software could use either, though in general it should use curtime.
fb2b68d to
e1676b0
Compare
|
I was indeed waiting for more people to chime in. Pushed the simplification to always apply the rule. |
#30681 fixed the
curtimefield ofgetblocktemplateto take the timewarp rule into account. However I forgot to do the same for themintimefield, which was hardcoded to usepindexPrev->GetMedianTimePast()+1.This PR adds a helper
GetMinimumTime()and uses it for themintimefield.#31376 changed the
curtimefield to always account for the timewarp rule. This PR maintains that behavior.Note that
mintimenow always applies BIP94, including on mainnet. This makes future softfork activation safer.It could be backported to v28.