-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[input/size] Check tx size constants #4775
[input/size] Check tx size constants #4775
Conversation
c1544d2
to
5febf58
Compare
Moving to v0.13, will cherry pick what is needed for sweeper changes. |
ccb8d5a
to
6121926
Compare
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.
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
// - OP_CSV: 1 byte // HTLC script types. The size won't be correct in all cases, | ||
// - OP_DROP: 1 byte // but it is just an upper bound used for fee estimation in any case. | ||
// - OP_1: 1 byte // These 3 extra bytes are only | ||
// - OP_CSV: 1 byte // present for the for the |
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.
Just a typo: uses two times "for the for the"
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.
Fixed! 👍
input/size.go
Outdated
// - OP_CSV: 1 byte | ||
// - OP_DROP: 1 byte | ||
// - OP_1: 1 byte // These 3 extra bytes are only | ||
// - OP_CSV: 1 byte // present for the for the |
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.
Just a typo: uses two times "for the for the"
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.
Fixed! 👍
32f9bd4
to
6dd5bfe
Compare
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 🌸
// | ||
// TODO(halseth): the non-confirmed version currently includes the | ||
// overhead. | ||
AcceptedHtlcScriptSizeConfirmed = AcceptedHtlcScriptSize // + HtlcConfirmedScriptOverhead |
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.
Why was this commented out in the past again?
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.
Ah nvm, I see the TODO now
@@ -115,6 +115,7 @@ const ( | |||
// - Sequence: 4 bytes | |||
InputSize = 32 + 4 + 1 + 4 | |||
|
|||
// FundingInputSize 41 bytes |
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.
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?
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.
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
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.
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
} | ||
|
||
// TestWitnessSizes asserts the correctness of our magic tx size constants. | ||
func TestTxSizes(t *testing.T) { |
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.
👍
Scratch my other comment re extending the tests.
3720f15
to
fc104fd
Compare
@@ -115,6 +115,7 @@ const ( | |||
// - Sequence: 4 bytes | |||
InputSize = 32 + 4 + 1 + 4 | |||
|
|||
// FundingInputSize 41 bytes |
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.
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
fc104fd
to
9f3d7d8
Compare
What's needed to move this forward? |
Travis 🤪 |
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.
9f3d7d8
to
d30aae4
Compare
@halseth looks fine to me? Have you review comments been addressed @cfromknecht ? |
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 🏅
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.