Commit Graph

14358 Commits

Author SHA1 Message Date
Rusty Russell f7b7cf3719 gossipd: remove routing.c and other unused functions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell c286241ab3 gossipd: switch over to using gossmap_manage, not routing.c.
The gossip_store_load is now basically a noop, since gossmap
does that.

gossipd removes a pile of routines dealing with messages,
in favor of just handing them to gossmap_manage.

The stub gossmap_manage constructor is removed entirely.

We simplified behaviour around channel_announcements with
no channel update: we now add them to the store, and go
back to fix the timestamp later.  This changes a test,
which explicitly tests for the old behaviour.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 137b80d53e gossipd: make the query response code use gossmap_manage.
This is a bit less optimal than before, where we had an ordered map of
channels and could easily serve "channels between scids 800000x and
900000x".  We now iterate all of them.

The rest is fairly mechanical.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 70811f7ed1 gossipd: make the seeker code use gossmap_manage.
We add a temporary stub gossmap_manage constructor, which simply opens
the gossmap and doesn't do anything else.

Then seeker uses this, rather than routing.c, to probe.

We optimize our "get random node announcements" a bit by traversing a
random set of nodes directly, and seeing if we have no
node_announcement, then querying their first channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 8f768634df gossipd: re-implement flood protection.
If we've got more than 10000 pending channel_announcements,
complain and stop processing any more.

If this becomes a problem, we can limit individual peers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 8f7f76f8c6 gossipd: don't validate UTXOs on our own channels.
It's an unnecessary round-trip, and can cause us to complain in CI, in
the case where the channel has been closed by the time we ask.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell f7ff3613c6 gossipd: interface to have gossmap_manage send updates on init.
At initialization, gossipd is supposed to send all the local
channel_updates and any node_announcement it knows, so lightningd
doesn't generate fresh ones unnecessarily.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 2ae3d25461 gossipd: implement pruning timer inside gossmap_manage.
No external interfaces, we start the timer on allocation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 2964e35699 gossipd: gossmap_manage helper to get a node's address, if any.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 1384d56db3 gossmap_manage: new file for managing the gossip store.
This is a fair amount of code, but much is taken from
the old routing.c, with the difference that this uses
common/gossmap instead of our own structures.

The interfaces are fairly clear:

1. gossmap_manage_new - allocator
2. gossmap_manage_channel_announcement
   - handle new channel announcement msg
   - if too early, keeps it in early map
   - queues it, asks lightingd about UTXO.
3. gossmap_manage_handle_get_txout_reply
   - handle response from lightningd for above.
4. gossmap_manage_channel_update
   - handle channel_update message
   - may have to wait on pending channel_announcement
5. gossmap_manage_node_announcement
   - handle node_announcement msg
   - may have to wait on pending channel_announcement
6. gossmap_manage_new_block
   - see if early announces can now be processed.
7. gossmap_manage_channel_spent
   - lightningd tells us UTXO is spent
   - may prepare channel for closing in 12 blocks.
8. gossmap_manage_channel_dying
   - gossip_store load tells us channel was spent earlier.
   - like gossmap_manage_channel_spent, but maybe < 12.
9. gossmap_manage_get_gossmap
   - gossmap accessor: seeker and queries will need this.
10. gossmap_manage_new_peer
   - a new peer has connected, give them all our gossip.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 104d6a9c78 gossip_store: remove infratructure and bits for marking ratelimited entries.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 07cd4a809b gossipd: remove spam handling.
We weakened this progressively over time, and gossip v1.5 makes spam
impossible by protocol, so we can wait until then.

