getroute: remove seed arg, document fromid, make default fuzzpercent match docs.

seed isn't very useful at this level: I've left it in routing.c
because it might be useful for detailed testing.  Pretty sure it's unused,
so I simply removed it.

The fuzzpercent is documented to default at 5%, but actually was 75%.
Fix that too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-01-15 14:25:27 +10:30 committed by Christian Decker
parent e65b680807
commit f321b1d35f
7 changed files with 15 additions and 37 deletions

View File

@ -109,6 +109,8 @@ changes.
### Removed
- JSON API: the optional 'seed' parameter to `getroute` was removed.
### Fixed
- Startup: more coherent complaint if daemon already running.

View File

@ -2,12 +2,12 @@
.\" Title: lightning-getroute
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 09/17/2018
.\" Date: 12/17/2018
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "LIGHTNING\-GETROUTE" "7" "09/17/2018" "\ \&" "\ \&"
.TH "LIGHTNING\-GETROUTE" "7" "12/17/2018" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -31,7 +31,7 @@
lightning-getroute \- Command for routing a payment (low\-level)\&.
.SH "SYNOPSIS"
.sp
\fBgetroute\fR \fIid\fR \fImsatoshi\fR \fIriskfactor\fR [\fIcltv\fR] [\fIfuzzpercent\fR] [\fIseed\fR]
\fBgetroute\fR \fIid\fR \fImsatoshi\fR \fIriskfactor\fR [\fIcltv\fR] [\fIfromid\fR] [\fIfuzzpercent\fR]
.SH "DESCRIPTION"
.sp
The \fBgetroute\fR RPC command attempts to find the best route for the payment of \fImsatoshi\fR to lightning node \fIid\fR, such that the payment will arrive at \fIid\fR with \fIcltv\fR\-blocks to spare (default 9)\&.
@ -42,9 +42,9 @@ For example, if you thought there was a 1% chance that a node would fail, and it
.sp
If you didn\(cqt care about risk, \fIriskfactor\fR would be zero\&.
.sp
The \fIfuzzpercent\fR is a positive floating\-point number, representing a percentage of the actual fee\&. The \fIfuzzpercent\fR is used to distort computed fees along each channel, to provide some randomization to the route generated\&. 0\&.0 means the exact fee of that channel is used, while 100\&.0 means the fee used might be from 0 to twice the actual fee\&. The default is 5\&.0, or up to 5% fee distortion\&.
\fIfromid\fR is the node to start the route from: default is this node\&.
.sp
The \fIseed\fR is a string whose bytes are used to seed the RNG for the route randomization\&. If not specified, a random string is used\&.
The \fIfuzzpercent\fR is a positive floating\-point number, representing a percentage of the actual fee\&. The \fIfuzzpercent\fR is used to distort computed fees along each channel, to provide some randomization to the route generated\&. 0\&.0 means the exact fee of that channel is used, while 100\&.0 means the fee used might be from 0 to twice the actual fee\&. The default is 5\&.0, or up to 5% fee distortion\&.
.SH "RISKFACTOR EFFECT ON ROUTING"
.sp
The risk factor is treated as if it were an additional fee on the route, for the purposes of comparing routes\&.

View File

@ -9,7 +9,7 @@ lightning-getroute - Command for routing a payment (low-level).
SYNOPSIS
--------
*getroute* 'id' 'msatoshi' 'riskfactor' ['cltv'] ['fuzzpercent'] ['seed']
*getroute* 'id' 'msatoshi' 'riskfactor' ['cltv'] ['fromid'] ['fuzzpercent']
DESCRIPTION
-----------
@ -29,6 +29,8 @@ fail, and it would cost you 20% per annum if that happened,
If you didn't care about risk, 'riskfactor' would be zero.
'fromid' is the node to start the route from: default is this node.
The 'fuzzpercent' is a positive floating-point number, representing a percentage of the actual fee.
The 'fuzzpercent' is used to distort computed fees along each channel,
to provide some randomization to the route generated.
@ -36,10 +38,6 @@ to provide some randomization to the route generated.
while 100.0 means the fee used might be from 0 to twice the actual fee.
The default is 5.0, or up to 5% fee distortion.
The 'seed' is a string whose bytes are used to seed the RNG for
the route randomization.
If not specified, a random string is used.
RISKFACTOR EFFECT ON ROUTING
----------------------------

View File

@ -32,7 +32,6 @@ gossip_getroute_request,,msatoshi,u64
gossip_getroute_request,,riskfactor,u16
gossip_getroute_request,,final_cltv,u32
gossip_getroute_request,,fuzz,double
gossip_getroute_request,,seed,struct siphash_seed
gossip_getroute_reply,3106
gossip_getroute_reply,,num_hops,u16

1 #include <common/cryptomsg.h>
32 gossip_getroute_reply,3106 gossip_getroute_reply,,num_hops,u16
33 gossip_getroute_reply,,num_hops,u16 gossip_getroute_reply,,hops,num_hops*struct route_hop
34 gossip_getroute_reply,,hops,num_hops*struct route_hop gossip_getchannels_request,3007
gossip_getchannels_request,3007
35 gossip_getchannels_request,,short_channel_id,?struct short_channel_id
36 gossip_getchannels_reply,3107
37 gossip_getchannels_reply,,num_channels,u16

View File

@ -1870,7 +1870,6 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
u8 *out;
struct route_hop *hops;
double fuzz;
struct siphash_seed seed;
/* To choose between variations, we need to know how much we're
* sending (eliminates too-small channels, and also effects the fees
@ -1881,7 +1880,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
if (!fromwire_gossip_getroute_request(msg,
&source, &destination,
&msatoshi, &riskfactor,
&final_cltv, &fuzz, &seed))
&final_cltv, &fuzz))
master_badmsg(WIRE_GOSSIP_GETROUTE_REQUEST, msg);
status_trace("Trying to find a route from %s to %s for %"PRIu64" msatoshi",
@ -1891,7 +1890,7 @@ static struct io_plan *getroute_req(struct io_conn *conn, struct daemon *daemon,
/* routing.c does all the hard work; can return NULL. */
hops = get_route(tmpctx, daemon->rstate, &source, &destination,
msatoshi, riskfactor, final_cltv,
fuzz, &seed);
fuzz, siphash_seed());
out = towire_gossip_getroute_reply(NULL, hops);
daemon_conn_send(daemon->master, take(out));

