Skip to content
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

plugins/topology: remove topology functionality from gossipd. #4585

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
370aee0
ccan: update to get RETURNS_NONNULL macro.
rustyrussell Jun 14, 2021
ab61067
common: note that command_fail doesn't return NULL.
rustyrussell Jun 14, 2021
ee94799
topology: plugin to implement getroute command.
rustyrussell Jun 14, 2021
d1f0c6b
pyln-client: hack in test that getroute returns the same old/new.
rustyrussell Jun 14, 2021
e1ba3e7
plugins/topology: listchannels command.
rustyrussell Jun 14, 2021
2063c91
plugins/topology: make listchannels mark disconnected local channels …
rustyrussell Jun 14, 2021
83cef65
pyln-client: hack in test that listchannels returns the same old/new.
rustyrussell Jun 14, 2021
56014eb
common/wireaddr: fromwire_wireaddr_array helper.
rustyrussell Jun 14, 2021
781d811
plugins/topology: add listnodes command.
rustyrussell Jun 14, 2021
63b7e09
pyln-client: hack in test that listnodes returns the same old/new.
rustyrussell Jun 14, 2021
8da24b8
plugins/topology: listincoming function to help invoices.
rustyrussell Jun 14, 2021
f62b90f
invoice: overhaul routehints to use topology.listincoming, cleanup.
rustyrussell Jun 14, 2021
a7fd016
signmessage: use listnodes instead of gossipd_getnodes_request.
rustyrussell Jun 14, 2021
4b8fbf2
pyln-client: revert old/new comparisons for getroute, listchannels, l…
rustyrussell Jun 14, 2021
ec86963
gossipd/test: remove routing tests.
rustyrussell Jun 14, 2021
9a7d49d
gossipd: remove routing, listchannels and listnodes infrastructure.
rustyrussell Jun 14, 2021
a0e1020
lightningd: wait for gossipd to finish initalizing before starting pl…
rustyrussell Jun 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ccan/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CCAN imported from http://ccodearchive.net.

CCAN version: init-2504-g48b4ffc3
CCAN version: init-2506-gec95c3c5
13 changes: 13 additions & 0 deletions ccan/ccan/compiler/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,19 @@
#define NON_NULL_ARGS(...)
#endif

#if HAVE_ATTRIBUTE_RETURNS_NONNULL
/**
* RETURNS_NONNULL - specify that this function cannot return NULL.
*
* Mainly an optimization opportunity, but can also suppress warnings.
*
* Example:
* RETURNS_NONNULL char *my_copy(char *buf);
*/
#define RETURNS_NONNULL __attribute__((__returns_nonnull__))
#else
#define RETURNS_NONNULL
#endif

#if HAVE_ATTRIBUTE_SENTINEL
/**
Expand Down
3 changes: 3 additions & 0 deletions ccan/tools/configurator/configurator.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ static const struct test base_tests[] = {
{ "HAVE_ATTRIBUTE_NONNULL", "__attribute__((nonnull)) support",
"DEFINES_FUNC", NULL, NULL,
"static char *__attribute__((nonnull)) func(char *p) { return p; }" },
{ "HAVE_ATTRIBUTE_RETURNS_NONNULL", "__attribute__((returns_nonnull)) support",
"DEFINES_FUNC", NULL, NULL,
"static const char *__attribute__((returns_nonnull)) func(void) { return \"hi\"; }" },
{ "HAVE_ATTRIBUTE_SENTINEL", "__attribute__((sentinel)) support",
"DEFINES_FUNC", NULL, NULL,
"static int __attribute__((sentinel)) func(int i, ...) { return i; }" },
Expand Down
2 changes: 1 addition & 1 deletion common/json_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct command_result;
/* Caller supplied this: param assumes it can call it. */
struct command_result *command_fail(struct command *cmd, errcode_t code,
const char *fmt, ...)
PRINTF_FMT(3, 4) WARN_UNUSED_RESULT;
PRINTF_FMT(3, 4) WARN_UNUSED_RESULT RETURNS_NONNULL;

