-
Notifications
You must be signed in to change notification settings - Fork 2.5k
mempool: check p2wsh standard #2371
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
base: master
Are you sure you want to change the base?
mempool: check p2wsh standard #2371
Conversation
Pull Request Test Coverage Report for Build 15042853022Details
💛 - Coveralls |
mempool/policy.go
Outdated
| } | ||
| // Check the size of each of stack item except witness script. | ||
| for j, wit := range txIn.Witness { | ||
| if len(wit) > maxStandardP2WSHStackItemSize && j != len(txIn.Witness)-1 { |
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.
No need for the j here or the branch checking for j != len(txIn.Witness)-1.
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's to exclude the last element of witness stack, which is witness script.
Core doesn't check the last element either.
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 refactored a bit not to use j by excluding the last element of the range to iterate(the logic is same).
https://github.com/btcsuite/btcd/pull/2371/files#diff-129399aad69c6063744078caac62b466d7db74e07f9fe7a3bd6dc99f00a8f8fbR436
| } | ||
|
|
||
| // checkWitnessStandard follows the core policy. | ||
| // |
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.
Maybe leave a comment that this should be called after the inputs are checked?
Otherwise you'd get a runtime panic here.
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.
|
Verified that the added logic implements just the P2WSH standardness check in Core. It does seem like the original commit is very old. Not quite sure about adding it but am indifferent if it does get added. bitcoin/bitcoin#8499 |
Following core, implements standardness rule of p2wsh. See https://github.com/bitcoin/bitcoin/blob/52ede28a8adb2c2d44d7f800bbfbef8aed86070e/src/policy/policy.cpp#L221
7bf98b6 to
2f0e7b5
Compare
Add missing witness standard validation in mempool. See https://github.com/bitcoin/bitcoin/blob/89c7b6b97ab409d06b435d8b4f36e5e4be36908d/src/validation.cpp#L887
2f0e7b5 to
51cfc78
Compare
FWIW, there're quite a few newer standardness rules that IMO, the only standardness/policy rules that are actually important, are those that directly impact the relay of time-sensitive transactions across the network. One such example is: TRUC and co. |
|
Original PR of
I agree that absence of this doesn't directly impact, but what explained in |
Change Description
AFAIK, btcd curretly doesn't check standard rule for witness unlike bitcoin core. I add method
CheckWitnessStandardto check standard rule forp2wsh, and execute it inside the methodvalidateStandardnessfor mempool validation.Steps to Test
If this PR makes sense, I will add test vectors following the reviews.
Pull Request Checklist
Testing
Code Style and Documentation
📝 Please see our Contribution Guidelines for further guidance.