Skip to content
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

Filter observed addresses #917

Merged
merged 4 commits into from
May 20, 2020
Merged

Filter observed addresses #917

merged 4 commits into from
May 20, 2020

Conversation

aarshkshah1992
Copy link
Contributor

Copy link
Contributor

@willscott willscott left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me

p2p/protocol/identify/obsaddr.go Outdated Show resolved Hide resolved
p2p/protocol/identify/obsaddr.go Show resolved Hide resolved
@aarshkshah1992
Copy link
Contributor Author

aarshkshah1992 commented May 19, 2020

@Stebalien There was some flakiness in the TestObservedAddrFiltering test because we map observations by the local internal address on the connection but the mocknet randomly selects the local address for a connection if it's listening on multiple addresses.

Since we were listening on both TCP & UDP addresses, some observations were made for the local UDP address and some on the local TCP address ignoring the address we were observing. So, the votes i.e. the count of SeenBy got divided across listen addresses for the same observed address. Have fixed this by removing UDP listeners/addresses from the tests.

Please take a look.

aarshshah@Aarshs-MacBook-Pro go-libp2p % go test -race -count=100 -run TestObservedAddrFiltering
testing: warning: no tests to run
PASS
ok  	github.com/libp2p/go-libp2p	0.215s

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

one nit but otherwise lgtm

protos := oa.Addr.Protocols()

for i := range protos {
key = key + protos[i].Name
Copy link
Member

Choose a reason for hiding this comment

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

This is fine but kind of sloppy. We should either use a separator (/ip4/udp/quic) or concatenate protocol.VCodes (these are prefix-free codes so we don't need separators).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a separator now.

if len(pat) != 0 {
pmap[pat] = append(pmap[pat], a)
} else {
log.Debugw("unable to group observed addr into IPx/(TCP or UDP) patterm", "address",
Copy link
Member

Choose a reason for hiding this comment

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

is this possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm... it can "theoretically" happen if the address dosen't have any protocols but it probably wouldn't make it so far if that were that case. Removing it to reduce clutter.

@aarshkshah1992 aarshkshah1992 merged commit 79ead33 into master May 20, 2020
@aarshkshah1992 aarshkshah1992 deleted the feat/910 branch May 20, 2020 06:09
Stebalien added a commit that referenced this pull request May 20, 2020
In #917, we started dropping additional address observations if we had multiple
for the same transport set. However, on further consideration, this isn't quite
correct. We _want_ to keep additional observations for multiple IP addresses.
The real issue is many observations for different ports.

So this patch simply changes the key with which we group observations from
"address protocols" to "address without the port" (well, with the port set to
0).
Stebalien added a commit that referenced this pull request May 20, 2020
In #917, we started dropping additional address observations if we had multiple
for the same transport set. However, on further consideration, this isn't quite
correct. We _want_ to keep additional observations for multiple IP addresses.
The real issue is many observations for different ports.

So this patch simply changes the key with which we group observations from
"address protocols" to "address without the port" (well, with the port set to
0).
@Stebalien Stebalien mentioned this pull request May 26, 2020
77 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants