Skip to content

Commit

Permalink
plugins/libplugin-pay.c: Tighten the fuzz.
Browse files Browse the repository at this point in the history
The fuzz only exists to prevent intermediate nodes from guessing
the distance to the payee by subtracting the nearest lower bin,
which gives us the fee paid to reach the payee.
But since we have a default limit on the max fee budget of 0.5%
(that some of our users complain is *too big*), fuzzing around the
bin size by +/-1% would be sufficient to obscure the fee paid to
reach the payee.

This reduces the presplitter +/-25% and the adaptive splitter
+/-10% to just 5%, which is more than enough to obscure the fee
paid to reach the payee, and could probably be made even smaller.
  • Loading branch information
ZmnSCPxj committed Aug 25, 2020
1 parent 060ac0b commit 0d5145d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/libplugin-pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -2844,9 +2844,9 @@ static struct amount_msat fuzzed_near(struct amount_msat target,
s64 fuzz;
struct amount_msat res = target;

/* Somewhere within 25% of target please. */
fuzz = pseudorand(target.millisatoshis / 2) /* Raw: fuzz */
- target.millisatoshis / 4; /* Raw: fuzz */
/* Somewhere within 5% of target please. */
fuzz = pseudorand(target.millisatoshis / 10) /* Raw: fuzz */
- target.millisatoshis / 20; /* Raw: fuzz */
res.millisatoshis = target.millisatoshis + fuzz; /* Raw: fuzz < msat */

if (amount_msat_greater(res, max))
Expand Down Expand Up @@ -3219,8 +3219,8 @@ static void adaptive_splitter_cb(struct adaptive_split_mod_data *d, struct payme
} else if (p->step == PAYMENT_STEP_FAILED && !p->abort) {
if (amount_msat_greater(p->amount, MPP_ADAPTIVE_LOWER_LIMIT)) {
struct payment *a, *b;
/* Random number in the range [90%, 110%] */
double rand = pseudorand_double() * 0.2 + 0.9;
/* Random number in the range [95%, 105%] */
double rand = pseudorand_double() * 0.1 + 0.95;
u64 mid = round((p->amount.millisatoshis / PHI) * rand); /* Raw: multiplication */
bool ok;
/* Use the start constraints, not the ones updated by routes and shadow-routes. */
Expand Down

0 comments on commit 0d5145d

Please sign in to comment.