Removing this code simplifies things a great deal!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Protocol: we no longer ratelimit gossip messages by channel, making our code far simpler.
2024-02-04 09:24:44 +10:30
Rusty Russell e7ceffd565 gossipd: remove zombie handling.
We never enabled it, because we seemed to be eliminating valid
channels.  We discard zombie-marked records on loading.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell af64d30407 gossipd: move gossip_store pointer from struct routing_state to daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 66574882a3 gossipd: simplify seeker startup.
Most nodes don't really care about exact timestamps on gossip filters,
so just keep a flag on whether we have anything in the gossip_store,
and use that to determine whether we ask peers for everything.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell ddc6783cf0 gossipd: move timestamp_reasonable out of routing.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 0388343602 gossipd: move dev flags from routing struct to daemon struct.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 0498695f1f gossipd: have seeker quert interfaces take an id, not a struct peer.
Again, we don't necessarily have a peer pointer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 275d59ead4 gossipd: pass node_id to queue_peer_msg, not peer.
This is easier for future callers, which don't have a convenient peer
structure: in particular, asynchronous processing of gossip for peers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 8cfbc1e7ad gossipd: make gossip_store hold daemon ptr, not rstate.
Makes it easier to wean off routing.c.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 7f5fe52320 gossipd: remove online gossip_store compaction.
It was an obscure dev command, as it never worked reliably.
It would be much easier to re-implement once this is done.

This turned out to reveal a tiny leak on
tests/test_gossip.py::test_gossip_store_load_amount_truncated where we
didn't immedately free chan_ann if it was dangling.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 561859da0c gossipd: move tell_lightningd_peer_update from routing.c into gossipd.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 2d09af8d56 gossipd: take signature checks out of routing.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 652432a298 gossipd: take txout failure cache out of routing.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell ce39309c0c common: optional gossmap callbacks for better failure handling.
In particular, allow callers to see unknown records we ignore (and let
them fail as a result), and get called if we can't pack a
channel_update into our internal format.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell f2cf353431 common: gossmap method to load fd directly, not filename.
And helpers to tell if a node_announcement exists, and get a
full channel_update.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 870c996628 gossipd: new routines to support gossmap compatibility.
gossip_store_del - takes a gossmap-style offset-of-msg not offset-of-hdr.
gossip_store_flag: set an arbitrary flag on a gossip_store hdr.
gossip_store_get_timestamp/gossip_store_set_timestamp: access gossip_store hdr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
Rusty Russell 37ccca5d69 common/gossmap: remove now-unused private flag.
The only way you'll see private channel_updates is if you put them
there yourself with localmods.

I also renamed the confusing gossmap_chan_capacity to gossmap_chan_has_capacity.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-04 09:24:44 +10:30
evansmj 5544911387 Convert fee result into msats 2024-02-02 17:31:23 +01:00
evansmj c90ca104ae Remove update_count from find_account_onchain_fees
update_count is just the count of the records for a tx.  To calculate onchain fees
for an account we must sum all credits vs debits.  We don't need to GROUP BY update_count
nor ORDER BY update_count since it is just a running index of updates to this tx.
2024-02-02 17:31:23 +01:00
evansmj 78ba4138d4 Remove grouping by update_count in finding onchain fees
Remove grouping by update_count which resulted in a crash due to bad arithmetic
caused by fee calculation returned rows not being consolidated.
Remove xfail.
2024-02-02 17:31:23 +01:00
evansmj 3b0cc28d4c Add xfail tests for onchain fees lookup query
Add test for single funded channels.
Add test for dual funded channels.
2024-02-02 17:31:23 +01:00
Lagrang3 9abd5ecf45 regtest: error message if bitcoin-cli is not found
If $BITCOIN_BIN is empty and bitcoin-cli or bitcoind are not found
startup_regtest will shutdown and display a corresponding error message.

