Commit graph

6434 commits

Author SHA1 Message Date
benthecarman
55da9c434e
Fix potential cases where max_dust_htlc_exposure_msat overflows 2023-11-09 14:51:44 -06:00
Matt Corallo
589a88e749 Fix data_loss_protect test to actually test DLP
The data loss protect test was panicking in a message assertion
which should be passing, but because the test was marked only
`#[should_panic]` it was being treated as a successful outcome.
Instead, we use `catch_unwind` on exactly the line we expect to
panic to ensure we are hitting the right one.
2023-11-09 00:05:23 +00:00
Valentine Wallace
0edd645ba8
Link to LSP spec in accept_underpaying_htlcs config 2023-11-07 15:14:27 -05:00
Valentine Wallace
1926c82b9e
Include counterparty skimmed fees in PaymentClaimed event. 2023-11-07 15:08:55 -05:00
Matt Corallo
6e40e5f18a
Merge pull request #2702 from G8XSU/libFuzzer
Update fuzzing instructions for libFuzzer/cargo-fuzz
2023-11-07 18:16:49 +00:00
Matt Corallo
0503df88c7 Use VecDeque, rather than LinkedList in peer message buffering
When buffering outbound messages for peers, `LinkedList` adds
rather substantial allocation overhead, which we avoid here by
swapping for a `VecDeque`.
2023-11-07 18:13:23 +00:00
Matt Corallo
48edd01d02 Avoid unnecessarily alloc'ing a new buffer when decrypting messages
When decrypting P2P messages, we already have a read buffer that we
read the message into. There's no reason to allocate a new `Vec` to
store the decrypted message when we can just overwrite the read
buffer and call it a day.
2023-11-07 18:13:23 +00:00
Matt Corallo
5e34bc4404 Add an option to in-place decrypt with ChaCha20Poly1305
In the next commit we'll use this to avoid an allocation when
deserializing messages from the wire.
2023-11-07 18:13:23 +00:00
Jeffrey Czyz
1e25979128
Merge pull request #2714 from TheBlueMatt/2023-11-one-less-alloc
Avoid an unnecessary allocation in `TaggedHash`
2023-11-07 07:43:26 -06:00
optout
649129ddab Add Splicing (and Quiescence) wire message definitions 2023-11-07 12:13:58 +01:00
Matt Corallo
1aa5210c2f Avoid an unnecessary allocation in TaggedHash
A well-formed tag is always a constant, so allocating to store it
is unnecessary when we can just make the tag a `&'static str`.
2023-11-07 05:08:16 +00:00
Matt Corallo
96e7d7a258
Merge pull request #2687 from orbitalturtle/signature-data-enum
Expose more granular data in TaggedHash struct
2023-11-07 05:04:48 +00:00
Matt Corallo
2e33acbd9c
Merge pull request #2677 from Evanfeenstra/public-onion-utils
public create_payment_onion in onion_utils
2023-11-07 04:41:03 +00:00
Matt Corallo
e4c6b70e8e Pre-allocate the full Vec prior to serializing as a Vec<u8>
We end up generating a substantial amount of allocations just
doubling `Vec`s when serializing to them, and our
`serialized_length` method is generally rather effecient, so we
just rely on it and allocate correctly up front.
2023-11-07 04:12:30 +00:00
Orbital
caafcedf3f
expose more granular data in TaggedHash struct
Expose tag and merkle root fields in the TaggedHash struct.
2023-11-06 21:36:54 -06:00
Orbital
38dfbf99db
refactor to remove message_digest
We change the Bolt12Invoice struct to carry a tagged hash. Because
message_digest is then only used in one place, we can inline it in
the TaggedHash constructor.
2023-11-06 21:29:50 -06:00
Gursharan Singh
dabe4afad6
Update fuzzing instructions for libFuzzer/cargo-fuzz 2023-11-06 16:28:43 -08:00
Evan Feenstra
0c7b6479b0 export create_onion_message and peel_onion_message from ln::onion_message 2023-11-06 10:42:50 -08:00
Evan Feenstra
c126f0b187 public create_payment_onion in onion_utils 2023-11-06 10:41:35 -08:00
Matt Corallo
50eba2624f
Merge pull request #2699 from mhrheaume/mhr/temporary_channel_id
Added `temporary_channel_id` to `create_channel`.
2023-11-05 05:35:40 +00:00
Matt Corallo
e09afafc43 Avoid unnecessarily overriding serialized_length
...as LLVM will handle it just fine for us, in most cases.
2023-11-04 16:21:29 +00:00
Matt Corallo
1455452177 Pre-allocate send buffer when forwarding gossip
When forwarding gossip, rather than relying on Vec doubling,
pre-allocate the message encoding buffer.
2023-11-04 16:20:51 +00:00
Matt Corallo
abee51b10c Prefer Writeable.encode() over VecWriter use
It does the same thing and its much simpler.
2023-11-04 16:20:24 +00:00
Matt Corallo
c0107c6069 Reduce on-startup heap frag due to network graph map/vec doubling
When we're reading a `NetworkGraph`, we know how many
nodes/channels we are reading, there's no reason not to
pre-allocate the `IndexedMap`'s inner `HashMap` and `Vec`, which we
do here.

