Commit graph

3049 commits

Author SHA1 Message Date
Matt Corallo
de783e0b95
Merge pull request #1946 from wpaulino/init-features-user-config
Use UserConfig to determine advertised InitFeatures by ChannelManager
2023-01-15 04:00:11 +00:00
Arik Sosman
16deda07aa
Allow manually passing a timestamp to channel_failed. Fixes #1914. 2023-01-14 08:22:50 -08:00
Arik Sosman
e9d4ae1d3e
Add error messages to stale gossip cleanup assertions.
Should help debug #1914.
2023-01-14 07:27:44 -08:00
Wilmer Paulino
abf4e79dcd
Use UserConfig to determine advertised InitFeatures by ChannelManager
This is purely a refactor that does not change the InitFeatures
advertised by a ChannelManager. This allows users to configure which
features should be advertised based on the values of `UserConfig`. While
there aren't any existing features currently leveraging this behavior,
it will be used by the upcoming anchors_zero_fee_htlc_tx feature.

The UserConfig dependency on provided_init_features caused most
callsites of the main test methods responsible for opening channels to
be updated. This commit foregos that completely by no longer requiring
the InitFeatures of each side to be provided to these methods. The
methods already require a reference to each node's ChannelManager to
open the channel, so we use that same reference to obtain their
InitFeatures. A way to override such features was required for some
tests, so a new `override_init_features` config option now exists on
the test harness.
2023-01-13 23:54:51 -08:00
Matt Corallo
ac6e0b3fed
Merge pull request #1930 from arik-so/2022-12-remove-keysinterface
Remove KeysInterface
2023-01-14 04:59:27 +00:00
Elias Rohrer
defa2f6811
Fix misc. warnings from --document-private-items 2023-01-13 18:26:09 -06:00
Elias Rohrer
d325fa7831
Fix docs and export impl_tlv_based_enum variants 2023-01-13 18:03:28 -06:00
Elias Rohrer
d78d06ceba
Fix misc doc warnings. 2023-01-13 18:03:28 -06:00
Elias Rohrer
7eac897746
Fix doc warnings and cleanup in msgs.rs 2023-01-13 18:03:24 -06:00
Elias Rohrer
3bf2f7189c
Fix doc warnings and cleanup in ser.rs 2023-01-13 09:18:47 -06:00
Arik Sosman
49c1f30c8c
Decouple lifetimes for trait implementations that used to comprise KeysInterface. 2023-01-12 16:10:44 -08:00
Arik Sosman
72183bd932
Split up generic parameters that used to comprise KeysInterface. 2023-01-12 16:10:35 -08:00
Arik Sosman
5824e226ca
Remove KeysInterface trait. 2023-01-12 09:18:08 -08:00
Matt Corallo
e8b91a478b
Merge pull request #1823 from mariocynicys/expose-tlv-macros2
Expose `impl_writeable_tlv_based` macro
2023-01-11 21:02:25 +00:00
Matt Corallo
5221e4a861
Merge pull request #1507 from ViktorTigerstrom/2022-05-store-channels-per-peer
Store `channels` per-peer
2023-01-10 19:19:35 +00:00
Matt Corallo
ab46f6b988 Make debug_sync regex more robust
On windows the symbol names appear to sometimes be truncated,
which causes the symbol name to not include the `::new` at the end.
This causes the regex to mis-match and track the wrong location
for the mutex construction, leading to bogus lockorder violations.

For example, in testing the following symbol name appeared on
Windows, without the function name itself:

`lightning::debug_sync::RwLock<std::collections:#️⃣:map::HashMap<lightning::chain::transaction::OutPoint,lightning::chain::chainmonitor::MonitorHolder<lightning::util::enforcing_trait_impls::EnforcingSigner>,std::collections:#️⃣:map::RandomState> >::`
2023-01-10 06:48:04 +00:00
Matt Corallo
230331f3e8 Move tests from debug_sync to a new submodule
This will allow us to change the module regex match in debug_sync
to make it more robust.
2023-01-10 06:48:04 +00:00
Matt Corallo
558bfa3fb3 Move debug_sync to the new sync folder 2023-01-10 06:31:13 +00:00
Matt Corallo
f66f720fa5 Move no-std sync implementations to a folder to clean up 2023-01-10 06:26:46 +00:00
Viktor Tigerström
23fdcca9a4 Remove the ChannelManager::channel_state 2023-01-09 23:50:41 +01:00
Viktor Tigerström
cb952f651f Expect pending_msg_events to be in random peer order in tests 2023-01-09 23:50:41 +01:00
Viktor Tigerström
6cb985390d Store pending_msg_events per peer 2023-01-09 23:50:41 +01:00
Viktor Tigerström
228fbc2f32 Use correct node in test_invalid_upfront_shutdown_script 2023-01-09 23:50:41 +01:00
Viktor Tigerström
1b70a1e973 Avoid unnecessary looping over all peers' channels 2023-01-09 23:50:41 +01:00
Viktor Tigerström
e2c5cb5b8c Update id_to_peer docs with consistency guarantees info 2023-01-09 23:50:41 +01:00
Viktor Tigerström
9e7c02cd12 Remove one tab level when accessing a peer_state 2023-01-09 23:50:41 +01:00
Viktor Tigerström
c42323c857 Remove unnecessary channel counterparty checks 2023-01-09 23:50:41 +01:00
Viktor Tigerström
5578d79bfa Add handle unkown peer test 2023-01-09 23:50:41 +01:00
Viktor Tigerström
8c175f5238 Add duplicate temporary_channel_id for 2 peers test 2023-01-09 23:50:41 +01:00
Viktor Tigerström
0eb74ec007 Unify failure to query Channel error messages 2023-01-09 23:50:41 +01:00
Viktor Tigerström
ff9840ea35 Avoid unnecessary immediate retake per_peer_state lock 2023-01-09 23:50:41 +01:00
Viktor Tigerström
b8ca7c9256 Remove unnecessary per_peer_state branch
After `channels` are now stored in the `per_peer_state`, some logic can
be simplified and extra accessing of the `per_peer_state` can be
removed.
2023-01-09 23:50:41 +01:00
Viktor Tigerström
1ab25a086a Store channels per peer 2023-01-09 23:50:41 +01:00
Omer Yacine
0acd5d3e46
Fix an incorrect assertion in tlv stream encoding
Types must be unique and monotonically increasing (using < instead of <=)
2023-01-09 21:20:23 +02:00
Omer Yacine
3a33693b1e
Expose impl_writeable_tlv_based macro
Every exported macro needed to have all the macros used inside it:
1- to be exported as well.
2- be called from the `$crate` namespace so it works in other crates.

