Commit Graph

12611 Commits

Author SHA1 Message Date
Alex Myers d1402e06f9 gossipd: load and store node_announcements correctly
Loading the gossip_store would not create a pending node announcement
when the node already had a zombie channel.  This would cause the node
announcement to attempt to be loaded, but fail because it had no
broadcastable channels.  Accepting a pending node announcement as when
normally loading from the channel corrects this.
`node_has_public_channels` taking into account zombie channels enables
this behavior.

Separately, node_announcements were still being flagged as zombies
in the gossip store despite that feature being removed.

Changelog-None
2023-03-01 15:36:13 -06:00
Alex Myers d5246e43bb gossipd: flag zombie channels when loading from gossip_store
Without inheriting zombie status, gossipd would allow regular channel updates
into the store until the pruning cycle hits (and the channel is properly
flagged) which is 3.5 days. Applying zombie status when reading channel
updates from the store prevents this.

Changelog-None
2023-03-01 15:36:13 -06:00
Alex Myers 07c04d247e gossipd: correct node_announcement order when zombifying channels
remove_chan_from_node already corrects the ordering if a node_announcement
is left ahead of the next oldest channel_announcement, but zombifying should
do that check (and reorder if necessary) too.

Changelog-None
2023-03-01 15:36:13 -06:00
Christian Decker f1c29aa3bd keysend: Do not strip even TLV types that were allowlisted
Changelog-Fixed: keysend: Keysend would strip even allowed extra TLV types before resolving, this is no longer the case.
2023-02-28 15:00:44 -06:00
Christian Decker 5dc85d185a keysend: Extract `accept-extra-tlv-types` from `listconfigs`
Since it is an optional field in the `listconfigs` output we can't use
the `rpc_scan` mechanism (doesn't handle optionals yet). We'll use
that list of accepted types later to avoid stripping them.
2023-02-28 15:00:44 -06:00
Christian Decker 29031c02ca libplugin: Expose the `jsonrpc_request_sync` method
This one was mostly used in libplugin, but not available outside. It
is rather useful, so let's expose it.
2023-02-28 15:00:44 -06:00
Christian Decker 4a38e37b59 json: Add method to parse a u64 array
This will be used to parse the extratlvs from `listconfigs` in
`keysend`, so we don't accidentally strip values we'd like to keep.
2023-02-28 15:00:44 -06:00
Rusty Russell 1426ac881b pytest: remove openchannel('v2') marker from test_sql
Now we'll test it in CI!  Manually set experimental-dual-fund.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-28 14:11:12 -06:00
Rusty Russell f3baa3e510 sql: fix crash on fresh node_announcment.
Missing quotes when we delete the old one!

Reported-by: Alex Myers
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-28 14:11:12 -06:00
Rusty Russell 855980641c sql: fix schema tests since num_channels added to listpeers.
Commit a418615b7f ("rpc: adds
num_channels to listpeers") broke the sql tests.  Turns out, no
openchannel v2 tests are run in CI!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-28 14:11:12 -06:00
Vincenzo Palazzo bcc94b2d43 fix: do not send send peerstorage msg when disabled
This commit will disable the peerstorage plugins
when the feature is not enabled.

I found this issue with lnprototest, and I guess
we did not find it with normal run because
other the unknown messages are ingored?

Changelog-Fixed: Disable the protocol messages when peerstorage is disabled.
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-27 11:18:56 -06:00
Rusty Russell 355a7ae827 pay: fix delpay to actually delete.
It works for the trivial case, where groupid and partid are the same,
but silently deletes nothing in the other cases (or worse, deletes the
wrong entry!).

See: #5835
Changelog-Fixed: `delpay`: actually delete the specified payment (mainly found by `autoclean`).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-27 11:08:12 -06:00
Rusty Russell 38d90b2505 autoclean: fix timer crash when we're cleaning two things at once.
If we had two things to clean, we fired off two requests (eg.
listforwards and listinvoices) and both marked the timer as finished,
triggering an assert.

We already have a refcount for outstanding requests to avoid this
for e.g. outstanding del commands, so use it here too!

```
Jan 19 19:20:00  lightningd[748044]: autoclean: plugins/libplugin.c:445: timer_complete: Assertion `p->in_timer > 0' failed.
Jan 19 19:20:00  lightningd[748044]: autoclean: FATAL SIGNAL 6 (version v22.11.1)
Jan 19 19:20:00  lightningd[748044]: 0x562c388136e4 send_backtrace
Jan 19 19:20:00  lightningd[748044]:         common/daemon.c:33
Jan 19 19:20:00  lightningd[748044]: 0x562c3881376c crashdump
Jan 19 19:20:00  lightningd[748044]:         common/daemon.c:46
Jan 19 19:20:00  lightningd[748044]: 0x7f26d0898d5f ???
Jan 19 19:20:00  lightningd[748044]:         ./signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
Jan 19 19:20:00  lightningd[748044]: 0x7f26d0898ce1 __GI_raise
Jan 19 19:20:00  lightningd[748044]:         ../sysdeps/unix/sysv/linux/raise.c:51
Jan 19 19:20:00  lightningd[748044]: 0x7f26d0882536 __GI_abort
Jan 19 19:20:00  lightningd[748044]:         ./stdlib/abort.c:79
Jan 19 19:20:00  lightningd[748044]: 0x7f26d088240e __assert_fail_base
Jan 19 19:20:00  lightningd[748044]:         ./assert/assert.c:92
Jan 19 19:20:00  lightningd[748044]: 0x7f26d0891661 __GI___assert_fail
Jan 19 19:20:00  lightningd[748044]:         ./assert/assert.c:101
Jan 19 19:20:00  lightningd[748044]: 0x562c3880355d timer_complete
Jan 19 19:20:00  lightningd[748044]:         plugins/libplugin.c:445
Jan 19 19:20:00  lightningd[748044]: 0x562c38800b54 clean_finished
Jan 19 19:20:00  lightningd[748044]:         plugins/autoclean.c:122
Jan 19 19:20:00  lightningd[748044]: 0x562c388010ed clean_finished_one
Jan 19 19:20:00  lightningd[748044]:         plugins/autoclean.c:132
Jan 19 19:20:00  lightningd[748044]: 0x562c388011b6 del_done
Jan 19 19:20:00  lightningd[748044]:         plugins/autoclean.c:149
Jan 19 19:20:00  lightningd[748044]: 0x562c388058b5 handle_rpc_reply
Jan 19 19:20:00  lightningd[748044]:         plugins/libplugin.c:768
Jan 19 19:20:00  lightningd[748044]: 0x562c38805a39 rpc_read_response_one
Jan 19 19:20:00  lightningd[748044]:         plugins/libplugin.c:944
Jan 19 19:20:00  lightningd[748044]: 0x562c38805ad7 rpc_conn_read_response
Jan 19 19:20:00  lightningd[748044]:         plugins/libplugin.c:968
Jan 19 19:20:00  lightningd[748044]: 0x562c38876b60 next_plan
Jan 19 19:20:00  lightningd[748044]:         ccan/ccan/io/io.c:59
Jan 19 19:20:00  lightningd[748044]: 0x562c38876fe7 do_plan
Jan 19 19:20:00  lightningd[748044]:         ccan/ccan/io/io.c:407
Jan 19 19:20:00  lightningd[748044]: 0x562c38877080 io_ready
Jan 19 19:20:00  lightningd[748044]:         ccan/ccan/io/io.c:417
Jan 19 19:20:00  lightningd[748044]: 0x562c3887823c io_loop
Jan 19 19:20:00  lightningd[748044]:         ccan/ccan/io/poll.c:453
Jan 19 19:20:00  lightningd[748044]: 0x562c38805d11 plugin_main
Jan 19 19:20:00  lightningd[748044]:         plugins/libplugin.c:1801
Jan 19 19:20:00  lightningd[748044]: 0x562c38801c7a main
Jan 19 19:20:00  lightningd[748044]:         plugins/autoclean.c:613
```

Fixes: #5912
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-27 11:05:36 -06:00
niftynei e315f30728 db-fix: update NULL lease_satoshi fields to zero
Missed a DEFAULT in the db clause.

Feb 15 16:02:12 citrine lightningd[902093]: Accessing a null column lease_satoshi/15 in query SELECT  funding_tx_id, funding_tx_outnum, funding_feerate, funding_satoshi, our_funding_satoshi, funding_psbt, last_tx, last_sig, funding_tx_remote_sigs_received, lease_expiry, lease_commit_sig, lease_chan_max_msat, lease_chan_max_ppt, lease_blockheight_start, lease_fee, lease_satoshi FROM channel_funding_inflights WHERE channel_id = ? ORDER BY funding_feerate

Fixes #6016
2023-02-15 18:08:25 -06:00
Alex Myers 7079fb506f meta: Update changelog for 23.02rc3
Changelog-None
2023-02-15 16:07:45 -06:00
Alex Myers 463355de59 gossipd: remember to squelch node announcements when shuffling
Closing channels would previously require moving the node announcements
in the gossip store on occasion. They incorrectly lost their spam flag
during this process (would no longer be squelched.)

Changelog-None
2023-02-15 14:19:42 -06:00
Rusty Russell 69cd043189 gossipd: remove redundant is_node_zombie() in routing_add_node_announcement.
A zombie channel is not considered broadcastable, so if all channels
are zombies (i.e. is_node_zombie() is true), then
node_has_broadcastable_channels() is false.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-15 14:19:42 -06:00
Rusty Russell baeebf2863 gossipd: remove any zombified node_announcements on load.
This can happen if you were running an rc.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-15 14:19:42 -06:00
Rusty Russell 2e7c08824a gossipd: don't zombify node_announcements, just forget them.
This simplifies things (we'll get node_announcement if they ever
rebroadcast), since we clearly have an issue with node_announcement for
zombie nodes.

Changes:
1. Remove now-unused gossip_store_mark_nannounce_zombie and resurrect_nannouncements.
2. Don't consider zombie channels to count when deciding whether to move node_announcement
   (node_announcement must be preceded by at least one broadcastable channel_announcement).
3. Treat incoming node_announcement where we have all-zombie channels the same as if
   we had no channels.
4. Remove node_announcement whenever we have no announcable channels (not just zombies).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-15 14:19:42 -06:00
Rusty Russell 4fc3c26671 gossipd: don't complain about unknown node_announcements if it's a zombie.
They might not consider it a zombie, and in fact this happens with the
next changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-15 14:19:42 -06:00
Rusty Russell 167209d595 gossipd: don't broadcast node_announcement if we have no public channels.
This could always happen if we armed the timer when we did have public
channels, and by the time we did our node_announcement we no longer
did, but it gets triggered in our tests when we remove (our own!)
zombied node_announcement in the next patch.
2023-02-15 14:19:42 -06:00
Rusty Russell 9e93826eea gossipd: neaten node_has_broadcastable_channels logic.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-15 14:19:42 -06:00
Rusty Russell 73e50b26f9 devtools: fix ZOMBIE detection in devtools/dump-gossipstore.
A victim of simultaneous changes, and I didn't pick it up :(
    
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-15 14:19:42 -06:00
Adi Shankara 0110026190 Change year to 2023 in LICENSE
Changelog-None
2023-02-15 06:52:18 -06:00
Vincenzo Palazzo a104380e49 fix: fixes `FATAL SIGNAL 11` on gossmap node
This will fix a crash that I caused on armv7
and by looking inside the coredump with gdb
(by adding an assert on n that must be
different from null) I get the following stacktrace

```
(gdb) bt
\#0  0x00000000 in ?? ()
\#1  0x0043a038 in send_backtrace (why=0xbe9e3600 "FATAL SIGNAL 11") at common/daemon.c:36
\#2  0x0043a0ec in crashdump (sig=11) at common/daemon.c:46
\#3  <signal handler called>
\#4  0x00406d04 in node_announcement (map=0x938ecc, nann_off=495146) at common/gossmap.c:586
\#5  0x00406fec in map_catchup (map=0x938ecc, num_rejected=0xbe9e3a40) at common/gossmap.c:643
\#6  0x004073a4 in load_gossip_store (map=0x938ecc, num_rejected=0xbe9e3a40) at common/gossmap.c:697
\#7  0x00408244 in gossmap_load (ctx=0x0, filename=0x4e16b8 "gossip_store", num_channel_updates_rejected=0xbe9e3a40) at common/gossmap.c:976
\#8  0x0041a548 in init (p=0x93831c, buf=0x9399d4 "\n\n{\"jsonrpc\":\"2.0\",\"id\":\"cln:init#25\",\"method\":\"init\",\"params\":{\"options\":{},\"configuration\":{\"lightning-dir\":\"/home/vincent/.lightning/testnet\",\"rpc-file\":\"lightning-rpc\",\"startup\":true,\"network\":\"te"..., config=0x939cdc) at plugins/topology.c:622
\#9  0x0041e5d0 in handle_init (cmd=0x938934, buf=0x9399d4 "\n\n{\"jsonrpc\":\"2.0\",\"id\":\"cln:init#25\",\"method\":\"init\",\"params\":{\"options\":{},\"configuration\":{\"lightning-dir\":\"/home/vincent/.lightning/testnet\",\"rpc-file\":\"lightning-rpc\",\"startup\":true,\"network\":\"te"..., params=0x939c8c)
    at plugins/libplugin.c:1208
\#10 0x0041fc04 in ld_command_handle (plugin=0x93831c, toks=0x939bec) at plugins/libplugin.c:1572
\#11 0x00420050 in ld_read_json_one (plugin=0x93831c) at plugins/libplugin.c:1667
\#12 0x004201bc in ld_read_json (conn=0x9391c4, plugin=0x93831c) at plugins/libplugin.c:1687
\#13 0x004cb82c in next_plan (conn=0x9391c4, plan=0x9391d8) at ccan/ccan/io/io.c:59
\#14 0x004cc67c in do_plan (conn=0x9391c4, plan=0x9391d8, idle_on_epipe=false) at ccan/ccan/io/io.c:407
\#15 0x004cc6dc in io_ready (conn=0x9391c4, pollflags=1) at ccan/ccan/io/io.c:417
\#16 0x004cf8cc in io_loop (timers=0x9383c4, expired=0xbe9e3ce4) at ccan/ccan/io/poll.c:453
\#17 0x00420af4 in plugin_main (argv=0xbe9e3eb4, init=0x41a46c <init>, restartability=PLUGIN_STATIC, init_rpc=true, features=0x0, commands=0x6167e8 <commands>, num_commands=4, notif_subs=0x0, num_notif_subs=0, hook_subs=0x0, num_hook_subs=0, notif_topics=0x0, num_notif_topics=0) at plugins/libplugin.c:1891
\#18 0x0041a6f8 in main (argc=1, argv=0xbe9e3eb4) at plugins/topology.c:679
```

I do not know if this is a solution because I do not know
when I can parse a node announcement for a node that
it is not longer in the gossip map.

So, I hope this is just usefult for @rustyrussell

Changelog-Fixed: fixes `FATAL SIGNAL 11` on gossmap node announcement parsing.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-13 17:51:41 -06:00
Michael Schmoock eea4781606 pytest: allow ipv6 in test_announce_dns_suppressed
The test runs fine on CI but can fail locally on IPv6 systems,
as the address descriptor is just checked agains IPv4.

Changelog-None
2023-02-13 16:33:25 -06:00
Alex Myers 2c7ceb8a21 peer storage: advertise features as optional
Fixes: #6002

Changelog-None
2023-02-14 06:21:44 +10:30
Alex Myers 1800139dbe meta: Add changelog for 23.02rc2
Changelog-None
2023-02-12 07:56:49 -06:00
Michael Schmoock 698eb0408f pytest: adds xfail test that shows datastore issues
When doing some plugin related work, I discovered that the datastore API
has two issues:

- Error messages on startup of plugins init method when the datastore is
  still completely empty: "Parsing '{datastore:[0:': token has no index 0: []"
- Data is escaped but not unwrapped again when sending and getting from
  the API.

[ Removed xfail, it now passes! --RR ]
Closes: #5990
2023-02-11 12:22:40 -06:00
Rusty Russell 9a77a995a8 lightningd: unescape JSON strings for db.
We were feeding in the raw JSON, which escapes \".  Then we were
escaping *again* to return it.

Reported-by: @m-schmook
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `datastore` handles escapes in `string` parameter correctly.
2023-02-11 12:22:40 -06:00
Rusty Russell 15a744be8c commando: don't try putting an integer as the 'string' parameter to "datastore".
This only worked because we handled the JSON raw: next patch prohibits this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-11 12:22:40 -06:00
Rusty Russell 70aee52903 libplugin: don't spew datastore errors to LOG_DEBUG.
People get upset, especially as our "not found" error can be a bit
hard to read!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
See-also: #5990
2023-02-11 12:22:40 -06:00
Vincenzo Palazzo dd9400df99 fix: compilation error on armv7l 32 bit
This fixes the following compilation error
and allow rebuilding again on 32-bit platform.

```
lightningd/dual_open_control.c: In function 'validate_input_unspent':
lightningd/dual_open_control.c:2627:43: error: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
 2627 |                         err = tal_fmt(pv, "PSBT input at index %"PRIu64
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~
 2628 |                                       " missing serial id", i);
      |                                                             ~
      |                                                             |
      |                                                             size_t {aka unsigned int}
ccan/ccan/tal/str/str.h:43:46: note: in definition of macro 'tal_fmt'
   43 |         tal_fmt_(ctx, TAL_LABEL(char, "[]"), __VA_ARGS__)
      |                                              ^~~~~~~~~~~

```

PS: apparently I'm the only remaining people that ran cln on an old raspberry pi 2?

Changelog-None
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-10 16:26:06 -06:00
Alex Myers 822db6acc2 gossipd: don't resurrect deleted half_chans
fixes #5989

Changelog-None
2023-02-10 16:15:30 -06:00
Vincenzo Palazzo a610f28ad4 add a log message when it is not possible upgrade the db
People are upgrading to 22.11.1 not, and in some configurations like the one
mentioned in the issue, we should
put some info information in the log when we are not able to upgrade.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-09 17:40:58 -06:00
Alex Myers b6a7532625 meta: Add changelog for 23.02rc1
Changelog-None
2023-02-08 23:11:42 -06:00
Carl Dong b83a19164c msggen: Regenerate for addition of SendCustomMsg
Performed using:
  PYTHONPATH=contrib/msggen python3 contrib/msggen/msggen/__main__.py
2023-02-08 23:10:53 -06:00
Carl Dong ef51ae3c6d msggen: Enable SendCustomMsg 2023-02-08 23:10:53 -06:00
Rusty Russell 49b3459be5 lightningd: don't put old deprecated `local_msat` and `remote_msat` in listpeerchannels.
These were deprecated in v0.12.0, hence scheduled for removal next version anyway
(use local_fund_msat and remote_funds_msat).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-08 21:17:37 -06:00
Vincenzo Palazzo b7ab80963d ci: include rust tests inside the pre build checks
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-08 16:33:26 -06:00
Vincenzo Palazzo 473c631ceb fix(grpc): add the num_channels field inside the tests
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-08 16:33:26 -06:00
Vincenzo Palazzo ca1fa84458 ignore sql binary plugin
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-08 14:38:58 -06:00
Riccardo Casatta 510abb934c cln-grpc: add roundtrip tests for test_getinfo and test_listppers 2023-02-08 12:03:27 -06:00
Riccardo Casatta 913f9da5a8 cln-rpc: explicitly enumerate ChannelState enum 2023-02-08 12:03:27 -06:00
Riccardo Casatta 21a8342289 Implement GRPC -> JSON conversions also for response types 2023-02-08 12:03:27 -06:00
Riccardo Casatta 9c35f9c13a Implement conversion JSON->GRPC also for requests type
This could be useful for existing software with  a JSON interface that want
to mimic the interface
2023-02-08 12:03:27 -06:00
Rusty Russell a71bd3ea37 options: create enable/disable option for peer storage.
Since it's not spec-final yet (hell, it's not even properly specified
yet!) we need to put it behind an experimental flag.

Unfortunately, we don't have support for doing this in a plugin; a
plugin must present features before parsing options.  So we need to do
it in core.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-08 08:37:59 -06:00
Rusty Russell c60ea5bcbb plugins/chanbackup: make get_file_data take ctx.
When you return an allocated pointer, you should always hand in the
context you want it allocated from.  This is more explicit, because it may
really matter to the caller!

This also folds some simple operations, and avoids doing too much
variable assignment in the declarations themselves: some coding styles
prohibit such initializers, but that's a bit exteme.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-08 08:37:59 -06:00
Rusty Russell 17c35819d8 plugins/chanbackup: neaten a little.
node_id can be on the stack, avoiding a tal call.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-08 08:37:59 -06:00
Rusty Russell f1fed40ac2 features: make name of peer storage features match spec.
And we should always represent them as is, not as optional: it's
possible in future we could *require* "WANT_PEER_BACKUP_STORAGE".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-02-08 08:37:59 -06:00