Commit df23640
perf(metrics): use lp_min_cost_to_cover in LowestFee bound
Replaces the single-benchmark estimate in `LowestFee::bound`'s "target met,
has change, can we go changeless?" branch with the shared
`lp_min_cost_to_cover` helper. The old code used only the lowest-value_pwu
unselected candidate as a benchmark and assumed it scaled arbitrarily,
which under-estimates the cost when the benchmark's `|ev|` is less than
the amount above the change threshold.
LP-relaxed knapsack handles this correctly: takes the benchmark fully
(it's the most-efficient by definition), then progressively worse-ratio
candidates until the deficit is covered.
The bound is provably tighter than V1 (or equal): for any
`amount <= |ev_benchmark|`, the LP answer equals V1's; for
`amount > |ev_benchmark|`, the LP answer is strictly larger (tighter LB),
because V1 over-scales the benchmark beyond its actual size.
In the synthetic `benches/lowest_fee_bounds` pool the V1/V2 round counts
are identical — the path "amount > benchmark's |ev|" doesn't fire in
this particular pool shape. The tightening is for adversarial / dust-heavy
pools the proptest occasionally exercises.
`ensure_bound_is_not_too_tight` proptest still passes (all 7 LowestFee
tests green).
Removes the TODO comment that pointed at this exact tightening
opportunity.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 600400c commit df23640
1 file changed
Lines changed: 31 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
92 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
93 | 88 | | |
94 | 89 | | |
95 | 90 | | |
| |||
0 commit comments