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

[Merged by Bors] - api: add hole punching info and data transfer stats #5792

Closed
wants to merge 18 commits into from

Conversation

ivan4th
Copy link
Contributor

@ivan4th ivan4th commented Mar 31, 2024

Motivation

Current AdminService.PeerInfoStream doesn't provide enough information about whether hole punching was used while connecting to a particular peer, and also doesn't reflect actual utilization of each peer, which makes it harder to see whether the peer connections are being used efficiently.
Also, importantly, in case if go-spacemesh causes network overload it may be hard to find out what kind of traffic is causing the problems. It would be nice to have some overview of the traffic even in case if the metrics are disabled. The current data transfer rates should be easy to view even without any Prometheus to do rate calculations.

Description

AdminService.PeerInfoStream response is extended with new fields.
This includes connection kind (relay / hole punching information, with HPInbound and HPOutbound meaning inbound and out-bound hole-punching, respectively) and client/server request and transfer statistics. Also, it includes the data transfer rates (bytes/s) calculated over 10s and 1m periods.
The peer records look like this (not using actual IPs or peer IDs):

{
  "id": "...",
  "connections": [
    {
      "address": "/ip4/123.45.67.89/tcp/15816",
      "uptime": "1336.521022291s",
      "outbound": true,
      "kind": "Outbound"
    }
  ],
  "clientStats": {
    "successCount": "1",
    "latency": "0.062496709s"
  },
  "bytesSent": "4635446",
  "bytesReceived": "29709306",
  "sendRate": [
    "0",
    "71"
  ],
  "recvRate": [
    "0",
    "193"
  ]
}
{
  "id": "...",
  "connections": [
    {
      "address": "/ip4/23.45.67.89/tcp/1024",
      "uptime": "449.661134625s",
      "outbound": true,
      "kind": "HPInbound"
    }
  ],
  "clientStats": {
    "successCount": "1",
    "latency": "0.070969208s"
  },
  "bytesSent": "6110842",
  "bytesReceived": "39615132",
  "sendRate": [
    "0",
    "257"
  ],
  "recvRate": [
    "0",
    "121"
  ]
}

The output of spacemesh.v1.DebugService.NetworkInfo now looks like:

{
  "id": "...",
  "listenAddresses": [
    "/ip4/0.0.0.0/tcp/7513",
    "/ip4/0.0.0.0/udp/7513/quic-v1",
    "/p2p-circuit"
  ],
  "knownAddresses": [
    "/ip4/127.0.0.1/tcp/7513",
    "/ip4/127.0.0.1/udp/7513/quic-v1",
    "/ip4/123.45.67.89/tcp/7513",
    "/ip4/192.168.40.159/tcp/7513",
    "/ip4/192.168.40.159/udp/7513/quic-v1",
    "/ip4/192.168.64.1/tcp/7513",
    "/ip4/192.168.64.1/udp/7513/quic-v1",
    "/ip4/...tcp/5001/p2p/....../p2p-circuit",
    "/ip4/.../tcp/5001/p2p/....../p2p-circuit"
  ],
  "natTypeTcp": "Cone",
  "reachability": "Private",
  "stats": {
    "/ipfs/id/1.0.0": {
      "bytesSent": "1702673",
      "bytesReceived": "1461222",
      "sendRate": [
        "0",
        "25"
      ],
      "recvRate": [
        "0",
        "18"
      ]
    },
    "/ipfs/id/push/1.0.0": {
      "bytesSent": "207189",
      "bytesReceived": "8977845",
      "sendRate": [
        "0",
        "237"
      ],
      "recvRate": [
        "0",
        "251"
      ]
    },
    "/libp2p/autonat/1.0.0": {
      "bytesSent": "7151",
      "bytesReceived": "3164"
    },
    "/libp2p/circuit/relay/0.2.0/hop": {
      "bytesSent": "2589492",
      "bytesReceived": "2461896"
    },
    "/libp2p/circuit/relay/0.2.0/stop": {
      "bytesSent": "88239",
      "bytesReceived": "85382",
      "sendRate": [
        "0",
        "5"
      ],
      "recvRate": [
        "0",
        "5"
      ]
    },
    "/libp2p/dcutr": {
      "bytesSent": "9139",
      "bytesReceived": "12671"
    },
    "/meshsub/1.1.0": {
      "bytesSent": "5265121597",
      "bytesReceived": "3980876238",
      "sendRate": [
        "456745",
        "185721"
      ],
      "recvRate": [
        "541102",
        "68351"
      ]
    },
    "/peersync/1.0/": {
      "bytesSent": "46385",
      "bytesReceived": "43979"
    },
    "/spacekad/kad/1.0.0": {
      "bytesSent": "644931",
      "bytesReceived": "15350810",
      "sendRate": [
        "0",
        "41"
      ],
      "recvRate": [
        "0",
        "1038"
      ]
    },
    "__other__": {
      "bytesSent": "2861993",
      "bytesReceived": "2857514",
      "sendRate": [
        "0",
        "33"
      ],
      "recvRate": [
        "0",
        "33"
      ]
    },
    "__total__": {
      "bytesSent": "5708199745",
      "bytesReceived": "4558225401",
      "sendRate": [
        "456745",
        "186550"
      ],
      "recvRate": [
        "541102",
        "69955"
      ]
    },
    "ax/1": {
      "bytesSent": "86797553",
      "bytesReceived": "520784404"
    },
    "hs/1": {
      "bytesSent": "338030798",
      "bytesReceived": "17237601",
      "sendRate": [
        "0",
        "251"
      ],
      "recvRate": [
        "0",
        "25"
      ]
    },
    "ld/1": {
      "bytesSent": "8693168",
      "bytesReceived": "6800320",
      "sendRate": [
        "0",
        "222"
      ],
      "recvRate": [
        "0",
        "222"
      ]
    },
    "lp/2": {
      "bytesSent": "320056",
      "bytesReceived": "256960",
      "sendRate": [
        "0",
        "8"
      ],
      "recvRate": [
        "0",
        "7"
      ]
    },
    "ml/1": {
      "bytesSent": "1079381",
      "bytesReceived": "1015395"
    }
  }
}

