3 suggestions
Earlier concerns neither republished nor resolved: 3 suggestions. See the Run archive for their assessments.
Optional improvements
[suggestion] · EvalScript eagerly allocates Boolean result elements even when unused
Uncached native Taproot key-path verification creates unused Boolean result objects in both EvalScript calls, adding allocation work that the base implementation avoided.
Location: src/script/interpreter.cpp:432 (head).
Details and suggested fix
Both handles are constructed before script processing. Each call creates two shared owners plus the one-byte true payload, adding three allocations where base used static vectors. VerifyScript evaluates an empty scriptSig and an OP_1 <32-byte key> scriptPubKey before native Taproot key-path dispatch. Ordinary pushes materialize separate elements, and the Schnorr branch needs neither result handle. That gives six unused allocations per uncached input; full script-cache hits avoid this work. Initialize execution-local handles lazily at their first corresponding result push, then reuse them. This retains immutable sharing without global reference-count contention, at the cost of a null check per Boolean result. Compare the existing key-path and P2WPKH benchmarks before assuming a wall-clock improvement.
[suggestion] · Oversized P2WSH witnesses allocate one shared owner per argument before rejection
A consensus-invalid block with valid proof of work can cause millions of transient shared-owner allocations for empty P2WSH arguments before script rejection.
Location: src/script/interpreter.cpp:1876 (head).
Details and suggested fix
The P2WSH branch checks the script commitment without an initial argument-count limit. With millions of empty arguments and a matching empty witnessScript, every argument passes the element-size check and reaches MakeStackElem. EvalScript executes no opcodes, then the wrapper returns SCRIPT_ERR_CLEANSTACK. Base copied the empty vectors with one outer allocation and no per-argument allocations. Empty arguments cost one witness byte each, so millions fit within block weight. Default relay rejects these stacks before script checking; network block validation can reach the conversion in a consensus-invalid block with valid proof of work and matching commitments. The work is transient and linear in block weight, and its time and memory impact is unmeasured. Reuse one execution-local immutable empty element for empty arguments while preserving their slot count. Do not simply import Tapscript's early count check into v0, where the first opcode can consume arguments before the existing size check.
[suggestion] · Benchmark comments describe MAX_SCRIPT_SIZE as a tapscript limit
The new TAPSCRIPT benchmarks use 10,000 bytes as a chosen workload size, not a consensus ceiling, so their comments misrepresent the repetition bounds.
Location: src/bench/verify_script.cpp:155 (head).
Details and suggested fix
Both benchmarks select TAPSCRIPT, but EvalScript enforces MAX_SCRIPT_SIZE and the 201-opcode limit only for BASE and WITNESS_V0. ExecuteWitnessScript supplies no replacement script-length check. Longer versions of these low-depth, signature-free sequences can run within transaction and block weight bounds, so the comments and the PR description should not present 10,000 bytes as a tapscript ceiling or these repetition counts as worst cases. Describe it as a chosen benchmark size matching the legacy and segwit-v0 script limit, and note that TAPSCRIPT avoids the 201-opcode cap. The benchmark code itself needs no change.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Shared-owner allocations increase push-heavy allocation counts (earlier report)
- [suggestion]: Saved element handles incur redundant reference-count updates (earlier report)
- [suggestion]: Aliasing test captures an error output it never reads (earlier report)