From 0d5145d6bb5870ad918d55809b0442d743e18a3b Mon Sep 17 00:00:00 2001 From: ZmnSCPxj jxPCSnmZ Date: Mon, 17 Aug 2020 12:38:16 +0800 Subject: [PATCH] plugins/libplugin-pay.c: Tighten the fuzz. 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. --- plugins/libplugin-pay.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index e83d5658e84c..e171a118b73a 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -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)) @@ -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. */