Skip to content

Conversation

@mzumsande
Copy link
Contributor

@mzumsande mzumsande commented Jan 9, 2024

Service flags received from the peer-to-peer network are handled differently, depending on how we receive them.
If received directly from an outbound peer the flags belong to, they replace existing flags.
If received via gossip relay (so that anyone could send them), new flags are added, but existing ones but cannot be overwritten.

Document that and add test coverage for it.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 9, 2024

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
ACK furszy, brunoerg, achow101
Stale ACK sipa, jonatack

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

@jonatack
Copy link
Member

jonatack commented Jan 9, 2024

Concept ACK

@mzumsande mzumsande force-pushed the 202401_addrman_serviceflags branch from 0687436 to d536e5a Compare January 9, 2024 22:51
@brunoerg
Copy link
Contributor

Concept ACK

@sipa
Copy link
Member

sipa commented Jan 10, 2024

utACK d536e5a6325d1885224f36debdcc5245b94efe8a

@DrahtBot DrahtBot requested review from brunoerg and jonatack January 10, 2024 13:27
Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK d536e5a6325d1885224f36debdcc5245b94efe8a

src/addrman.h Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps add a "see AddSingle()" mention somewhere in here, as the logic referred to here is in that method called from this one (Add/Add_).

Copy link
Contributor Author

@mzumsande mzumsande Jan 15, 2024

Choose a reason for hiding this comment

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

I think it's better if the header doesn't refer to implementation details. If I remember correctly, this logic used to be in Add(), then Add_(), now AddSingle(), and I don't think it's nice if we have to update addrman.h for refactors like that.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Adding service flags even works when the addr is in Tried
// Adding service flags even works when the addr is in Tried; see `AddSingle()`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

similar to above, I don't like referring to implementation details in comments unless really necessary.

src/addrman.h Outdated
Comment on lines 113 to +115
Copy link
Member

Choose a reason for hiding this comment

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

It is not immediately clear that additional services flags may be added, but the return value could still be false. And the same seems to happen for the AddrInfo timestamp. It can also be updated while the return value remains false.

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 that followed from the @return doc, but it wasn't so obvious that adding an existing addr to another new bucket also affects the return value; Changed the @return description to true if at least one address is successfully added, or added to an additional bucket. Unaffected by updates.

Service flags are handled differently, depending on whether
validated (if received from the peer) or unvalidated (received
via gossip relay).
@mzumsande mzumsande force-pushed the 202401_addrman_serviceflags branch from d536e5a to 74ebd4d Compare January 15, 2024 21:20
@mzumsande
Copy link
Contributor Author

d536e5a to 74ebd4d: Addressed feedback

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

ACK 74ebd4d

@DrahtBot DrahtBot requested review from jonatack and sipa January 15, 2024 21:24
Copy link
Contributor

@brunoerg brunoerg left a comment

Choose a reason for hiding this comment

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

utACK 74ebd4d

@achow101
Copy link
Member

ACK 74ebd4d

@achow101 achow101 merged commit 5711da6 into bitcoin:master Jan 16, 2024
@jonatack
Copy link
Member

Post-merge ACK 74ebd4d

@mzumsande mzumsande deleted the 202401_addrman_serviceflags branch January 17, 2024 19:14
@bitcoin bitcoin locked and limited conversation to collaborators Jan 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants