Repository navigation
Align legacy script policy with P2SH policy in AreInputsStandard - #33926
151henry151 wants to merge 1 commit into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33926. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible places where named args may be used (e.g.
2025-11-27 |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
|
Our change allows NONSTANDARD legacy scripts with acceptable sigop counts to pass AreInputsStandard, which breaks tests that relied on those scripts being rejected. p2p_segwit.py uses a NONSTANDARD script (0 sigops) as self.utxo[0] that now passes instead of being rejected, so transactions that should be rejected are getting accepted. feature_taproot.py has some spenders with NONSTANDARD scripts that are now allowed, so the test's standardness checks don't match the new policy. I'll fix both by updating the tests to match the new policy. |
|
I updated the tests to match the new policy. The NONSTANDARD script in p2p_segwit.py now passes AreInputsStandard since it has zero sigops. For test_segwit_versions, I switched the input from the NONSTANDARD UTXO to the standard UTXOs created earlier, so the transaction now passes all checks and gets accepted. For feature_taproot.py, I adjusted the is_standard flag for the compat/nocsa spender because bare NONSTANDARD scripts with low sigop counts now pass policy checks. Please check this all out and let me know if this looks correct or needs any adjustment. |
a3c7c8c to
5086fdb
Compare
fe4c1e7 to
4d06b1e
Compare
|
The I added a coin validity check in I'm not seeing why transactions accepted by the policy fail the consistency check. Any help diagnosing this would be appreciated. Perhaps you might have some ideas, @roconnor-blockstream ? |
|
My best guess is that making legacy script standard means that randomly generated ScriptPubKeys are now generally mempool acceptable whereas before only very few specifically shaped ScriptPubKeys could be accepted and weren't being generated by the fuzzer. This is exposing some kind of error in the One thing to explore is to see if reverting PR #32822 makes the failure disappear. If so then we maybe narrowed down the problem to the recent changes to this fuzz test. Another angle we might take is that legacy script perhaps ought to require at least one checksig operation, otherwise it is unsecured and, theoretically, eligible as an upgrade mechanism similar to Segwit. This might sweep any potential existing |
a26ee87 to
e06b011
Compare
2f9f211 to
aa0be3d
Compare
maflcko
left a comment
There was a problem hiding this comment.
Please note that contributors are required to fully understand their authored code themselves.
Asking others for review, to feed that into an LLM, does not count as understanding the code.
If they wanted to use an LLM, they could just do so themselves.
Please focus on creating high-quality, original content that demonstrates a clear understanding of the project's requirements and goals. Also, see the contributing guidelines.
b7480d6 to
1dce460
Compare
1dce460 to
7f33352
Compare
|
Closing, to break the bot loop |
|
Sorry about that -- not trying to falsely represent anything here. I thought I had a pretty good start with my changes to policy.cpp, but then I've been struggling with getting the tests working. I know that overuse of LLMs is frowned upon and I realize that accidentally committing and pushing a bunch of MD files with notes generated by an LLM is not a good look, but I'm going to keep trying to figure this out locally and hope to make a valuable contribution here. I also realize that I should have got my code to a point where the tests are passing first before opening the PR so closing it makes sense, sorry. I've been applying myself to this enthusiastically but it's proven to be more difficult than I anticipated, and I have been leveraging every tool available to me to try and get a good result that will be of some use to the project. |
I appreciate the feedback and want to make sure it's clear that I do comprehend the code I've written. The core change applies sigop limits to legacy scripts and fixes CLEANSTACK to only apply to P2SH as specified in BIP62. Most of the diff is test updates—the functional tests were using 0-sigop scripts that fail under the new policy, so they needed to be switched to 1-sigop scripts with proper signing. I've been stuck on a I apologize for the excessive CI usage. I've now set up local testing and will continue debugging there until I have a working solution. |
|
@maflcko I think I've resolved the issue in 151henry151@1c67900568 Witness scripts (P2WSH, P2WPKH, etc.) were incorrectly falling into the legacy script path, so they're now explicitly skipped since they're handled by All tests now pass locally: Could this PR be reopened so we can verify the fixes pass CI? The previous failures were due to missing edge case handling in the policy logic, which has now been addressed. |
Legacy scripts currently require solvability, while P2SH scripts only check sigop count. This asymmetry causes some non-solvable legacy scripts to be rejected even when they have acceptable sigop counts, while equivalent P2SH scripts would be accepted.
This change updates AreInputsStandard to check sigop count for legacy scripts instead of requiring solvability, matching P2SH behavior. Non-solvable legacy scripts with sigop counts within the limit are now accepted, consistent with P2SH.
This implements the approach suggested by roconnor-blockstream in #33882 to address the policy asymmetry between legacy and P2SH script redemption.
The test suite covers boundary conditions (0, 14, 15, and 16 sigops), different sigop types (CHECKSIG and CHECKMULTISIG), multiple inputs, and regression cases to ensure existing behavior for standard and WITNESS_UNKNOWN scripts is preserved.