Skip to content

#1199 Followup #1324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

valentinewallace
Copy link
Contributor

Closes #1308.

@codecov-commenter
Copy link

codecov-commenter commented Feb 19, 2022

Codecov Report

Merging #1324 (c743adb) into main (8e7f241) will increase coverage by 0.64%.
The diff coverage is 98.35%.

❗ Current head c743adb differs from pull request most recent head 694ef1e. Consider uploading reports for the commit 694ef1e to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1324      +/-   ##
==========================================
+ Coverage   90.52%   91.17%   +0.64%     
==========================================
  Files          72       72              
  Lines       39560    43078    +3518     
==========================================
+ Hits        35811    39275    +3464     
- Misses       3749     3803      +54     
Impacted Files Coverage Δ
lightning/src/ln/msgs.rs 86.72% <ø> (+0.83%) ⬆️
lightning/src/ln/channelmanager.rs 86.65% <95.23%> (+2.20%) ⬆️
lightning/src/ln/onion_route_tests.rs 97.46% <98.63%> (+0.76%) ⬆️
lightning/src/util/scid_utils.rs 99.17% <100.00%> (+0.79%) ⬆️
lightning/src/lib.rs 100.00% <0.00%> (ø)
lightning/src/ln/functional_tests.rs 97.13% <0.00%> (+0.02%) ⬆️
lightning/src/routing/router.rs 93.07% <0.00%> (+1.14%) ⬆️
lightning/src/ln/channel.rs 92.86% <0.00%> (+3.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e7f241...694ef1e. Read the comment docs.

@jkczyz jkczyz self-requested a review February 21, 2022 15:48
@TheBlueMatt TheBlueMatt added this to the 0.0.105 milestone Feb 21, 2022
@TheBlueMatt
Copy link
Collaborator

Can you add some more tests - eg (a) that don't modify the onion at all, by just editing the route to have incorrect values - too-low CLTV, too low amount, etc (b) that hit blamed_chan_closed(false), (c) that also blame the prev SCID not just the phantom SCID?

@valentinewallace
Copy link
Contributor Author

Can you add some more tests - eg (a) that don't modify the onion at all, by just editing the route to have incorrect values - too-low CLTV, too low amount, etc (b) that hit blamed_chan_closed(false), (c) that also blame the prev SCID not just the phantom SCID?

Thanks, I think I added these but whew each one found a bug basically (one preexisting tbf). So let me know if anything's missing

@TheBlueMatt
Copy link
Collaborator

I'm not quite sure why the test I wrote at https://git.bitcoin.ninja/index.cgi?p=rust-lightning;a=commit;h=1907bcc5d055008eae4e378f2907cba15d719587 is failing - can you examine it a bit and include that test here?

This will be used in upcoming commit(s) to encrypt phantom payment failure packets.
This also fixes a bug where we were failing back phantom payments with the
wrong scid, causing them to never actually be failed backwards (L3022 in
channelmanager.rs)

This new field will be used in upcoming commit(s) to encrypt phantom payment failure
packets.
Ensure we fail back phantom malformed payments with an update_fail_htlc s.t.
the error contains the sha256 of the onion, per LN protocol.
In any place where fail_htlc_backwards_internal was called for a phantom payment
failure, we weren't encoding the onion failure as if the phantom were the one
failing. Instead, we were encoding the failure as if it were coming from the
second-to-last hop. This caused our failures to not be parsed properly on the
payer's side.

Places we were encoding failures incorrectly include:
* on failure of a call to inbound_payment::verify
* on a user call to fail_htlc_backwards

Also drop some unnecessary panics when reading OnionHopData objects. This also
enables one of the phantom failure tests because we can construct OnionHopDatas
with invalid amounts.

Lastly, remove a bogus comment
Failing an HTLC with onion error channel_disabled requires encoding a 'flags' field into the failure
packet. However, we were encoding this 'flags' field for all failures packets that were failing on
update_add_htlc with an update (error 0x1000 UPDATE).

Discovered in the course of adding phantom payment failure tests, which also added testing for this bug
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

.expected_htlc_error_data(0x4000 | 15, &error_data);
expect_payment_failed_conditions!(nodes[0], payment_hash, true, fail_conditions);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: excess \n

@TheBlueMatt TheBlueMatt merged commit 99073c7 into lightningdevkit:main Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix (+test) phantom node onion error returning
4 participants