Test Plan

Tested on a mainnet node

TODO

Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 87.69231% with 40 lines in your changes missing coverage. Please review.

Project coverage is 81.4%. Comparing base (7efcf58) to head (5e1ff05).
Report is 1 commits behind head on develop.

Files Patch % Lines
p2p/peerinfo/peerinfo.go 89.9% 11 Missing and 8 partials ⚠️
api/grpcserver/admin_service.go 82.2% 8 Missing ⚠️
p2p/upgrade.go 75.8% 6 Missing and 1 partial ⚠️
p2p/server/server.go 78.5% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #5792    +/-   ##
========================================
  Coverage     81.3%   81.4%            
========================================
  Files          296     297     +1     
  Lines        31667   31965   +298     
========================================
+ Hits         25764   26036   +272     
- Misses        4214    4231    +17     
- Partials      1689    1698     +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ivan4th
Copy link
Contributor Author

ivan4th commented Apr 1, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Apr 1, 2024
@spacemesh-bors
Copy link

spacemesh-bors bot commented Apr 1, 2024

try

Build failed:

@ivan4th
Copy link
Contributor Author

ivan4th commented Apr 1, 2024

Partition test flake:

    partition_test.go:175: 
        	Error Trace:	/src/systest/tests/partition_test.go:175
        	            				/src/systest/tests/partition_test.go:204
        	Error:      	Should be true
        	Test:       	TestPartition_50_50

@ivan4th
Copy link
Contributor Author

ivan4th commented Apr 1, 2024

bors try

spacemesh-bors bot added a commit that referenced this pull request Apr 1, 2024
@spacemesh-bors
Copy link

spacemesh-bors bot commented Apr 1, 2024

try

Build succeeded:

@ivan4th ivan4th force-pushed the feature/holepunch-info branch from 3934e9d to c451fae Compare April 23, 2024 17:36
@ivan4th ivan4th changed the title api: add detailed peer information to AdminService.PeerInfoStream api: add hole punching info and data transfer stats Apr 25, 2024
go.mod Outdated
@@ -38,7 +38,7 @@ require (
github.com/rs/cors v1.11.0
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
github.com/seehuhn/mt19937 v1.0.0
github.com/spacemeshos/api/release/go v1.42.0
github.com/spacemeshos/api/release/go v1.42.1-0.20240530113900-b81297d5714c
Copy link
Member

Choose a reason for hiding this comment

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

The PR in the api repo needs to be merged first I assume?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I planned to do so after I address all the other comments here

p2p/upgrade.go Outdated Show resolved Hide resolved
p2p/server/server.go Outdated Show resolved Hide resolved
p2p/server/server.go Outdated Show resolved Hide resolved
p2p/server/server.go Outdated Show resolved Hide resolved
p2p/server/server.go Outdated Show resolved Hide resolved
api/grpcserver/interface.go Outdated Show resolved Hide resolved
p2p/peerinfo/peerinfo.go Outdated Show resolved Hide resolved
p2p/peerinfo/peerinfo.go Show resolved Hide resolved
p2p/peerinfo/peerinfo.go Outdated Show resolved Hide resolved
Copy link
Member

@fasmat fasmat left a comment

Choose a reason for hiding this comment

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

LGTM, remember to first merge and release spacemeshos/api#322 🙂

@ivan4th ivan4th requested a review from acud as a code owner June 16, 2024 22:02
@ivan4th
Copy link
Contributor Author

ivan4th commented Jun 16, 2024

bors merge

spacemesh-bors bot pushed a commit that referenced this pull request Jun 16, 2024
## Motivation

Current `AdminService.PeerInfoStream` doesn't provide enough information about whether hole punching was used while connecting to a particular peer, and also doesn't reflect actual utilization of each peer, which makes it harder to see whether the peer connections are being used efficiently.
Also, importantly, in case if `go-spacemesh` causes network overload it may be hard to find out what kind of traffic is causing the problems. It would be nice to have some overview of the traffic even in case if the metrics are disabled. The current data transfer rates should be easy to view even without any Prometheus to do `rate` calculations.
@spacemesh-bors
Copy link

Pull request successfully merged into develop.

Build succeeded:

@spacemesh-bors spacemesh-bors bot changed the title api: add hole punching info and data transfer stats [Merged by Bors] - api: add hole punching info and data transfer stats Jun 16, 2024
@spacemesh-bors spacemesh-bors bot closed this Jun 16, 2024
@spacemesh-bors spacemesh-bors bot deleted the feature/holepunch-info branch June 16, 2024 23:37
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.

2 participants