This seems to reduce on-startup heap fragmentation with glibc by
something like 100MiB.
2023-11-04 04:00:04 +00:00
Matthew Rheaume
bf395070dd Added temporary_channel_id to create_channel.
By default, LDK will generate the initial temporary channel ID for you.
However, in certain cases, it's desirable to have a temporary channel ID
specified by the caller in case of any pre-negotiation that needs to
happen between peers prior to the channel open message. For example, LND
has a `FundingShim` API that allows for advanced funding flows based on
the temporary channel ID of the channel.

This patch adds support for optionally specifying the temporary channel
ID of the channel through the `create_channel` API.
2023-11-03 17:44:50 -07:00
Matt Corallo
281a0aead7
Merge pull request #2558 from waterson/pr-2554
Handle retrying sign_counterparty_commitment failures
2023-11-02 19:04:05 +00:00
Elias Rohrer
d795e247b7
Merge pull request #2641 from alexanderwiederin/2585-preflight-test-coverage
#2585 Preflight Test Coverage
2023-11-02 09:50:21 +01:00
Chris Waterson
014a336e59 Add basic async signer tests
Adds a `get_signer` method to the context so that a test can get ahold of the
channel signer. Adds a `set_available` method on the `TestChannelSigner` to
allow a test to enable and disable the signer: when disabled some of the
signer's methods will return `Err` which will typically activate the error
handling case. Adds a `set_channel_signer_available` function on the test
`Node` class to make it easy to enable and disable a specific signer.

Adds a new `async_signer_tests` module:

* Check for asynchronous handling of `funding_created` and `funding_signed`.
* Check that we correctly resume processing after awaiting an asynchronous
  signature for a `commitment_signed` event.
* Verify correct handling during peer disconnect.
* Verify correct handling for inbound zero-conf.
2023-11-01 15:24:20 -07:00
Matt Corallo
4278afc9aa Handle retrying sign_counterparty_commitment inb funding failures
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

This commit adds retrying of inbound funding_created signing
failures, regenerating the `FundingSigned` message, attempting to
re-sign, and sending it to our peers if we succeed.
2023-11-01 15:24:20 -07:00
Matt Corallo
8d01309555 Handle retrying sign_counterparty_commitment outb funding failures
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

This commit adds retrying of outbound funding_created signing
failures, regenerating the `FundingCreated` message, attempting to
re-sign, and sending it to our peers if we succeed.
2023-11-01 15:24:20 -07:00
Matt Corallo
f36afcbae3 Handle retrying sign_counterparty_commitment failures
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

This commit adds initial retrying of failures, specifically
regenerating commitment updates, attempting to re-sign the
`CommitmentSigned` message, and sending it to our peers if we
succed.
2023-11-01 15:24:14 -07:00
Matt Corallo
0e3f6b6029 Handle sign_counterparty_commitment failing during inb funding
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

Here we add initial handling of sign_counterparty_commitment
failing during inbound channel funding, setting a flag in
`ChannelContext` which indicates we should retry sending the
`funding_signed` later. We don't yet add any ability to do that
retry.
2023-11-01 14:41:08 -07:00
Matt Corallo
d86f73b8d5 Handle sign_counterparty_commitment failing during outb funding
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

