feat: FeeOptimizerService + positive inbound fees (routing engine Phase 2a)#534
Closed
markettes wants to merge 1 commit into
Closed
feat: FeeOptimizerService + positive inbound fees (routing engine Phase 2a)#534markettes wants to merge 1 commit into
markettes wants to merge 1 commit into
Conversation
…fee-engine path Phase 2a of the heuristic routing engine (stacked on Phase 1 / #533): the pure decision logic and the LND-write primitive the fee optimizer job (2b) will drive. - FeeOptimizerService (pure, singleton): ComputeNextPolicy runs proportional control on the EMA-smoothed local ratio. Authority split (defer to rebalancer outside the rebalance deadband), fee-deadband no-op, per-step + min-delta clamps, outbound/inbound ppm floors and ceilings, and inbound collapse to <=0 when the node disallows positive inbound. Category baseline (p0) both scales the term and seeds the first-eval "jump". - SetChannelFeePolicy: per user request, no separate engine method — the existing method gains an opt-in allowPositiveInboundFees flag (default false). The manual/UI/gRPC path keeps its <=0 inbound cap unchanged; the engine passes true and its writes are marked EngineWrite=true in the audit log for filterability. - Unit tests for the control-law direction table, clamps, inbound-collapse, first-eval seeding, and the positive-inbound write path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Routing engine — Phase 2a (dynamic fee engine: logic + write primitive)
Stacked on #533 (Phase 1). Base branch is
feat/heuristic-fee-engine-phase1, so this PR's diff shows only the Phase 2a layer. Review/merge #533 first.This is the first of two Phase 2 PRs. It adds the pure decision logic and the LND-write primitive the actuator job (Phase 2b) will drive — no actuator runs yet, so behaviour is unchanged.
What's here
FeeOptimizerService(pure, singleton) —ComputeNextPolicyruns proportional control on the EMA-smoothed local ratio:d>0(too local) → lower outbound + positive inbound;d<0(too remote) → raise outbound + negative inbound.≤0when the node disallows positive inbound.p₀scales the term and seeds the first-eval "jump" toward the category baseline.SetChannelFeePolicygains an opt-inallowPositiveInboundFeesflag (defaultfalse). Per review guidance, this reuses the existing method rather than adding a separate engine method: the manual/UI/gRPC path keeps its≤0inbound cap; the engine passestrueand its writes are audit-markedEngineWrite=true.Tests
FeeOptimizerServiceTests: direction table, clamps, inbound-collapse, first-eval seeding,FromConstantsmapping.LightningServiceTests: positive-inbound engine write path + audit marker.Full suite green (337 passed, 1 skipped).
🤖 Generated with Claude Code