Commit graph

2709 commits

Author SHA1 Message Date
Matt Corallo
437fa4f807
Merge pull request #1959 from danielgranhao/stop-passing-init-features-in-msg-handlers
Stop passing `InitFeatures` in msg handlers
2023-01-17 01:26:31 +00:00
Daniel Granhão
bcf174034a
Stop passing InitFeatures in msg handlers 2023-01-16 21:18:53 +00:00
Matt Corallo
bae81bafca Swap per_peer_state lock order 2023-01-15 23:53:21 +00:00
Matt Corallo
7e23afe1dc Pass monitor updates by reference, not owned
In the next commit(s) we'll start holding `ChannelMonitorUpdate`s
that are being persisted in `Channel`s until they're done
persisting. In order to do that, switch to applying the updates by
reference instead of value.
2023-01-15 23:53:21 +00:00
Matt Corallo
f9bafa6d0e Use ChannelUnavailable for a peer disconnecting not MisuseError
This fixes a crash in the `full_stack_target` fuzz test (found by
Chaincode's generous fuzzing infrastructure!) but ultimately is a
better error code - a peer disconnecting before we can fund a
channel isn't a "misuse error" its an unavailable channel.
2023-01-15 23:38:24 +00:00
Matt Corallo
11524884cb Do not rely on auto-deref'ing when aaccessing a Hash{Map,Set}
In newer versions of `hashbrown` this code would be broken. While
we aren't updating `hashbrown` any time soon (as it requires an
MSRV bump), it is useful to swap for a newer `hashbrown` when
fuzzing, which this makes easier.
2023-01-15 23:32:08 +00:00
Matt Corallo
b75a558a1d Convert Vec de/serialization impl to a macro and impl for tuples
...to make it easier to add new implementations and implement it
for all tuples which implement `Readabe` + `Writeable`. Note that
we don't want to just convert to a blanket implementation as we'd
really like to keep our optimized `Vec<u8>` wrapper or we'll end
up spinning way too much when writing vecs of bytes.
2023-01-15 20:30:12 +00:00
Matt Corallo
a03db3ca30 Add support for including ignorable types in enum de/ser macros
An enum implements de/serialization via
`impl_writeable_tlv_based_enum_upgradable` currently cannot contain
an object that only implements `MaybeReadable`.

This solves that by implementing the required blocks for
`ignorable`, opting to return `Ok(None)` in the top-level read in
cases where the inner field read returns `Ok(None)`.
2023-01-15 20:28:42 +00:00
Matt Corallo
7fd9b33c09 Implement (de)serialization for BTreeMap same as HashMap 2023-01-15 20:28:19 +00:00
Matt Corallo
8ecd71777c Fix link text in reply_short_channel_ids_end 2023-01-15 07:03:55 +00:00
Matt Corallo
ce6bcf68a1
Merge pull request #1950 from tnull/2023-01-fix-doc-warnings-and-nits
Fix doc warnings and doc cleanup in `msgs.rs`/`ser.rs`
2023-01-15 07:03:14 +00:00
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
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