-
Notifications
You must be signed in to change notification settings - Fork 37.7k
p2p: Remove GetAdjustedTime() from AddrMan #23807
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
64c2492
to
14b5d2b
Compare
Concept ACK |
765e71b
to
f282ffb
Compare
I haven't thought a lot about this, but I have two questions: Is this going to cause any additional fingerprinting vectors? I guess not after commit 14ba286? Also, could this break P2P address relay? I guess only for the local node? |
Yes, but so could a misadjusted time due to connecting to the wrong nodes. At the least it reduces variance between starts of |
This PR doesn't affect address (gossip) relay, because that is independent from AddrMan: bitcoin/src/net_processing.cpp Lines 2887 to 2888 in cb27d60
and bitcoin/src/net_processing.cpp Lines 2933 to 2936 in cb27d60
Although it would probably make sense to change |
Could you summarize the reasons for this change and put it in the OP post? |
@naumenkogs The main reason is to remove the use of GetAdjustedTime. As @mzumsande said, this change does not affect the network layer (or other layers), only the local AddrMan so it seems safer and easier to test and review. I have a version of this PR that also removes If reviewers think it's better, I can update the PR with this version. |
If this really doesn't change p2p behavior and is only a refactor (?), then I'd say to leave this pull as-is to simplify review. If this is not a refactor, it would be good to list all behavior changes. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
@mzumsande I'm not sure this change doesn't affect p2p
And what's the problem with |
The problem is that adjusted time is:
Thus, it is an huge mental burden to think about any change to addrman that involves those timestamps. Also, it makes it hard to understand the existing logic, even if nothing is changed. |
I wasn't trying to say that, just that it doesn't really affect gossip relay, because self-announcements have already been changed to always use local time in #23695, and the mechanism of whether to forward these is located in One p2p aspect that the adjusted time in AddrMan can influence in theory are GETADDR responses: Addrs for which I'm not sure that this is a huge influence though, since I'd have to think about it a bit more, but I tend toward removing the Adjusted Time from all addr related code - not just AddrMan but also in |
What is the biggest possible deviation? From what I see in the code, any, but we show warnings if it deviates more than 5 minutes? I thought the deviation from block header timestamps is limited, but I can't find that.
I probably support the overall sentiment, I just think we should understand all implications and document it here. |
Likely |
f282ffb
to
cb660ce
Compare
This is not just a refactor because it changes the AddrMan behavior.
commit 3a141ff
commit cb660ce
|
Concept ACK I have found understanding I'll spend some time reading the linked threads and discussion on this PR before digging in a bit more |
cb660ce
to
a27fab1
Compare
-BEGIN VERIFY SCRIPT- s() { sed -i -e 's/GetAdjustedTime()/GetTime()/g' $(git grep -l 'GetAdjustedTime' $1); } s src/addrman.cpp s src/addrman.h s src/addrman_impl.h s src/bench/addrman.cpp s src/test/addrman_tests.cpp -END VERIFY SCRIPT-
-BEGIN VERIFY SCRIPT- s() { sed -i -e 's/GetAdjustedTime()/GetTime()/g' $(git grep -l 'GetAdjustedTime' $1); } s src/net_processing.cpp -END VERIFY SCRIPT-
a27fab1
to
3445590
Compare
Rebased. |
@@ -2891,7 +2891,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, | |||
|
|||
// Store the new addresses | |||
std::vector<CAddress> vAddrOk; | |||
int64_t nNow = GetAdjustedTime(); | |||
int64_t nNow = GetTime(); |
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.
One side effect I’m thinking of is if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)
. If this is triggered (because our node lives in the past), we would mark some of the recent address (including all one-hop self-announcements) to be 5 days old, and deprioritize them?
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.
Looks like this is changing both too much (a few in net_processing) and too little (missing net.cpp).
@@ -963,7 +963,7 @@ bool PeerManagerImpl::TipMayBeStale() | |||
|
|||
bool PeerManagerImpl::CanDirectFetch() | |||
{ | |||
return m_chainman.ActiveChain().Tip()->GetBlockTime() > GetAdjustedTime() - m_chainparams.GetConsensus().nPowTargetSpacing * 20; | |||
return m_chainman.ActiveChain().Tip()->GetBlockTime() > GetTime() - m_chainparams.GetConsensus().nPowTargetSpacing * 20; |
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 don't think this has anything to do with addrman
Thanks, but due to inactivity I am closing this for now. I've picked it up in #24662. |
This PR modifies AddrMan to use local time instead of
GetAdjustedTime()
.Motivation: Check discussion in #23695, #23631 and the issues related to
GetAdjustedTime()
reported in #4521