Similarly if lightning-cli and lightningd are not found.
2024-02-02 17:25:50 +01:00
Rusty Russell 3c9fd0ca5b pytest: fix another gossip flake.
```
2024-02-02T10:30:38.6479143Z __________________ ERROR at teardown of test_multifunding_one __________________
...
2024-02-02T10:30:38.6491895Z >           raise ValueError(str(errors))
2024-02-02T10:30:38.6492208Z E           ValueError:
2024-02-02T10:30:38.6492465Z E           Node errors:
2024-02-02T10:30:38.6492833Z E            - lightningd-2: had bad gossip messages
2024-02-02T10:30:38.6493535Z E           Global errors:
...
2024-02-02T10:30:38.7458545Z lightningd-2 2024-02-02T10:25:48.410Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-gossipd: Ignoring future channel_announcment for 103x2x1 (current block 102)
2024-02-02T10:30:38.7460140Z lightningd-2 2024-02-02T10:25:48.411Z UNUSUAL lightningd: Bad gossip order: could not find channel 103x2x1 for peer's channel update
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-02 16:14:53 +01:00
Rusty Russell a04fdfbe89 pytest: fix gossip_store load test for EXPERIMENTAL_SPLICING=1
It can change the node_announcement size, so don't check that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-02 16:14:53 +01:00
Rusty Russell 858c084f54 lightningd: fix reference to uninitialized channel_type during opening.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-02-02 16:14:53 +01:00
Lagrang3 59935c535c fixed source (using raw millisatohis) 2024-02-02 11:28:47 +01:00
Lagrang3 997d5aa970 renepay: flow routes limited by htlc_max/min
The flow routes returned by minflow are bounded by the htlc_min and
    htlc_max along the route whenever possible.
2024-02-02 11:28:47 +01:00
Christian Decker 5924509813 rpc: Regenerate derived files after adding bkpr-listincome 2024-02-01 20:00:52 +01:00
Christian Decker 19af808f45 msggen: Add classes for MethodName and TypeName
This is required for types and methods with names that need
post-processing (`bkpr-listincome`).
2024-02-01 20:00:52 +01:00
Harshit933 85b79bc2e1 fix : implements the `bkpr-listincome` plugin for grpc interface.
Changelog-added support for the `bkpr-listincome` for grpc interface

Signed-off-by: harshit933 <harshitverma933@gmail.com>
2024-02-01 20:00:52 +01:00
Christian Decker 6bf97ac259 ci: Split out the fuzz testing
Tacking the fuzz testing onto the PR testing not a good idea. It
causes completely unrelated tests to fail, and doesn't guarantee it
will find newly introduced ones. Running daily is likely better.

Changelog-None No user visible change
2024-02-01 19:46:57 +01:00
Christian Decker f39a43cf14 pyln: Include py.typed file 2024-02-01 17:55:10 +01:00
Matt Morehouse 968d6d6d24 configure: abort on UBSan failure
By default, UBSan reports runtime errors but does not stop execution.
We already abort in debug builds, and this commit makes us also abort in
regular builds when UBSan is enabled. Arguably, this is what users
expect when they enable UBSan, so it is a good default.

I know I've missed some UBSan bugs in the past because of this issue,
and dergoegge mentioned that this also happened to him.
2024-02-01 14:52:39 +10:30
Ken Sedgwick d759f3b758 channeld: use explicit revoke on retry when HSM_VERSION >= 5
Changelog-None: fixes hole in ([#7010]), see ([#7026])

Explicit hsmd_revoke_commitment_tx instead of get_per_commitment_point
needed when revokes are retried. The hsmd_revoke_commitment_tx message
is idempotent.
2024-02-01 14:38:58 +10:30
Erik De Smedt 085960b054 Rename `FeatureBitsPlace` to `FeatureBitsKind` 2024-01-31 21:27:47 +01:00
Erik De Smedt 870e25e180 cln-plugin: Allow user to set featurebits 2024-01-31 21:27:47 +01:00
ok300 a38d81dee0 cln-grpc: Derive serde Serialize/Deserialize for types 2024-01-31 16:44:02 +01:00
Ken Sedgwick 33c838212e tests: augment test_onchain_their_unilateral_out to check to_remote witness generation
Changelog-Added: added a withdraw all to the end of test_onchain_their_unilateral_out to ensure that the unilateral close info is correct with anchors.  Tests https://github.com/Blockstream/greenlight/issues/348
2024-01-31 15:51:31 +01:00
22388o⚡️ c7e5d8049e Update LICENSE 2024-01-31 13:33:30 +01:00