Skip to content

Fix simple to_local revoked output claim and rebase #184 - #199

Merged
TheBlueMatt merged 4 commits into
lightningdevkit:masterfrom
TheBlueMatt:2018-09-184-fixed-monitor
Sep 30, 2018
Merged

TheBlueMatt merged 4 commits into
lightningdevkit:masterfrom
TheBlueMatt:2018-09-184-fixed-monitor

Conversation

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

In review of #184 the tests looked funky and it turned out we were incorrectly claiming revoked to_local outputs. FIrst commit fixes it, then follows a rebase of #184 with the fixes required separated out so its easier to review the differences (I'll squash them before merge).

Comment thread src/ln/channelmanager.rs
assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_5.3.txid());
assert_eq!(revoked_local_txn[0].output.len(), 2); // Only HTLC and output back to 0 are present
assert_eq!(revoked_local_txn[1].input.len(), 1);
assert_eq!(revoked_local_txn[1].input[0].previous_output.txid, revoked_local_txn[0].txid());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Check that it's a HTLC-Timeout with assert_eq!(..witness.len(), 5) and (..witness[5].len(), 133) ?

Comment thread src/ln/channelmanager.rs
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1);
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
assert_eq!(node_txn.len(), 3); // nodes[1] will broadcast justice tx twice, and its own local state once

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

side-thought: Aren't duplicate (or more) tx generation due to block re-scan not gonna be a bottleneck for watchtowers ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I suppose it might, though hopefully watchtowers aren't broadcasting that many transactions to begin with as people would have to be misbehaving for that.

Comment thread src/ln/channelmanager.rs
let revoked_local_txn = nodes[0].node.channel_state.lock().unwrap().by_id.get(&chan_1.2).unwrap().last_local_commitment_txn.clone();
assert_eq!(revoked_local_txn.len(), 2); // commitment tx + 1 HTLC-Timeout tx
assert_eq!(revoked_local_txn[0].input.len(), 1);
assert_eq!(revoked_local_txn[0].input[0].previous_output.txid, chan_1.3.txid());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same as above, maybe ensure that the witnessScript is an offered htlc one?

@ariard

ariard commented Sep 30, 2018

Copy link
Copy Markdown

utACK, fix + test of revoked to_local output is something less to be done in #137 !

@TheBlueMatt
TheBlueMatt force-pushed the 2018-09-184-fixed-monitor branch from a2aabf6 to af29adc Compare September 30, 2018 00:28
@TheBlueMatt

Copy link
Copy Markdown
Collaborator Author

Ok, fixed the comments, squashed and macro'd the tx.verify() map stuff (adding one more such test for local txn spending each other).

@ariard

ariard commented Sep 30, 2018

Copy link
Copy Markdown

Good, thanks for the macro, will use it for next tests!

@TheBlueMatt
TheBlueMatt merged commit 6c1123c into lightningdevkit:master Sep 30, 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