Skip to content

Conversation

@gmelodie
Copy link
Contributor

@gmelodie gmelodie commented Sep 2, 2025

Add util functions needed for autonatv2

@gmelodie gmelodie self-assigned this Sep 2, 2025
@gmelodie gmelodie requested a review from a team as a code owner September 2, 2025 19:33
@gmelodie gmelodie force-pushed the chore/autonat-v2-types branch from 7ca8dbc to da5c8a6 Compare September 2, 2025 19:37
@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2025

🏁 Performance Summary

Commit: e0e29429e277faa76fade2b6f6c47721145afea7

Scenario Nodes Total messages sent Total messages received Latency min (ms) Latency max (ms) Latency avg (ms)
Base test 10 100 900 0.308 2.270 1.011
Low Bandwidth rate 256kbit burst 8kbit limit 5000 10 100 900 0.273 61.422 16.502
Packet Reorder 15% 40% with 2ms delay 10 100 900 0.395 6.169 3.103
Queue Limit 5 10 100 900 0.279 2.430 1.032
Latency 100ms 20ms 10 100 900 20.357 210.530 117.728
Burst Loss 8% 30% 10 100 900 0.346 2.433 1.098
Duplication 2% 10 100 900 0.416 2.682 1.143
Corruption 0.5% 10 100 900 0.421 2.399 1.105
Packet Loss 5% 10 100 900 0.341 2.456 1.087
Combined Network Conditions 10 100 900 0.279 262.153 127.392

📊 View Latency History and full Container Resources in the Workflow Summary

../../../peerid,
../../../protobuf/minprotobuf,
../../../switch,
../autonat/service
Copy link
Member

Choose a reason for hiding this comment

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

Probably makes more sense to extract from service the things that are common to autonat v1 and v2 into some file that's shared by both that file and this one

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 wonder where that file would live

  1. in libp2p/protocols/connectivity/file.nim
  2. in libp2p/protocols/connectivity/autonat/file.nim (in this case autonatv2/ should live inside autonat/, and autonatv1 should also be inside autonat/)
  3. Same as 2 but without creating a new autonatv1 folder. Which is the same as just renaming core.nim to types.nim and importing it in v2.

I'll go with 3: change core.nim to types.nim in autonat/ and import autonat/types in v2.

## Checks if at least one of the requests' addresses
## has the same IP address of observedIPAddr

let observedIPAddr = observedIPAddr[0].valueOr:
Copy link
Member

Choose a reason for hiding this comment

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

There's no guarantee that the first element of the address is gonna be an ip (i.e. /p2p/somePeerId is a valid multiaddress). Look into how observedaddrmanager extracts IP for inspiration. https://github.com/vacp2p/nim-libp2p/blob/master/libp2p/observedaddrmanager.nim#L30-L67


(ipv4, ipv6)

proc isPrivateIP*(ip: string): bool {.raises: [ValueError].} =
Copy link
Member

Choose a reason for hiding this comment

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

AutoTLS has a isPublic. Could we maybe put both that function and this one in some utils file?

@gmelodie gmelodie force-pushed the chore/autonat-v2-types branch 3 times, most recently from b660988 to 69c524a Compare September 3, 2025 17:58
@github-project-automation github-project-automation bot moved this from new to In Progress in nim-libp2p Sep 3, 2025
@gmelodie gmelodie force-pushed the chore/autonat-v2-types branch 4 times, most recently from 20135bb to efd88bd Compare September 3, 2025 18:28
@gmelodie gmelodie force-pushed the chore/autonat-v2-types branch from efd88bd to e0e2942 Compare September 3, 2025 18:43
@gmelodie gmelodie enabled auto-merge (squash) September 3, 2025 18:49
@gmelodie gmelodie merged commit 0611951 into master Sep 3, 2025
15 of 17 checks passed
@gmelodie gmelodie deleted the chore/autonat-v2-types branch September 3, 2025 19:04
@github-project-automation github-project-automation bot moved this from In Progress to done in nim-libp2p Sep 3, 2025
@gmelodie gmelodie mentioned this pull request Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants