mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 15:08:38 +00:00
bitcoin-util: Add evalscript subcommand #35788
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35788
Loading…
Reference in a new issue
No description provided.
Delete branch "202607-evalscript"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds an
evalscriptsubcommand for using bitcoin's consensus logic to evaluate script fragments. Intended for debugging and development.Examples:
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
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:
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.
Previously included in bitcoin-inquisition (https://github.com/bitcoin-inquisition/bitcoin/pull/58, also https://github.com/bitcoin-inquisition/bitcoin/pull/64 and https://github.com/bitcoin-inquisition/bitcoin/pull/79).
Makes minimal changes to consensus logic, but still has to duplicate a bunch of code to get equivalent behaviour, might be worthwhile simplifying that API in followups, and potentially exposing as a kernel API of some sort?
tACK
a64f2ac5b1Ran tool_utils, the script unit tests and feature_taproot on the head, and both examples from the description reproduce here.
The PR description mentions
-tx, but I noticed no case in bitcoin-util-test.json uses-tx, so that path goes uncovered. To confirm, I disabled the-inputrange check and the suite still passes. Would it be worth adding a case like that?4 additional verified findings in the Review report.
Earlier concerns neither republished nor resolved: 1 minor finding. See the Run archive linked from the Review report for their assessments.
🟠 Minor ·
evalscriptomits the annex length prefixWith
-tx -sigversion=tapscript,evalscriptreconstructs the wrong signature message for annex-bearing inputs and can reject otherwise-valid Schnorr signatures; annexes are non-standard for relay.Location:
src/bitcoin-util.cpp:384(head).🟠 Minor · Negative
-spentoutputamounts can abortevalscriptA user-supplied negative prevout amount can make a
witness_v0signature check abortbitcoin-utilinstead of reporting a normal argument error.Location:
src/bitcoin-util.cpp:373(head).🟠 Minor · Detached tapscript budget omits the minimum control-block weight
The hidden, approximate tapscript allowance omits at least 34 serialized control-block bytes, so near-budget fragments can fail even when a real spend with the same stack and script has sufficient validation weight.
Location:
src/bitcoin-util.cpp:409(head).🔵 Suggestion · Hex autodetection changes valid ASM inputs
evalscript 10executes raw byte0x10instead ofOP_10, and adding whitespace changes which parser handles that same ASM token.Location:
src/bitcoin-util.cpp:307(head).🔵 Suggestion · Real-checker fixtures cover only
basesighashingBoth real-checker fixtures select
base, so neither prevout-amount wiring nor tapscript annex and tapleaf reconstruction is tested.Location:
test/functional/data/util/bitcoin-util-test.json:903(head).🔵 Suggestion · Dummy-mode fixtures do not distinguish execution rules
The tapscript, custom-flags and empty-stack fixtures cannot detect incorrect interpreter forwarding or rejection of only empty witness stacks instead of all non-singleton stacks.
Location:
test/functional/data/util/bitcoin-util-test.json:855(head).Review coverage was incomplete.
Reviewed:
f0acf4ed7e81· Review report · Previous reportspermalink
🐙 This pull request conflicts with the target branch and needs rebase.
Rebased, added a test that uses
-txTested
598427fd07.I ran the 1214 rows of script_tests.json that evalscript can express, each as a chain of calls (scriptSig, then scriptPubKey, then the redeem or witness script) with -tx and -spentoutput. All 1214 gave the expected result, and so did the 5 tapscript rows. The other 18 rows fail in checks that VerifyScript makes outside EvalScript.
I also ran 10,000 random scripts under each sigversion with NONE, MANDATORY and STANDARD flags, 90,000 runs, and compared them with btclib's interpreter. Success and error matched on all but 246 runs. In those, both sides failed with different error codes, and all come from three btclib bugs. evalscript never crashed.
One trap: a script argument that is valid hex is read as raw bytes.
evalscript 16runs the byte 0x16 and fails with "Opcode missing or not understood", whileevalscript '16 'runs OP_16. Could the help say so, or raw hex need a0xprefix?🐙 This pull request conflicts with the target branch and needs rebase.
🚧 At least one of the CI tasks failed.
Task
tidy: https://github.com/bitcoin/bitcoin/actions/runs/45956875614/job/140365283975LLM reason (✨ experimental): CI failed because clang-tidy treated
r += ","inbitcoin-util.cpp:50as an error; use the character overloadr += ','.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.