Skip to content

conctractcourt: check sweep sanity + reliable publication#1936

Merged
Roasbeef merged 4 commits into
lightningnetwork:masterfrom
cfromknecht:cnct-sane-txn-reliable-pub
Oct 25, 2018
Merged

conctractcourt: check sweep sanity + reliable publication#1936
Roasbeef merged 4 commits into
lightningnetwork:masterfrom
cfromknecht:cnct-sane-txn-reliable-pub

Conversation

@cfromknecht
Copy link
Copy Markdown
Contributor

This PR modifies the signing and sweeping of commit to-remote sweeps and htlc success sweeps, such that we validate the generated transaction's sanity before publication. It also ensures that the resolvers checkpoint the transaction before publishing. This ensures that we will watch for the same txid after a restart in case a crash happens between publication and checkpointing. If such a crash happens, both will attempt to publish the sweep transaction again in order to ensure the transaction propagates.

In addition, we return an error if checkpointing fails from a number of places within the contract resovlers, and also ignore errors that can arise from duplicate publications of the same htlc success transaction.

Note: would like to add some unit tests exercising this behavior, though this brings the resolvers in line with the intended behavior of other subsystems performing similar functions.

@Roasbeef Roasbeef added wallet The wallet (lnwallet) which LND uses contracts P2 should be fixed if one has time utxo sweeping labels Sep 21, 2018
@Roasbeef Roasbeef added this to the 0.5.1 milestone Sep 21, 2018
@Roasbeef Roasbeef added the needs review PR needs review by regular contributors label Sep 21, 2018
@joostjager
Copy link
Copy Markdown
Contributor

Looking at this PR again, I realize it partially overlaps with #1978, at least the sanity checking.

@Roasbeef
Copy link
Copy Markdown
Member

Needs rebase!

Comment thread contractcourt/contract_resolvers.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO the control flow is easier to follow if we retain the publishing of the tx in this case, and also the ones that need a tx published.

Comment thread contractcourt/contract_resolvers.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@cfromknecht cfromknecht force-pushed the cnct-sane-txn-reliable-pub branch from 55d4bf2 to f9cec4a Compare October 24, 2018 21:08
Copy link
Copy Markdown
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

LGTM ☑️

// With the sweep transaction constructed, we'll now Checkpoint
// our state.
if err := c.Checkpoint(c); err != nil {
log.Errorf("unable to Checkpoint: %v", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Print resolvertype+channelpoint?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We'll print the chan point in the char arb.

Copy link
Copy Markdown
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🛶

@Roasbeef Roasbeef merged commit 15508df into lightningnetwork:master Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contracts needs review PR needs review by regular contributors P2 should be fixed if one has time utxo sweeping wallet The wallet (lnwallet) which LND uses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants