Skip to content

Send ChannelManager messages out-of-band to ensure ordered delivery #217

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

TheBlueMatt
Copy link
Collaborator

This fixes a rather glaring set of race conditions where we generate messages for a given channel in-order but then send them out-of-order due to the two independant message paths we have (events + direct returns). Sadly we give up a bit of effeciency here by handling all messages out-of-band and pushing them into a vec first. That said, the last commit gets to completely remove reentrancy from PeerHandler::read_event, which is super, super nice for client complexity in implementing PeerHandler, so overall I'm quite happy with it.

Based on #213 cause I dont want to rebase it but sadly the fact that a ton of tests had to have a bunch of diff (though should all still be pretty clearly identical in behavior) is gonna cause some pain for other PRs. I'm willing to wait a bit to hit merge for that reason and am happy to rebase as a few other things land, but would ideally like to get this in for 0.0.6 which should be middle/end of this week.

@TheBlueMatt TheBlueMatt force-pushed the 2018-10-msg-resp-overhaul branch 2 times, most recently from f3e5cc6 to 36ae7b8 Compare October 20, 2018 22:53
@TheBlueMatt TheBlueMatt added this to the 0.0.6 milestone Oct 20, 2018
@ariard
Copy link

ariard commented Oct 21, 2018

Well if tests are still identical in behavior it shouldn't be too much a hustle to rebase other current PRs, I mean at least with mines after a really quick skim on diffs. So when ready go ahead and get it merge for 0.0.6. Will review new commits tomorrow.

@ariard
Copy link

ariard commented Oct 21, 2018

With head at b5cbc4e, I hit a crash with the fuzzer, but wasn't able to reproduce it twice (should learn honggfuzz I know will do it soon..)

1 similar comment
@ariard
Copy link

ariard commented Oct 21, 2018

With head at b5cbc4e, I hit a crash with the fuzzer, but wasn't able to reproduce it twice (should learn honggfuzz I know will do it soon..)

yuntai added a commit to yuntai/rust-lightning that referenced this pull request Oct 22, 2018
Add retryable and error_code fields to PaymentFailed event
Add RouteUpdate event ala lightningdevkit#217 containing msgs::HTLCFailChannelUpdate
Move msgs::HTLCFailChannelUpdate from update_fail_htlc's return value to
the payload of RouteUpdate fired inside fail_htlc_backwards_interanl
Some fixes in decode_update_add_htlc_onion
Move procesing onion failure to fail_htlc_backwards_internal
Test for process_onion_failure
@TheBlueMatt
Copy link
Collaborator Author

After discussion, the crash in question was a race in resetting the rng state across threads between the dummy test and the breakage test, this is an independent issue that may have just been exacerbated here, but should be fixed separately (by commenting out the dummy test by default).

@TheBlueMatt TheBlueMatt force-pushed the 2018-10-msg-resp-overhaul branch from 470d9cc to 294ad32 Compare October 27, 2018 13:42
@TheBlueMatt TheBlueMatt merged commit 3609ba5 into lightningdevkit:master Oct 27, 2018
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.

2 participants