-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Askrene algorithm switcher #8163
base: master
Are you sure you want to change the base?
Askrene algorithm switcher #8163
Conversation
089eed9
to
b570166
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad idea! I'm just not sure about some of the refactorings.
/* Returns an error message, or sets *routes */ | ||
static const char *get_routes(const tal_t *ctx, | ||
struct command *cmd, | ||
const struct node_id *source, | ||
const struct node_id *dest, | ||
struct amount_msat amount, | ||
struct amount_msat maxfee, | ||
u32 finalcltv, | ||
u32 maxdelay, | ||
const char **layers, | ||
struct gossmap_localmods *localmods, | ||
const struct layer *local_layer, | ||
bool single_path, | ||
struct route ***routes, | ||
struct amount_msat **amounts, | ||
const struct additional_cost_htable *additional_costs, | ||
double *probability) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handing arguments inside a struct (rather than using them explicitly) is an anti-pattern. We need to use this for callbacks, which is why we do it, but we try to constrain the damage to one location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't understand your request here.
I didn't change the arguments passed to do_getroutes
.
That function changed from this:
static struct command_result *do_getroutes(struct command *cmd,
struct gossmap_localmods *localmods,
const struct getroutes_info *info)
{
...
// unpack getroutes_info and calls get_routes
err = get_routes(cmd, cmd,
info->source, info->dest,
*info->amount, *info->maxfee, *info->finalcltv,
*info->maxdelay, info->layers, localmods, info->local_layer,
have_layer(info->layers, "auto.no_mpp_support"),
&routes, &amounts, info->additional_costs, &probability);
// write results in a json stream and returns
...
return command_finished(cmd, response);
}
static struct command_result *json_getroutes(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
// packages all input data into getroutes_info
struct getroutes_info *info = tal(cmd, struct getroutes_info);
...
return do_getroutes(cmd, gossmap_localmods_new(cmd), info);
}
to this
static struct command_result *do_getroutes(struct command *cmd,
struct gossmap_localmods *localmods,
const struct getroutes_info *info)
{
// do some stuff that previously was done in get_routes
...
// unpack getroutes_info and calls default_routes
err = default_routes(rq, rq, srcnode, dstnode, *info->amount,
/* only one path? = */
have_layer(info->layers, "auto.no_mpp_support"),
*info->maxfee, *info->finalcltv, *info->maxdelay,
&flows, &probability);
// write results in a json stream and returns
...
return command_finished(cmd, response);
}
static struct command_result *json_getroutes(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
// packages all input data into getroutes_info
struct getroutes_info *info = tal(cmd, struct getroutes_info);
...
return do_getroutes(cmd, gossmap_localmods_new(cmd), info);
}
Some of the code in the definition of get_routes
was moved to mcf.c
under the name
default_routes
and some was moved to do_getroutes
.
Add log information about the runtime of getroutes. Changelog-None: askrene: add runtime of getroutes to the logs Signed-off-by: Lagrang3 <[email protected]>
c636e4d
to
da220a8
Compare
Move the feature tuning algorithm to mcf.c, ie. the loops for searching a good mu and delay_feefactor to satisfy the problem constraints. We are looking to set the stage for an execution logic that allows for multiple choices of routing algorithms, mainly for experimenting without breaking the default working code. Changelog-None Signed-off-by: Lagrang3 <[email protected]>
8a14144
to
c194763
Compare
Prefer the following programming pattern: do_getroutes(){ do_something1(); do_something2(); do_something3(); } rather than get_routes(){ do_something1(); do_something2(); } do_getroutes(){ get_routes(); do_something3(); } Changelog-None Signed-off-by: Lagrang3 <[email protected]>
Changelog-None Signed-off-by: Lagrang3 <[email protected]>
c194763
to
28dc007
Compare
This PR only does a bit of refactoring to askrene.
I would like to add the possibility to switch algorithms in askrene.
This would not be available from the user interface, it is just for developers.
It would allow us to test different algorithms for experimenting performance and reliability
without risking breaking the existing code.
This PR sets the stage for switching between multiple MCF algorithms.
This PR is built on top of #7932.