Add per-peer bandwidth attribution to egress server#332
Open
myleshorton wants to merge 1 commit intomainfrom
Open
Add per-peer bandwidth attribution to egress server#332myleshorton wants to merge 1 commit intomainfrom
myleshorton wants to merge 1 commit intomainfrom
Conversation
Previously, the egress server tracked ingress bytes as a single global counter. This change attributes bytes to individual peers so the data can be consumed by a future reward oracle. Changes: - Add PeerID field to EgressOptions (UUID by default) - Include peer ID in WebSocket subprotocol header alongside consumer session ID (backwards compatible: old clients fall back to CSID) - Replace global nIngressBytes atomic with per-peer sync.Map of atomic counters, shared across all connections from the same peer - Add "ingress-bytes-by-peer" OTel metric with peer_id attribute - Preserve existing "ingress-bytes" total metric for backward compat Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
@noahlevenson and @garmr-ulfr this is just background work that's necessary if we ever did want to integrate a crypto token. |
Contributor
|
When do you need to land this? My only thought: we have an open ticket to decouple the Lantern-specific parts of Unbounded and refactor them to our own proprietary layer, because when they're tightly coupled, it makes it harder for people to integrate Unbounded into their own projects. The stuff in this PR seems like a prime candidate for the "Lantern proprietary" Unbounded package... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sync.Mapkeyed by peer ID)ingress-bytes-by-peerOTel metric with apeer_idattribute, preserving the existingingress-bytestotal metricPeerIDfield toEgressOptions(auto-generated UUID by default), so all callers get a peer identity without code changesThis is the first step toward bandwidth-based compensation for unbounded peers (see getlantern/lantern-token).
Test plan
ingress-bytestotal metric still reports correctlyingress-bytes-by-peermetric appears withpeer_idlabels in OTel collector🤖 Generated with Claude Code