Skip to content
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

Fix sidecar message handlers #341

Merged
merged 3 commits into from
Mar 7, 2022
Merged

Conversation

positiveblue
Copy link
Contributor

@positiveblue positiveblue commented Feb 18, 2022

The first commit cleans up the shims whenever we reject a batch.
The second commit populates the OrderMatchReject msg properly.

@positiveblue positiveblue requested a review from guggero February 18, 2022 08:55
@positiveblue positiveblue force-pushed the fix-sidecar-message-handlers branch from d0c07e0 to 8f04e75 Compare February 18, 2022 09:05
Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Great fixes and nice find! A couple of comments about error wrapping. But I'm pretty confident you found the underlying cause for the problem Voltage described.

I think we should add a server side integration test for this specific case, pulling in the version of this PR to verify.

@@ -617,8 +595,7 @@ func (a *SidecarAcceptor) matchPrepare(pendingBatch *order.Batch,
// that's being used to pay for the sidecar channel.
err = a.cfg.FundingManager.PrepChannelFunding(batch, a.getSidecarAsOrder)
if err != nil {
return nil, fmt.Errorf("error preparing channel funding: %v",
err)
return fmt.Errorf("error preparing channel funding: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

We need to wrap this error, otherwise the errors.As(failure, &partialReject): below won't trigger.

sidecar_acceptor.go Show resolved Hide resolved
sidecar_acceptor.go Show resolved Hide resolved
sidecar_acceptor.go Show resolved Hide resolved
@positiveblue positiveblue force-pushed the fix-sidecar-message-handlers branch 3 times, most recently from a51e447 to db55432 Compare February 24, 2022 21:06
@lightninglabs-deploy
Copy link
Collaborator

@positiveblue, remember to re-request review from reviewers when ready

sidecar_acceptor.go Show resolved Hide resolved
}

// We know we're involved in a batch, so let's store it for the
// next step.
a.pendingBatch = newBatch
Copy link
Member

Choose a reason for hiding this comment

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

Why do we no longer store the batch here? We'll need to remove it if the execution fails for w/e reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we do, but all the logic is inside the a.matchPrepare, a.matchSign and a.matchFinalize

return nil, fmt.Errorf("unable to cleanup previous "+
"batch: %v", err)
if a.pendingBatch != nil {
if err := a.removeShims(a.pendingBatch); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

So this is part of the core fix here? That we wipe the batch after we remove the shim?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the fix was merged in another PR (already in master). Usually we want to remove the shims of the previous batch, but it was possible to end up in a state were there was not previous batch stored and some shims were created

return batch, nil
// We know we're involved in a batch, so let's store it for the
// next step.
a.pendingBatch = batch
Copy link
Member

Choose a reason for hiding this comment

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

Ok I see we only store it now once all the other operations succeed...


// Assert we're in the correct state to receive a sign message.
if !a.isPending(msg.BatchId) {
return fmt.Errorf("pending batchID was: %x got: %x",
Copy link
Member

Choose a reason for hiding this comment

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

Seems this would indicate a logic error elsewhere if we see it frequently in practice, or even a bug in the server's execution logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, it should not be the normal flow. I have never seen it in our logs, but the code was already there and I think it does not hurt us to keep it. (I hope we end up in this state though*)

sidecar_acceptor.go Show resolved Hide resolved
@positiveblue positiveblue force-pushed the fix-sidecar-message-handlers branch from db55432 to c06ee37 Compare March 4, 2022 20:24
@positiveblue positiveblue force-pushed the fix-sidecar-message-handlers branch from c06ee37 to cb86b2c Compare March 4, 2022 20:28
@positiveblue positiveblue marked this pull request as ready for review March 4, 2022 21:12
@positiveblue positiveblue requested review from Roasbeef and guggero March 4, 2022 21:12
@kornpow
Copy link

kornpow commented Mar 4, 2022

Running this branch on my machine.
Registered a sidecar ticket, and I got the connection error that I had seemed to get stuck on before for my first batch, but then when the second batch rolled around I got matched to somebody else and it worked!

I am hopeful that this fixes it!

Copy link
Member

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Excited to hear that this seems to fix your issues, @kornpow!
LGTM 🎉

@kornpow
Copy link

kornpow commented Mar 7, 2022

But I am also hopeful that your backend fixes also contribute to better reliability even without upgrading devices to the PR

@guggero guggero merged commit a35ceca into master Mar 7, 2022
@guggero guggero deleted the fix-sidecar-message-handlers branch March 7, 2022 18:24
positiveblue pushed a commit to positiveblue/pool that referenced this pull request Oct 11, 2022
rpc: parse unknown order type as peer dependent
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.

5 participants