Here we add initial handling of sign_counterparty_commitment
failing during outbound channel funding, setting a new flag in
`ChannelContext` which indicates we should retry sending the
`funding_created` later. We don't yet add any ability to do that
retry.
2023-11-01 14:41:02 -07:00
Matt Corallo
1da29290e7 Handling for sign_counterparty_commitment failing during normal op
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending later, rather than force-closing the
channel (which probably won't even work if the signer is missing).

Here we add initial handling of sign_counterparty_commitment
failing during normal channel operation, setting a new flag in
`ChannelContext` which indicates we should retry sending the
commitment update later. We don't yet add any ability to do that
retry.
2023-11-01 14:29:59 -07:00
valentinewallace
415cbf088e
Merge pull request #2682 from jkczyz/2023-09-bolt12-test-vectors
BOLT 12 Offer test vectors
2023-11-01 14:34:29 -04:00
alexanderwiederin
a38bdbe7bc
add preflight probes test coverage 2023-11-01 19:33:12 +01:00
Matt Corallo
d0f0d9c19f
Merge pull request #2686 from jkczyz/2023-10-onion-message-fuzz
Re-add one-hop onion message fuzzing test
2023-11-01 17:42:29 +00:00
valentinewallace
1f399b0984
Merge pull request #2668 from TheBlueMatt/2023-10-fix-doc
Update docs on `MonitorEvent::HolderForceClosed`
2023-10-30 16:21:36 -04:00
valentinewallace
44e87b86f2
Merge pull request #2693 from Evanfeenstra/next-hop-pubkey-secp-mode
next_hop_pubkey secp Verification only
2023-10-30 12:49:42 -04:00
Matt Corallo
b6f3d0a5fa
Merge pull request #2669 from benthecarman/trace-sync-progress
Remove channel monitor sync in progress log
2023-10-30 16:00:19 +00:00
Matt Corallo
b3e7aac4a7
Merge pull request #2689 from benthecarman/no-std-offer-expire
Add `is_expired_no_std` to Offer
2023-10-29 19:38:26 +00:00
Matt Corallo
8f308f98dd
Merge pull request #2613 from wvanlint/batch_funding_fix_up
Refactor ShutdownResult type and construction
2023-10-29 17:58:56 +00:00
Evan Feenstra
c70961e9ca next_hop_pubkey secp Verification only 2023-10-28 08:11:21 -07:00
benthecarman
5ddd8a7559
Add is_expired_no_std to Offer & Refund
This was available for OfferContents but not an Offer so dependent
projects could not access it.
2023-10-26 20:58:04 -05:00
Jeffrey Czyz
bb1a4f5556
Re-add one-hop onion message fuzzing test
Revert fuzz test removal in 6dc42235ba.
The test originally checked that OnionMessenger would fail for one-hop
blinded paths. The commit added support for such paths, but changing the
checks was not sufficient since the node was not connected to the
introduction node of the reply path. This is required in order to work
with the trivial TestMessageRouter. Fix this by explicitly connecting
the nodes.
2023-10-25 18:13:10 -05:00
Jeffrey Czyz
c0bf030ad2
Wrap long onion_message fuzz strings
Some editors like vim slow to a crawl when scrolling over long strings
when syntax highlighting is turned on. Limit the length in fuzz strings
to avoid this.
2023-10-25 18:12:44 -05:00
Jeffrey Czyz
e469492d95
BOLT 12 test vectors for offer parsing
One discrepancy from the spec still needs to be resolved:

https://github.com/lightning/bolts/pull/798/files#r1334851959
2023-10-24 15:45:35 -05:00
Jeffrey Czyz
452a30e746
Separate and describe BOLT 12 test vectors 2023-10-24 14:19:21 -05:00
Jeffrey Czyz
5fc4abc5cd
Move bech32 parsing tests to the parse module
Additional BOLT 12 tests specific to Offer were added, which will live
in the offer module. Thus, it makes sense to move the bech32 tests to
the parse module.
2023-10-24 13:09:15 -05:00
Matt Corallo
d2242f604d
Merge pull request #2678 from TheBlueMatt/2023-10-0.0.118
Cut 0.0.118
2023-10-24 01:26:30 +00:00