Repository navigation
forwarding ability: report fee and forwarding totals - #249
Conversation
Report the fees alongside the volume so a single call describes the window completely. Fees are reported in millisatoshis because a single forward routinely earns less than one satoshi, and a satoshi granular sum would floor a low-fee pair's earnings to zero. Report the forward count as well. Both sums can be zero for a pair that really did forward: its volume floors to whole satoshis and a zero-fee policy earns nothing, so without a count neither zero can be told apart from a pair that carried nothing at all. The count is what makes the presence of traffic a fact the response states rather than one the consumer infers from a sum.
A full entry now transports what the pair earned and how many forwards it earned that over, alongside the volume and uptime it already carried. A pair reported through the up-but-idle bitmask carries neither, which is consistent with a bit that stands for a pair having carried nothing: it decodes back at full window uptime with no forwards, and therefore with no volume and no fees.
The analyzer already walked lnd's forwarding history to total each pair's volume. It now totals the fees those forwards earned and counts them, in one pass over the same events. The per-pair accumulator replaces the slice of individual amounts, which was only ever summed.
Carry the two new totals from the analyzer into the response, so one call describes the window rather than this response plus a separate walk of the forwarding history.
Presence was inferred from the forwarded volume. A pair whose forwards were all sub-satoshi sums to no volume and one forwarding for free earns no fees, so a volume-driven rule demotes either to an up-but-idle bit and records traffic that happened as traffic that did not. The count decides instead, which leaves an invariant a consumer can rely on: a full entry always reports at least one forward, so an entry without one can only have come from a server that predates counts.
The command already derives uptime fraction and velocity from the raw facts and the window it was given; the fee rate is derived the same way.
There was a problem hiding this comment.
Pull request overview
Extends forwarding-ability analysis with fee totals and successful-forward counts.
Changes:
- Accumulates and exposes fee/count metrics.
- Preserves zero-value forwards using the count.
- Adds CLI output, API schema updates, and tests.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
chanevents/analyzer.go |
Accumulates forwarding totals. |
chanevents/analyzer_test.go |
Tests fee/count propagation. |
cmd/frcli/forwarding_ability.go |
Displays metrics and fee rate. |
frdrpc/faraday.pb.go |
Updates generated protobuf bindings. |
frdrpc/faraday.proto |
Defines new response fields. |
frdrpc/faraday.swagger.json |
Updates REST schema. |
frdrpc/forwarding_ability_codec.go |
Encodes and decodes new metrics. |
frdrpc/forwarding_ability_codec_test.go |
Tests codec behavior. |
frdrpcserver/forwarding_ability.go |
Maps analyzer totals into RPC data. |
frdrpcserver/forwarding_ability_test.go |
Verifies RPC metric encoding. |
itest/channel_events_test.go |
Verifies idle-pair zero values. |
Files not reviewed (1)
- frdrpc/faraday.pb.go: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| func (a ForwardingAbility) tier(minUptimeS int64) abilityTier { | ||
| switch { | ||
| case a.ForwardedSat > 0: | ||
| case a.Forwards > 0: |
There was a problem hiding this comment.
This is an intentional breaking change, callers are not expected as the code isn't released yet.
ViktorT-11
left a comment
There was a problem hiding this comment.
LGTM 🔥! Maybe we could include itest coverage when these new values aren't zero as well?
As mentioned out of band, unfortunately the itest isn't flexible enough to generate routing. |
This extends the
ForwardingAbilityRPC to also report the total fees earned and number of payments forwarded within the analyzed interval.