Page MenuHomePhabricator

[avalanche] Add a getavaaddr message
ClosedPublic

Authored by Fabien on Jan 14 2022, 10:34.

Details

Reviewers
tyler-smith
Group Reviewers
Restricted Project
Maniphest Tasks
Restricted Maniphest Task
Commits
rABC8a1cbd16b87f: [avalanche] Add a getavaaddr message
Summary

This is part of the active peer discovery. This new message is equivalent to the standard getaddr message and asks for the best avalanche peers, i.e. the ones with the highest availability score. The response use the standard addr message.

For now this does not come with any of the privacy features of the getaddr message, this can be added in follow-up diffs if needed. The messages are limited to one every 10 minutes to prevent a peer from exhausting our resources by spamming with getavaaddr.

Ref T1696.

Test Plan
ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Jan 14 2022, 10:34
tyler-smith added inline comments.
src/net_processing.cpp
4611 ↗(On Diff #31810)

Am I understanding correctly that the AvailabilityScore is measuring how responsive that node has been to polls?

Fabien marked an inline comment as done.Jan 21 2022, 08:07
Fabien added inline comments.
src/net_processing.cpp
4611 ↗(On Diff #31810)

You're correct. The score is an EWMA computation of the received votes minus the emitted polls. So the score will increase over time as the node is polled and is answering, remain zero if the node is not polled, and decrease if the node is not responding. By filtering for score > 0 we only keep the nodes that have been polled and have answered most of the polls.

test/functional/abc_p2p_getavaaddr.py
29 ↗(On Diff #31810)

What is this lock that doesn't seem to be on other uses of this var?

Fabien marked an inline comment as done.Feb 2 2022, 07:16
Fabien added inline comments.
test/functional/abc_p2p_getavaaddr.py
29 ↗(On Diff #31810)

The P2PInterface class have callback methods for the p2p events. The on_xxx() methods are such callbacks and are already locking the p2p_lock (see the on_message() method in /test/functional/test_framework/p2p.py for details).

The get_received_addrs() method on the other hand is not overriden from P2PInterface and needs the lock because it accesses the received_addrs members which can be set concurrently by on_addr(). Note that the addr_received() is also doing the same but here the lock is not really needed due to the nature of the check.

This revision looks correct and tests look sufficient.

This revision is now accepted and ready to land.Feb 4 2022, 22:06
This revision was automatically updated to reflect the committed changes.