feat: ChannelFeeOptimizerJob dynamic fee actuator (routing engine Phase 2b)#535
Closed
markettes wants to merge 1 commit into
Closed
feat: ChannelFeeOptimizerJob dynamic fee actuator (routing engine Phase 2b)#535markettes wants to merge 1 commit into
markettes wants to merge 1 commit into
Conversation
Phase 2b of the heuristic routing engine (stacked on Phase 2a): the Quartz actuator that drives the fee optimizer over live channels. - ChannelFeeOptimizerJob (~30 min, DisallowConcurrentExecution, IDbContextFactory): reads ChannelRoutingState + raw ListChannels, filters eligibility (owned via ChannelOwnershipHelper, Open, IsDynamicFeeEnabled, capacity >= min, has signal, not circuit-broken), prioritizes by 7-day organic fee revenue then |deviation|, and under ROUTING_ENGINE_FEE_MAX_UPDATES_PER_RUN applies FeeOptimizerService's decision. Enforces the fee-vs-rebalance authority split (skips any channel with an in-flight rebalance), a restart-surviving per-channel throttle, baseline snapshot, and a consecutive-failure circuit breaker. Real LND writes only when neither the global nor per-node dry-run flag is set (go-live one node at a time). - Restore-on-disable: a node with DynamicFeeManagementEnabled off restores each touched channel's baseline once (or freezes with an audit marker), then clears its snapshot so the action is one-shot. - Repository queries: RebalanceRepository.HasInFlightRebalanceBySourceChannel (the authority-split check) and ChannelFeeStateRepository.GetByManagedNodePubKey (batch per-node state + restore-on-disable enumeration). - Quartz wiring in Program.cs; job + repository tests (live write, dry-run gate, authority-split skip, kill-switch, in-flight-source query). 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 2b (dynamic fee actuator)
Stacked on #534 (Phase 2a), which stacks on #533 (Phase 1). Base branch is
feat/heuristic-fee-engine-phase2a, so this PR's diff shows only the Phase 2b layer. Merge #533 → #534 → this.The Quartz actuator that drives
FeeOptimizerServiceover live channels.What's here
ChannelFeeOptimizerJob(~30 min,[DisallowConcurrentExecution],IDbContextFactory):ChannelOwnershipHelper,Open,IsDynamicFeeEnabled, capacity ≥ROUTING_ENGINE_FEE_MIN_CHANNEL_SIZE_SATS, has routing-state signal, not circuit-broken.|deviation|desc, capped atROUTING_ENGINE_FEE_MAX_UPDATES_PER_RUN.ROUTING_ENGINE_DRY_RUNnor the per-nodeRoutingEngineDryRunis set — go live one node at a time.DynamicFeeManagementEnabled=falserestores each touched channel's baseline once (or freezes with an audit marker), then clears its snapshot (one-shot).RebalanceRepository.HasInFlightRebalanceBySourceChannel(authority-split check) andChannelFeeStateRepository.GetByManagedNodePubKey(per-node batch + restore enumeration).Program.cs.Tests
ChannelFeeOptimizerJobTests: live write applies computed policy, global dry-run writes nothing, in-flight rebalance skips the channel entirely, kill-switch short-circuits.RebalanceRepositoryRoutingEngineTests:HasInFlightRebalanceBySourceChanneltrue only for Pending/InFlight source.Full suite green (337 passed, 1 skipped). Job-level actuation is validated on a canary via dry-run per the plan.
🤖 Generated with Claude Code