/* Convenient wrapper for "paramname: msg: invalid token '.*%s'" */
static inline struct command_result *
Expand Down
14 changes: 8 additions & 6 deletions common/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,10 @@ const char *param_subcommand(struct command *cmd, const char *buffer,
return subcmd;

/* We really do ignore this. */
if (command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Unknown subcommand '%s'", subcmd))
;
struct command_result *ignore;
ignore = command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Unknown subcommand '%s'", subcmd);
assert(ignore);
return NULL;
}

Expand All @@ -323,9 +324,10 @@ bool param(struct command *cmd, const char *buffer,
}
if (!param_add(&params, name, required, cbx, arg)) {
/* We really do ignore this return! */
if (command_fail(cmd, PARAM_DEV_ERROR,
"developer error: param_add %s", name))
;
struct command_result *ignore;
ignore = command_fail(cmd, PARAM_DEV_ERROR,
"developer error: param_add %s", name);
assert(ignore);
va_end(ap);
return false;
}
Expand Down
29 changes: 29 additions & 0 deletions common/wireaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,35 @@ struct addrinfo *wireaddr_to_addrinfo(const tal_t *ctx,
abort();
}

struct wireaddr *fromwire_wireaddr_array(const tal_t *ctx, const u8 *ser)
{
const u8 *cursor = ser;
size_t len = tal_count(ser);
struct wireaddr *wireaddrs = tal_arr(ctx, struct wireaddr, 0);

while (cursor && len) {
struct wireaddr wireaddr;

/* BOLT #7:
*
* The receiving node:
*...
* - SHOULD ignore the first `address descriptor` that does
* NOT match the types defined above.
*/
if (!fromwire_wireaddr(&cursor, &len, &wireaddr)) {
if (!cursor)
/* Parsing address failed */
return tal_free(wireaddrs);
/* Unknown type, stop there. */
break;
}

tal_arr_expand(&wireaddrs, wireaddr);
}
return wireaddrs;
}

bool all_tor_addresses(const struct wireaddr_internal *wireaddr)
{
for (int i = 0; i < tal_count(wireaddr); i++) {
Expand Down
3 changes: 3 additions & 0 deletions common/wireaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,7 @@ struct addrinfo *wireaddr_internal_to_addrinfo(const tal_t *ctx,

bool all_tor_addresses(const struct wireaddr_internal *wireaddr);

/* Decode an array of serialized addresses from node_announcement */
struct wireaddr *fromwire_wireaddr_array(const tal_t *ctx, const u8 *ser);

#endif /* LIGHTNING_COMMON_WIREADDR_H */
15 changes: 6 additions & 9 deletions doc/lightning-invoice.7

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions doc/lightning-invoice.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ The following error codes may occur:
- 902: None of the specified *exposeprivatechannels* were usable.

One of the following warnings may occur (on success):
- *warning\_offline* if no channel with a currently connected peer has
the incoming capacity to pay this invoice
- *warning\_capacity* if there is no channel that has sufficient
incoming capacity
- *warning\_deadends* if there is no channel that is not a dead-end
- *warning_capacity*: even using all possible channels, there's not enough incoming capacity to pay this invoice.
- *warning_offline*: there would be enough incoming capacity, but some channels are offline, so there isn't.
- *warning_deadends*: there would be enough incoming capacity, but some channels are dead-ends (no other public channels from those peers), so there isn't.
- *warning_private_unused*: there would be enough incoming capacity, but some channels are unannounced and *exposeprivatechannels* is *false*, so there isn't.
- *warning_mpp* if there is sufficient capacity, but not in a single channel,
so the payer will have to use multi-part payments.
- *warning_mpp_capacity* if there is not sufficient capacity, even with all
channels.

AUTHOR
------
Expand Down
39 changes: 32 additions & 7 deletions gossipd/gossip_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <errno.h>
#include <gossipd/gossip_generation.h>
#include <gossipd/gossip_store.h>
#include <gossipd/gossip_store_wiregen.h>
#include <gossipd/gossipd.h>
#include <gossipd/gossipd_peerd_wiregen.h>
#include <hsmd/hsmd_wiregen.h>
Expand Down Expand Up @@ -414,6 +415,12 @@ void refresh_local_channel(struct daemon *daemon,
{
const struct half_chan *hc;
struct local_cupdate *lc;
u8 *prev;
secp256k1_ecdsa_signature signature;
struct bitcoin_blkid chain_hash;
struct short_channel_id short_channel_id;
u32 timestamp;
u8 message_flags, channel_flags;

hc = &local_chan->chan->half[local_chan->direction];

Expand All @@ -425,14 +432,32 @@ void refresh_local_channel(struct daemon *daemon,
lc->daemon = daemon;
lc->local_chan = local_chan;
lc->even_if_identical = even_if_identical;
lc->disable = (hc->channel_flags & ROUTING_FLAGS_DISABLED)
|| local_chan->local_disabled;
lc->cltv_expiry_delta = hc->delay;
lc->htlc_minimum = hc->htlc_minimum;
lc->htlc_maximum = hc->htlc_maximum;
lc->fee_base_msat = hc->base_fee;
lc->fee_proportional_millionths = hc->proportional_fee;

prev = cast_const(u8 *,
gossip_store_get(tmpctx, daemon->rstate->gs,
local_chan->chan->half[local_chan->direction]
.bcast.index));

/* If it's a private update, unwrap */
fromwire_gossip_store_private_update(tmpctx, prev, &prev);

if (!fromwire_channel_update_option_channel_htlc_max(prev,
&signature, &chain_hash,
&short_channel_id, &timestamp,
&message_flags, &channel_flags,
&lc->cltv_expiry_delta,
&lc->htlc_minimum,
&lc->fee_base_msat,
&lc->fee_proportional_millionths,
&lc->htlc_maximum)) {
status_broken("Could not decode local channel_update %s!",
tal_hex(tmpctx, prev));
tal_free(lc);
return;
}

lc->disable = (channel_flags & ROUTING_FLAGS_DISABLED)
|| local_chan->local_disabled;
update_local_channel(lc);
}

Expand Down
Loading