Some structs in `lightning::util::ser` needed to be made public as they were used inside the exported macros.

Use the macros like this:
```Rust
lightning::impl_writeable_tlv_based!(...)
```
2023-01-09 21:16:30 +02:00
Matt Corallo
7165d6d48f Fix panic on receiving channel_ready after 1st commitment update
`cur_counterparty_commitment_transaction_number` starts at
`INITIAL_COMMITMENT_NUMBER`, gets decremented once when the initial
`channel_ready` message is received, and gets decremented a second
time when the first `revoke_and_ack` is received, revoking the
first counterparty commitment point.

At this point, `counterparty_prev_commitment_point` points to the
non-revoked second commitment point.

If we then process a second `channel_ready`, we check the
`cur_counterparty_commitment_transaction_number` number, see that
if is `INITIAL_COMMITMENT_NUMBER - 2` (i.e. not `- 1`) and assume
that the *second* commitment number has been revoked (by
`expect`ing `CounterpartyCommitmentSecrets::get_secret` with
`INITIAL_COMMITMENT_NUMBER - 1`). This `expect` panic's.

As the second commitment point has not yet been revoked, we should
fetch it from `counterparty_prev_commitment_point`, which we do
here, adding a test which failed on the previous code as well.

Found by the `full_stack_target` fuzzer.
2023-01-08 02:02:47 +00:00
Matt Corallo
efc0244ba6 Make the no-std RwLockGuard try_lock actually try
There doesn't appear to be any reason to have `try_lock` fail, and
future work shouldn't need to check for std to use `try_lock`.
2023-01-07 22:43:09 +00:00
Viktor Tigerström
4207eab59d Add try_write function to FairRwLock 2023-01-07 00:52:30 +01:00
Viktor Tigerström
48f9c72eb6 Add ChannelManager::PeerState::latest_features docs 2023-01-07 00:52:29 +01:00
Viktor Tigerström
ce5cc73b4d Add counterparty_node to test macros 2023-01-07 00:52:29 +01:00
valentinewallace
d8a20eda5f
Merge pull request #1927 from jkczyz/2022-12-invoice-rework
Pre-work for BOLT 12 invoices
2023-01-06 11:07:17 -05:00
Jeffrey Czyz
b50fc4e32c
Define blinded hop features for use in BOLT 12
BOLT 12 invoices may contain blinded_payinfo for each hop in a blinded
path. Each blinded_payinfo contains features, whose length must be
encoded since there may be multiple hops.

Note these features are also needed in the BOLT 4 encrypted_data_tlv
stream. But since they are a single TLV record, the length must *not* be
encoded there.
2023-01-05 22:39:24 -06:00
Jeffrey Czyz
d985ced7e3
Define BOLT 12 invoice features with MPP support 2023-01-05 22:39:24 -06:00
Jeffrey Czyz
ea1a68c6e6
Use explicit WithoutLength for BOLT 12 features
Most BOLT 12 features are used as the value of a TLV record and thus
don't use an explicit length. One exception is the features inside the
blinded payinfo subtype since the TLV record contains a list of them.
However, these features are also used in the BOLT 4 encrypted_data_tlv
TLV stream as a single record, where the length is implicit.

Implement Readable and Writeable for Features wrapped in WithoutLength
such that either serialization can be used where required.
2023-01-05 22:39:24 -06:00
Jeffrey Czyz
1a437f4150
Remove Option from InvoiceRequest::signature
Refunds don't have signatures and now use their own abstraction.
Therefore, signatures can be required in invoice requests as per the
spec.
2023-01-05 22:39:24 -06:00
Jeffrey Czyz
7964b9f745
Correct documentation about Refund::payer_id
The docs incorrectly stated that Refund::payer_id is for signing, where
it is only used for identifying a node if Refund::paths is not present.
2023-01-05 22:38:31 -06:00
Matt Corallo
b79ff71fe7
Merge pull request #1812 from valentinewallace/2022-10-chanman-router-param
Parameterize `ChannelManager` by a `Router`
2023-01-05 22:09:35 +00:00
Valentine Wallace
19516c041e
Test utils: allow queueing >2 persistence update results 2023-01-05 11:29:24 -05:00
Valentine Wallace
22501c3c5e
ser_macros: rename check_tlv_order
.. to disamgibutate from check_encoded_tlv_order
2023-01-05 11:29:24 -05:00
Matt Corallo
af6fa143a1
Provide a static_value TLV field serialization type
This is useful in the type serialization definition macros to avoid
writing or reading a field at all, simply using a static value on
each reload.
2023-01-05 11:29:21 -05:00