3 suggestions
Earlier concerns neither republished nor resolved: 3 suggestions. See the Run archive for their assessments.
Optional improvements
[suggestion] · Shared vector elements add heap allocations on push paths
Small and numeric pushes and witness arguments gain allocation overhead, while repeated data pushes lose parser-buffer reuse, so duplication savings alone do not establish a general speedup.
Location: src/script/interpreter.h:380 (head).
Details and suggested fix
MakeStackElem coallocates the control block and vector object, but a non-empty vector's byte buffer still allocates separately. Compared with base, OP_0, small-number and numeric results, and witness arguments gain a shared-object allocation. Moving vchPushValue into each executed data push also prevents GetScriptOp from reusing that buffer for later pushes. Duplication and P2SH stack copies save byte copies, so the net performance effect remains workload-dependent and unmeasured. Prefer a dedicated immutable, reference-counted element that stores its count, length and bytes in one allocation while preserving shared ownership and stable identity. Compare the representations using VerifyNestedIfScript, VerifyPushDropSmall, VerifyPushDropSized* and VerifyDupDropLarge before describing the change as a pure performance improvement. Keep thread-safe counting unless every owner is proven thread-confined. Separately, move saved DUP-family handles into their final slots to avoid the redundant reference-count updates from copying and then destroying each local.
[suggestion] · Boolean result elements allocate eagerly even when unused
During uncached verification, native Taproot key-path spends construct two pairs of Boolean elements that neither preliminary script uses.
Location: src/script/interpreter.cpp:432 (head).
Details and suggested fix
elemFalse and elemTrue construct before parsing, normally requiring two make_shared blocks and a one-byte vector buffer per call; base used process-wide static vectors. For a native Taproot key-path input, VerifyScript first evaluates an empty scriptSig and OP_1 <32 bytes>. Neither uses these handles: OP_1 creates its own numeric element, and witness dispatch then checks the Schnorr signature directly. Those two preliminary calls therefore add six avoidable allocations in the usual allocation model. Start with empty execution-local handles and create each on its first Boolean push, for example through a push_bool helper. This preserves per-execution sharing without global reference-count contention, at the cost of a null check on Boolean pushes. The wall-clock effect is unmeasured.
[suggestion] · Benchmark comments misstate tapscript limits and push workloads
The comments confuse a chosen 10,000-byte workload with a tapscript consensus limit and incorrectly distinguish which push benchmarks materialize every element.
Location: src/bench/verify_script.cpp:157 (head).
Details and suggested fix
MAX_SCRIPT_SIZE and the 201-opcode limit apply only to BASE and WITNESS_V0 here; the witness path executes tapscript leaves without a replacement script-length limit. Describe 10,000 bytes as the benchmarks' chosen workload matching the legacy/segwit-v0 size limit, with TAPSCRIPT selected to avoid the opcode cap. Longer leaves can repeat these cycles within enclosing transaction-policy and consensus block-weight limits, so the PR description should frame the cost per weight unit rather than treat these repetition counts as worst cases. The sized benchmark also uses 18 pushes for N=520, not 100, and only its OP_DROPs count toward MAX_OPS_PER_SCRIPT. Both push benchmarks materialize every pushed element. The actual distinction is that VerifyPushDropSized sweeps inline payload sizes in BASE and keeps all pushed elements live before dropping them, whereas VerifyPushDropSmall alternates pushes and drops. Correcting the comments requires no benchmark or interpreter behavior change.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Oversized P2WSH witnesses allocate an owner per item before rejection (earlier report)
- [suggestion]: Benchmark comments mistake a workload budget for a tapscript limit (earlier report)
- [suggestion]: Aliasing test captures an error output it never reads (earlier report)