From e0d8e2648266c99b16cab5c15b795e3692581efd Mon Sep 17 00:00:00 2001 From: Julian Moik Date: Fri, 31 Jul 2026 21:16:43 +0200 Subject: [PATCH 1/2] BIP-0440: exclude non-v2 inputs from varops budget --- bip-0440.mediawiki | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bip-0440.mediawiki b/bip-0440.mediawiki index 7b5493ca07..d4ae924986 100644 --- a/bip-0440.mediawiki +++ b/bip-0440.mediawiki @@ -10,7 +10,7 @@ License: BSD-3-Clause Discussion: https://groups.google.com/g/bitcoindev/c/GisTcPb8Jco/m/8znWcWwKAQAJ https://delvingbitcoin.org/t/benchmarking-bitcoin-script-evaluation-for-the-varops-budget-great-script-restoration/2094 - Version: 0.2.1 + Version: 0.2.2 ==Introduction== @@ -49,7 +49,7 @@ The last two assumptions make a large difference in practice: normal usage on sm ==Design== -A per-transaction integer "varops budget" is determined by multiplying the total transaction weight by the fixed factor 10,000 (chosen to make operation costs all integer values). The budget is transaction-wide (rather than per-input) to allow for cross-input introspection: a small input may reasonably access larger inputs. +A per-transaction integer "varops budget" is determined by multiplying the transaction weight, excluding the weight of inputs not evaluated under Tapscript v2, by the fixed factor 10,000 (chosen to make operation costs all integer values). For this calculation, an input's weight is the serialized size of its outpoint, scriptSig, and sequence multiplied by the witness discount factor, plus the serialized size of its witness stack; all CompactSize prefixes are included. A transaction without a Tapscript v2 input has no varops budget. Transaction-level fields and outputs remain included, so the total transaction weight is used when every input uses Tapscript v2. Excluding other inputs prevents their weight from funding both pre-existing resource limits and Tapscript v2 execution; for example, a BIP342 input's witness weight could otherwise fund both its own sigops budget and Tapscript v2 execution. The budget is transaction-wide (rather than per-input) to allow for cross-input introspection: a small input may reasonably access larger inputs. Opcodes consume budget as they are executed, based on the length (not generally the value) of their parameters as detailed below. A transaction which exceeds its budget fails to validate. @@ -67,7 +67,7 @@ The script is assumed to execute in a single thread and acts on initial stack el Ideally, on each platform we tested, the worst case time for each opcode would be no worse than the Schnorr signature upper bound: i.e. the block would get no slower. And while CHECKSIG can be batched and/or done in parallel, it also involves hashing, which is not taken into account here (the worst-case being significantly slower than the signature validations themselves). -The signature cost is simply carried across from the existing [[bip-0342.mediawiki|BIP-342]] limit: 50 weight units allow you one signature. Since each transaction gets varops budget for the entire transaction (not just the current input's witness), and each input has at least 41 bytes (164 weight), this is actually slightly more generous than the sigops budget (which was 50 + witness weight), but still limits the entire block to 80,000 signatures. +The signature cost is simply carried across from the existing [[bip-0342.mediawiki|BIP-342]] limit: 50 weight units allow you one signature. For transactions containing both BIP342 and Tapscript v2 inputs, excluding the BIP342 input weight prevents its witness weight from funding both validation budgets. Each input has at least 41 bytes (164 weight), so its excluded weight covers BIP342's allowance of 50 plus its witness weight. The transaction weight funding the remaining varops budget is disjoint from that allowance and bounded by block weight, preserving the limit of 80,000 signatures per block. ===Benchmarks=== @@ -348,6 +348,7 @@ Work in progress: ==Changelog== +* 0.2.2: 2026-07-31: exclude non-Tapscript-v2 input weight from the varops budget. * 0.2.1: 2026-06-15: define wordspan notation and clarify byte-length versus word-span costs. * 0.2.0: 2026-02-21: increase in cost for hashing and copying based on benchmark results. * 0.1.0: 2025-09-27: first public posting From f60581b56350a98ee729bdcbd9694884a05bcf4f Mon Sep 17 00:00:00 2001 From: Julian Moik Date: Fri, 31 Jul 2026 21:17:03 +0200 Subject: [PATCH 2/2] BIP-0441: add OP_BOOLAND to varops cost list --- bip-0441.mediawiki | 1 + 1 file changed, 1 insertion(+) diff --git a/bip-0441.mediawiki b/bip-0441.mediawiki index fd4de36f27..d92a95c5fc 100644 --- a/bip-0441.mediawiki +++ b/bip-0441.mediawiki @@ -617,6 +617,7 @@ The varops costs of the following opcodes are defined in * OP_PICK * OP_TUCK * OP_ROLL +* OP_BOOLAND * OP_BOOLOR * OP_NUMEQUAL * OP_NUMEQUALVERIFY