Skip to content

[input/size] Check tx size constants#4775

Merged
cfromknecht merged 4 commits intolightningnetwork:masterfrom
halseth:input-tx-size-constants
Mar 10, 2021
Merged

[input/size] Check tx size constants#4775
cfromknecht merged 4 commits intolightningnetwork:masterfrom
halseth:input-tx-size-constants

Conversation

@halseth
Copy link
Contributor

@halseth halseth commented Nov 17, 2020

We ensure the size constants and their godoc checks out.

See lightning/bolts#815 for a disagreement with the spec that was found in the process.

@halseth halseth requested a review from cfromknecht November 17, 2020 14:38
@halseth halseth requested a review from Roasbeef as a code owner November 17, 2020 14:38
@halseth halseth force-pushed the input-tx-size-constants branch from c1544d2 to 5febf58 Compare November 17, 2020 14:45
@halseth halseth modified the milestones: 0.12.0, 0.13.0 Nov 17, 2020
@halseth
Copy link
Contributor Author

halseth commented Nov 18, 2020

Moving to v0.13, will cherry pick what is needed for sweeper changes.

@halseth halseth force-pushed the input-tx-size-constants branch 3 times, most recently from ccb8d5a to 6121926 Compare November 18, 2020 11:48
Copy link
Contributor

@bjarnemagnussen bjarnemagnussen left a comment

Choose a reason for hiding this comment

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

Although not touched in this PR I fell over the size description for BaseCommitmentTxSize in line 158, which says "125 + 43 * num-htlc-outputs bytes". Maybe the description should be changed to "125 bytes", and instead the "43 * num-htlc-outputs" explained in a line beneath it, as it is not part of the size calculation for BaseCommitmentTxSize?

Similarly for BaseAnchorCommitmentTxSize in line 179

input/size.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a typo: uses two times "for the for the"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed! 👍

input/size.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a typo: uses two times "for the for the"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed! 👍

@Roasbeef Roasbeef added bug fix fees Related to the fees paid for transactions (both LN and funding/commitment transactions) P1 MUST be fixed or reviewed labels Jan 28, 2021
@halseth halseth force-pushed the input-tx-size-constants branch 4 times, most recently from 32f9bd4 to 6dd5bfe Compare February 1, 2021 13:21
Copy link
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 🌸

input/size.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Why was this commented out in the past again?

Copy link
Member

Choose a reason for hiding this comment

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

Ah nvm, I see the TODO now

input/size.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Where's the script that was run? Should we consider adding it to the repo, or instead extending our tests to craft the actual transaction to compare to the estimate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a pretty rough script I wrote, not sure if worth adding it since we shouldn't be changing these very often.

Posting for reference: halseth@d86684c

Copy link
Contributor

Choose a reason for hiding this comment

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

my vote would be to add the script and have it generate a test suite that verifies the actual size. we can fail the build if the tests are not properly committed in git or fail the size checks. I'd be okay with making that a follow up as well

Copy link
Member

Choose a reason for hiding this comment

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

👍

Scratch my other comment re extending the tests.

@Roasbeef Roasbeef requested review from cfromknecht and removed request for cfromknecht February 9, 2021 03:31
@halseth halseth force-pushed the input-tx-size-constants branch 2 times, most recently from 3720f15 to fc104fd Compare February 11, 2021 14:16
input/size.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

my vote would be to add the script and have it generate a test suite that verifies the actual size. we can fail the build if the tests are not properly committed in git or fail the size checks. I'd be okay with making that a follow up as well

@halseth halseth force-pushed the input-tx-size-constants branch from fc104fd to 9f3d7d8 Compare February 25, 2021 11:45
@halseth halseth requested a review from cfromknecht February 25, 2021 11:45
@Roasbeef
Copy link
Member

Roasbeef commented Mar 5, 2021

What's needed to move this forward?

@halseth
Copy link
Contributor Author

halseth commented Mar 5, 2021

What's needed to move this forward?

Travis 🤪

halseth added 4 commits March 5, 2021 10:58
This to more easily track mismatches if constants and get more accurate
fee estimates for the two channel types.

The non-anchor weight estimates will now be smaller, this is okay since
these constants are only being used for fee estimation (and will now be
more accurate).
We run a script that ensures the constant sizes listed is actually the
value of the constant.
Similar to what we do for witnesses, check that the HTLC weight
constants check out.

They actually do not, since the spec is off by one. We ensure we agree
with the spec.
@halseth halseth force-pushed the input-tx-size-constants branch from 9f3d7d8 to d30aae4 Compare March 5, 2021 09:58
@Roasbeef
Copy link
Member

@halseth looks fine to me?

Have you review comments been addressed @cfromknecht ?

Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 🏅

@cfromknecht cfromknecht merged commit 7e33548 into lightningnetwork:master Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix fees Related to the fees paid for transactions (both LN and funding/commitment transactions) P1 MUST be fixed or reviewed v0.13

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants