Skip to content

Conversation

@ismaelsadeeq
Copy link
Member

This PR is another attempt at #13525.

Transactions that fail PreChecks Validation due to non-standard inputs now returns invalid validation stateTxValidationResult::TX_INPUTS_NOT_STANDARD along with a debug error message.

Previously, the debug error message for non-standard inputs do not specify why the inputs were considered non-standard.
Instead, the same error string, bad-txns-nonstandard-inputs, used for all types of non-standard input scriptSigs.

This PR updates the AreInputsStandard to include the reason why inputs are non-standard in the debug message.
This improves the Precheck debug message to be more descriptive.

Furthermore, I have addressed all remaining comments from #13525 in this PR.

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 12, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/29060.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK sedited
Concept ACK stickies-v
Stale ACK sipa

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34124 (refactor: make CCoinsView a purely virtual abstract base class by l0rinc)
  • #33645 (refactor: optimize: avoid allocations in script & policy verification by Raimo33)
  • #32317 (kernel: Separate UTXO set access from validation functions by sedited)

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 for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • AddCoins(coins, CTransaction(txFrom), 0) in src/test/script_p2sh_tests.cpp
  • AddCoins(coins, CTransaction(tx_create), 0, false) in src/test/transaction_tests.cpp
  • AddCoins(coins, CTransaction(tx_create_p2pk), 0, false) in src/test/transaction_tests.cpp
  • AddCoins(coins, CTransaction(tx_create_segwit), 0, false) in src/test/transaction_tests.cpp

If you want, I can propose the exact comment-style annotations to make these third/fourth literal arguments clearer (e.g., /height=/0, /coinbase=/false).

2025-12-30

@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 3fc397a to 6ffb956 Compare December 12, 2023 13:48
Copy link
Contributor

@stickies-v stickies-v left a comment

Choose a reason for hiding this comment

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

Concept ACK

@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 6ffb956 to e032462 Compare December 14, 2023 11:43
@ismaelsadeeq
Copy link
Member Author

Thank you for review @stickies-v

I Addressed your comments and taken suggestions.
Force pushed from 6ffb956 to e032462 , Compare diff

@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from e032462 to 814571b Compare December 18, 2023 14:53
@ismaelsadeeq
Copy link
Member Author

ismaelsadeeq commented Dec 18, 2023

Thanks for reviewing @luke-jr
Force pushed from e032462 to 0a39b07

Compare diff

The changes in latest push are:

  • Rebased on master to fix CI
  • Updated the non-standardness reason to address @luke-jr comments
  • bad-txns-input-script-nonstandard --> bad-txns-input-script-unknown
  • bad-txns-input-scriptsig-failure --> bad-txns-input-p2sh-scriptsig-malformed
  • bad-txns-input-p2sh-no-redeemscript --> bad-txns-input-scriptcheck-missing
  • bad-txns-input-scriptcheck-sigops --> bad-txns-input-p2sh-redeemscript-sigops

@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 814571b to 0a39b07 Compare December 18, 2023 15:46
@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch 2 times, most recently from d9e71f0 to 5ef3f9b Compare December 24, 2023 14:41
@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 5ef3f9b to f4c1945 Compare January 25, 2024 23:05
@ismaelsadeeq
Copy link
Member Author

Rebased on master for green CI.

@achow101 achow101 requested review from glozow and luke-jr April 9, 2024 15:37
@ismaelsadeeq ismaelsadeeq requested a review from stickies-v April 24, 2024 14:30
@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from f4c1945 to 101a308 Compare May 17, 2024 08:00
@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 101a308 to 3ef7ac6 Compare September 14, 2024 11:51
Copy link
Contributor

@sedited sedited left a comment

Choose a reason for hiding this comment

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

Concept ACK

There are also some drahtbot llm linter suggestions.

@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 85c6c97 to db5c7ed Compare October 13, 2025 12:19
@sipa
Copy link
Member

sipa commented Oct 14, 2025

Concept ACK on more descriptive error messages.

However, I'm not convinced about changing the error code string from "bad-txns-nonstandard-inputs" to be more granular. My thinking is that the error code is for software to make automated decisions based on, and the more detailed message is for humans to help debugging. In this case, it seems to me just changing the debugging suffices, or do we expect applications to deal differently with different forms of non-standardness.

Somewhat related question: are there places where only the error code is reported, and not the more detailed message?

@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from db5c7ed to 9eea72d Compare October 14, 2025 16:59
@ismaelsadeeq
Copy link
Member Author

ismaelsadeeq commented Oct 14, 2025

Forced push from db5c7ed388a8eb72247dff015bbf47654f27faf1 to 9eea72d3f3647197c24329b412c7fc71895e3ea2 Compare diff 4f27faf1..9eea72d

I addressed @sipa recent #29060 (comment) by maintained the error code "bad-txns-nonstandard-inputs" and add the additional information in the debug message.

Somewhat related question: are there places where only the error code is reported, and not the more detailed message?

After a grep of GetRejectReason It seems the trace point only reports the reject reason in AcceptToMemoryPool.

@ismaelsadeeq ismaelsadeeq changed the title Policy: Report reason inputs are non standard Policy: Report debug message why inputs are non standard Oct 14, 2025
Copy link
Member

@sipa sipa left a comment

Choose a reason for hiding this comment

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

utACK 9eea72d3f3647197c24329b412c7fc71895e3ea2

Copy link
Contributor

@sedited sedited left a comment

Choose a reason for hiding this comment

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

ACK 9eea72d3f3647197c24329b412c7fc71895e3ea2

@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch 2 times, most recently from 1eb0b09 to 32a5a84 Compare November 28, 2025 13:09
@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 32a5a84 to 65d45ac Compare November 28, 2025 13:13
@ismaelsadeeq
Copy link
Member Author

ismaelsadeeq commented Nov 28, 2025

Forced push from 9eea72d3f3647197c24329b412c7fc71895e3ea2 to 65d45ac 9eea72d3f3...65d45acf283

ismaelsadeeq and others added 3 commits December 30, 2025 13:24
This commit renames AreInputsStandard to ValidateInputsStandardness.

ValidateInputsStandardness now returns valid TxValidationState if all inputs
(scriptSigs) use only standard transaction forms else returns invalid
TxValidationState which states why an input is not standard.
…ring

- Test the various input scriptSig non standardness, and ensure ValidateInputsStandardness
  Returns the reason why the input is nonstandard.

Co-authored-by: Ben Woosley <ben.woosley@gmail.com>
@ismaelsadeeq ismaelsadeeq force-pushed the 11-2023-non-standard-inputs-error-messages branch from 65d45ac to b4db7f3 Compare December 30, 2025 13:41
Copy link
Contributor

@sedited sedited left a comment

Choose a reason for hiding this comment

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

Re-ACK b4db7f3

@DrahtBot DrahtBot requested a review from sipa December 30, 2025 16:12
@ismaelsadeeq ismaelsadeeq requested a review from maflcko January 8, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants