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

feat: track failed/successful dials per-address #2033

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Sep 8, 2023

Instead of tracking which peer we failed to dial, track dial success or failure on a per-address basis.

This will let us detect when IPv6 is unsupported or certain transports (e.g. UDP ones) are blocked.

Refs: #2010

Instead of tracking which peer we failed to dial, track dial success
or failure on a per-address basis.

This will let us detect when IPv6 is unsupported or certain transports
(e.g. UDP ones) are blocked.

Refs: 2010
Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

just looking through the code.. some minor improvements and a question but in general it looks reasonable.

There doesn't seem to be any code utilizing the lastSuccess or lastFailed yet, but from the title of the PR that seems intentional.

Comment on lines +45 to +49
existingAddr.lastFailure = Number(addr.lastFailure)
}

if (addr.lastSuccess != null) {
existingAddr.lastSuccess = Number(addr.lastSuccess)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a good reason to use Number here instead of BigInt as is used elsewhere in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

The value is a timestamp, the max value of which can exceed 32 bits so we need to use a 64 bit number in the protobuf to store it, which means we need to represent it as a BigInt, but this is overkill for actual time values.

We can refactor this once ipfs/protons#112 is implemented to have protons serialize/deserialize to Number instead of BigInt.

@@ -244,4 +241,53 @@ describe('merge', () => {
expect(updated).to.have.property('tags').that.deep.equals(original.tags)
expect(updated).to.have.property('protocols').that.deep.equals(original.protocols)
})

it('merges addresses', async () => {
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
it('merges addresses', async () => {
it('merges lastFailure & lastSuccess on peer addresses', async () => {

Copy link
Member Author

Choose a reason for hiding this comment

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

This test also ensures multiaddr and isCertified values are merged and not lost so they are missing from the test name if you want it to be exhaustive, or it can remain as it is.

Comment on lines +470 to +473
if (pendingDial.peerId != null) {
// mark multiaddr dial as failure
await this._updateAddressStatus(pendingDial.peerId, addr, false)
}
Copy link
Member

Choose a reason for hiding this comment

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

This check implies that we may also attempt to dial peers where peerId == null. Can we log when that is the case, and that we're not marking peer as having a failed dial?

Copy link
Member Author

@achingbrain achingbrain Sep 12, 2023

Choose a reason for hiding this comment

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

we may also attempt to dial peers where peerId == null

Yes, this is the case when dialing a multiaddr without a peer id, e.g. /dnsaddr/bootstrap.libp2p.io

and that we're not marking peer as having a failed dial?

We can't mark the peer as having a failed dial as peer data is keyed on the peer id - if we don't know the peer id we can't mark anything as having failed.

Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

Following from previous conversations I think this is the right direction, is this ready for review @achingbrain ?

@achingbrain achingbrain marked this pull request as ready for review November 2, 2023 12:43
@achingbrain achingbrain requested a review from a team as a code owner November 2, 2023 12:43
@maschad
Copy link
Member

maschad commented Nov 2, 2023

LGTM but we should perhaps merge #2150 into this before merging this as it effectively adds no enhancement without the sorting functionality.

@dhuseby dhuseby added the help wanted Seeking public contribution on this issue label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue
Projects
Status: 🧊Icebox🥶
Development

Successfully merging this pull request may close these issues.

4 participants