View File

@ -300,7 +300,6 @@ static struct command_result *json_getroute(struct command *cmd,
struct lightningd *ld = cmd->ld;
struct pubkey *destination;
struct pubkey *source;
const jsmntok_t *seedtok;
u64 *msatoshi;
unsigned *cltv;
double *riskfactor;
@ -310,7 +309,6 @@ static struct command_result *json_getroute(struct command *cmd,
* be selected) at the cost of increasing the probability of
* selecting the higher-fee paths. */
double *fuzz;
struct siphash_seed seed;
if (!param(cmd, buffer, params,
p_req("id", param_pubkey, &destination),
@ -318,29 +316,16 @@ static struct command_result *json_getroute(struct command *cmd,
p_req("riskfactor", param_double, &riskfactor),
p_opt_def("cltv", param_number, &cltv, 9),
p_opt_def("fromid", param_pubkey, &source, ld->id),
p_opt("seed", param_tok, &seedtok),
p_opt_def("fuzzpercent", param_percent, &fuzz, 75.0),
p_opt_def("fuzzpercent", param_percent, &fuzz, 5.0),
NULL))
return command_param_failed();
/* Convert from percentage */
*fuzz = *fuzz / 100.0;
if (seedtok) {
if (seedtok->end - seedtok->start > sizeof(seed))
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"seed must be < %zu bytes",
sizeof(seed));
memset(&seed, 0, sizeof(seed));
memcpy(&seed, buffer + seedtok->start,
seedtok->end - seedtok->start);
} else
randombytes_buf(&seed, sizeof(seed));
u8 *req = towire_gossip_getroute_request(cmd, source, destination,
*msatoshi, *riskfactor * 1000,
*cltv, fuzz, &seed);
*cltv, fuzz);
subd_req(ld->gossip, ld->gossip, req, -1, 0, json_getroute_reply, cmd);
return command_still_pending(cmd);
}

View File

@ -508,7 +508,6 @@ static struct command_result *json_pay_try(struct pay *pay)
u8 *req;
struct command *cmd = pay->cmd;
struct timeabs now = time_now();
struct siphash_seed seed;
u64 maxoverpayment;
u64 overpayment;
@ -534,9 +533,6 @@ static struct command_result *json_pay_try(struct pay *pay)
/* Clear route */
pay->route = tal_free(pay->route);
/* Generate random seed */
randombytes_buf(&seed, sizeof(seed));
/* Generate an overpayment, from fuzz * maxfee. */
/* Now normally the use of double for money is very bad.
* Note however that a later stage will ensure that
@ -561,8 +557,7 @@ static struct command_result *json_pay_try(struct pay *pay)
pay->msatoshi + overpayment,
pay->riskfactor,
pay->min_final_cltv_expiry,
&pay->fuzz,
&seed);
&pay->fuzz);
subd_req(pay->try_parent, cmd->ld->gossip, req, -1, 0, json_pay_getroute_reply, pay);
return NULL;