-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Change -maxtimeadjustment default from 70 minutes to 0 #24606
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
Will add a release note if concept/approach here is good. |
Ah, it looks like bitcoinxt/bitcoinxt#140 did the same. The default remains 0 since: https://github.com/bitcoinxt/bitcoinxt/blob/48bbdd48e71af98c467caf31cbf93e8339e2ae7e/src/timedata.h#L13 |
26d54ad
to
5c81837
Compare
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
The time data comes from untrusted peers over cleartext, unauthenticated and unencrypted, so it could be bogus. However, I guess, the assumption here is that most of the nodes are honest. Note that we choose those 200 peers randomly from our addrman, sort their datas and only take the median. So, an evil actor who wants to mess with our perceived time has to control >100 of those peers, or >50% of our addrman entries.
What is the most useful thing that could happen if the system clock is wrong indeed during bitcoind
startup and it gets adjusted by those 200 honest samples (in a good way)? Or in other words - what will go wrong in that case if we refuse to adjust the clock?
src/test/timedata_tests.cpp
Outdated
@@ -16,7 +16,16 @@ | |||
|
|||
#include <boost/test/unit_test.hpp> | |||
|
|||
BOOST_FIXTURE_TEST_SUITE(timedata_tests, BasicTestingSetup) | |||
/** | |||
* Set -maxtimeadjustment to 70 minutes for testing purposes; this was |
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.
Does it make sense to test with a non-default value? Or should we test both old (70) and the new (0)?
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.
For a few of the tests it might make sense, if this approach goes forward.
I am not sure this is the right way to go. If we think the changes are ok to make, we should just remove adjusted time. If we don't, then we shouldn't do the changes here either. No objection to the changes here, but to me it seems to combine the worst of everything:
|
Concept ACK. Seems like a good one-release-only stage before complete removal? |
@luke-jr yes, this seems like the right thing to do for users. |
@MarcoFalke indeed, this change doesn't preclude removing the code permanently afterward. if I understand correctly, this code has been in the codebase since |
If there is any user using this with a valid use case in mind, we shouldn't remove it nor deprecate it. In that case, we should probably fix it so that users with a proper system clock aren't negatively affected by adjusted time and the users with an improper system clock are covered in all/most cases where it is needed. So it would be good to know if any users are using this, and I think the most effective way to find out is by removing it (User will see an init error on startup, if they are using it). I am not sure how many users would notice with just the default value changed and a release note snippet. An alternative would be to add a Again, I am not against the changes here. They look fine and I don't see any harm in them. I am only wondering how much benefit they will bring. |
The concept of timedata was already introduced by Satoshi, it's historical 😄 Concept ACK on removing it though. So there are three possibilities discussed:
While there seems to be consensus that 3) doesn't make sense, is there much of a difference between 1) and 2) if it all happens for the 24.0 release (which seems realistic?). |
If this is indeed the approach of the project today nothing should ever be deprecated (including say the legacy wallet in #20160) because you can never be sure a user isn't using it. I'm not sure when this switch to never deprecating anything happened. There are various examples (e.g. #8780 and more recent examples) in the past of things being deprecated over multiple versions. Of course giving time to developers/users to prepare for the changes and good communication are important. Maybe something to bring up in the Core dev meeting this week. |
@michaelfolkson let's please stay on this topic. RPC result fields (and sometimes input params) are still deprecated and a config option may possibly be removed (having a deprecation process for this may be an improvement). Removing an RPC outright seems much more rare to avoid needlessly breaking the API / user space, and sometimes an RPC is made hidden (not returned in the CLI help) but not removed. |
@mzumsande, good points! I think 1. and 2. can be done in parallel. If 1. is fully completed before 24.x then 2. becomes irrelevant. Having 2. now could help with some testing by people that use pre-release, and don't change the defaults, I guess. |
Concept ACK. |
The least risky way to find out is to do this pull for a release or so, because it is trivial to revert and gives users optionality.
Project and user space risk, and ease of reversion. |
If users change the default setting, they won't find out if this pull is merged. But maybe I am just overthinking this, as almost no one changes the default values. |
True, in any case we need to communicate about it. Devil's advocate, if there is a potential attack vector with the current code that should be closed, that would be a different scenario. |
I think I agree with @MarcoFalke & @mzumsande and would rather move ahead with refactoring the code, i.e #24662 + validation changes, rather than a sort of interim / soft deprecation period of just changing the default. I think we have a long enough window prior to the 24.x branch off to get the refactoring done, and if for some reason that didn't happen, we could always, if still wanted, make this change just prior to branch off. I would also be very surprised if anyone is actually using this setting in production. |
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
5c81837
to
e91d403
Compare
I just went through the old conversation for #7573 where this flag was added and I found the reason why we did not set the default to zero back then: "I chose not to disable the time-offset logic entirely because I've gotten feedback about people liking to get the warning message "Please check that your computer's date and time are correct!" if none of the peers are within 5 minutes just in-case." In summary, I tend to Concept NACK this changing of default for the reasons mentioned. |
Hi @mruddy, this change is proposed within the context of a process to remove adjusted time completely. |
When I think about removing adjusted time completely, this quote from sipa comes to mind: I think there is some subtle wisdom in sipa's sentiment at the time and I think it still applies. Initially, when I proposed the PR that led to the creation of the I still think that adjusted time can serve the same purpose as it did in 2016. I still think that the justification for the |
I think that if we want to progress with removing the mechanism that adjusts our node's view of time, that we should still keep a mechanism that warns about being out of alignment with peer times. That would allow us to keep clock sync as a local system problem. So, if this PR is moving in that direction, then I'd be ok with concept ack'ing. But, getting to the actual change, only changing the default to 0, seems kind of lacking. It gets closer to the end goal, but it leaves a lot of clumsy code to get log messages. So, I tend to agree with this #24606 (comment) |
Not sure how useful it is to look at "internet hosts" to get data points, which are off by several days. (I haven't checked, but) Bitcoin Core should refuse to start up if the clock is behind the latest block saved on disk (or will refuse to download it). It is certainly not uncommon for some clocks to be broken. I've run into this myself, see for example https://bugs.launchpad.net/cloud-images/+bug/1896443 . However, Bitcoin Core will already fail to function properly on those systems and adjusted time doesn't correct offsets in the order of days anyway. I agree on the warnings. Someone should check that Bitcoin Core raises an InitError when the clock is behind the latest block saved on disk (or maybe the latest data point in the chainTxData). I proposed more aggressive warnings or errors in a recent IRC meeting, but there was no agreement that more aggressive warnings are warranted. So I think we should check that the existing warnings are properly sent out even if the default is set to 0 or the setting removed. |
There is a meta issue if anyone feels like contributing data points: #24805 |
I think it would also help to understand the (worst-case) consequences of having an incorrect time in cases where AdjustedTime might have ideally helped before. I had a look at the places where adjusted time is used - there are just a few: I could think of the following items:
Am I missing anything important? |
One theoretical example might be where one clock is behind by one hour and ten min and another is ahead by one hour and 10 min. For both, adjusted time would fix the offset, but without adjusted time the fallen-back node wouldn't accept the blocks of the advanced node. |
Another idea for improving the warning: We could calculate the running median offset of the last 10 outbound peer connections instead of the current offset, which locks in after (and takes into account) 200 outbound connections? |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
This won't be merged, closing. |
Following the core dev IRC discussion today, this is a straightforward step per the suggestion at https://www.erisian.com.au/bitcoin-core-dev/log-2022-03-17.html#l-652. Users can still opt in to adjusted time by setting
-maxtimeadjustment
with a value greater than zero. This allows gaining feedback as to what extent user space depends on adjusted time.If we want to remove the adjusted time code down the road, it makes sense to give users the fallback option to use adjusted time for a release or two. This also reduces our code reversion risk in the case that users rely on it. The release notes would describe the change and suggest that the option is being deprecated for future removal.
See #7573 and #4521 for further context.