-
Notifications
You must be signed in to change notification settings - Fork 411
Correct variable names in ChannelMonitor
and DRY tests
#1494
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
Correct variable names in ChannelMonitor
and DRY tests
#1494
Conversation
Several fields used in tracking on-chain HTLC outputs were named `input_idx` despite referring to the output index in the commitment transaction. Here they are all renamed `commitment_tx_output_idx` for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Assigning 108 as #1495 depends on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved with comment
@@ -620,7 +620,7 @@ pub(crate) struct ChannelMonitorImpl<Signer: Sign> { | |||
funding_redeemscript: Script, | |||
channel_value_satoshis: u64, | |||
// first is the idx of the first of the two revocation points | |||
their_cur_revocation_points: Option<(u64, PublicKey, Option<PublicKey>)>, | |||
their_cur_per_commitment_points: Option<(u64, PublicKey, Option<PublicKey>)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like variable names are free, so we could spell out "current" or "latest"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ambiguous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, just marginally easier on the reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, I'm trying to avoid writing out too long variable names so that rustfmt doesn't break things into more lines...unless its critical I'd prefer not to.
@@ -2142,7 +2143,19 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> { | |||
} | |||
let preimage = if htlc.offered { if let Some(p) = self.payment_preimages.get(&htlc.payment_hash) { Some(*p) } else { None } } else { None }; | |||
if preimage.is_some() || !htlc.offered { | |||
let counterparty_htlc_outp = if htlc.offered { PackageSolvingData::CounterpartyOfferedHTLCOutput(CounterpartyOfferedHTLCOutput::build(*revocation_point, self.counterparty_commitment_params.counterparty_delayed_payment_base_key, self.counterparty_commitment_params.counterparty_htlc_base_key, preimage.unwrap(), htlc.clone())) } else { PackageSolvingData::CounterpartyReceivedHTLCOutput(CounterpartyReceivedHTLCOutput::build(*revocation_point, self.counterparty_commitment_params.counterparty_delayed_payment_base_key, self.counterparty_commitment_params.counterparty_htlc_base_key, htlc.clone())) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol how was this ever one line
190a6b9
to
1f69c96
Compare
Codecov Report
@@ Coverage Diff @@
## main #1494 +/- ##
==========================================
- Coverage 90.93% 90.93% -0.01%
==========================================
Files 77 77
Lines 42394 42359 -35
Branches 42394 42359 -35
==========================================
- Hits 38553 38521 -32
+ Misses 3841 3838 -3
Continue to review full report at Codecov.
|
In `HTLCUpdate` and `OnchainEvent` tracking, we store the HTLC value (rounded down to whole satoshis). This is somewhat confusingly referred to as the `onchain_value_satoshis` even though it refers to the commitment transaction output value, not the value available on chain (which may have been reduced by an HTLC-Timeout/HTLC-Success transaction).
The `ChannelMonitor` had a field for the counterparty's `cur_revocation_points`. Somewhat confusingly, this actually stored the counterparty's *per-commitment* points, not the (derived) revocation points. Here we correct this by simply renaming the references as appropriate. Note the update in `channel.rs` makes the variable names align correctly.
1f69c96
to
d443b79
Compare
Squashed without changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-ACKing
While working on #1466, i noticed a few things in
ChannelMonitor
are confusingly- (or mis-)named, plusmonitor_tests.rs
had some obvious DRY'ability. This gets those out of the way so that changes to address #1466 are simpler to read.