Skip to content

Commit 2851b77

Browse files
committed
Make all script verification flags softforks
1 parent 2935b46 commit 2851b77

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

src/script/interpreter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,6 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
349349
{
350350
if (!(flags & SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)) {
351351
// not enabled; treat as a NOP2
352-
if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
353-
return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS);
354-
}
355352
break;
356353
}
357354

@@ -391,9 +388,6 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
391388
{
392389
if (!(flags & SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)) {
393390
// not enabled; treat as a NOP3
394-
if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
395-
return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS);
396-
}
397391
break;
398392
}
399393

src/script/interpreter.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,40 @@ enum
2727
SIGHASH_ANYONECANPAY = 0x80,
2828
};
2929

30-
/** Script verification flags */
30+
/** Script verification flags.
31+
*
32+
* All flags are intended to be soft forks: the set of acceptable scripts under
33+
* flags (A | B) is a subset of the acceptable scripts under flag (A).
34+
*/
3135
enum
3236
{
3337
SCRIPT_VERIFY_NONE = 0,
3438

35-
// Evaluate P2SH subscripts (softfork safe, BIP16).
39+
// Evaluate P2SH subscripts (BIP16).
3640
SCRIPT_VERIFY_P2SH = (1U << 0),
3741

3842
// Passing a non-strict-DER signature or one with undefined hashtype to a checksig operation causes script failure.
3943
// Evaluating a pubkey that is not (0x04 + 64 bytes) or (0x02 or 0x03 + 32 bytes) by checksig causes script failure.
40-
// (softfork safe, but not used or intended as a consensus rule).
44+
// (not used or intended as a consensus rule).
4145
SCRIPT_VERIFY_STRICTENC = (1U << 1),
4246

43-
// Passing a non-strict-DER signature to a checksig operation causes script failure (softfork safe, BIP62 rule 1)
47+
// Passing a non-strict-DER signature to a checksig operation causes script failure (BIP62 rule 1)
4448
SCRIPT_VERIFY_DERSIG = (1U << 2),
4549

4650
// Passing a non-strict-DER signature or one with S > order/2 to a checksig operation causes script failure
47-
// (softfork safe, BIP62 rule 5).
51+
// (BIP62 rule 5).
4852
SCRIPT_VERIFY_LOW_S = (1U << 3),
4953

50-
// verify dummy stack item consumed by CHECKMULTISIG is of zero-length (softfork safe, BIP62 rule 7).
54+
// verify dummy stack item consumed by CHECKMULTISIG is of zero-length (BIP62 rule 7).
5155
SCRIPT_VERIFY_NULLDUMMY = (1U << 4),
5256

53-
// Using a non-push operator in the scriptSig causes script failure (softfork safe, BIP62 rule 2).
57+
// Using a non-push operator in the scriptSig causes script failure (BIP62 rule 2).
5458
SCRIPT_VERIFY_SIGPUSHONLY = (1U << 5),
5559

5660
// Require minimal encodings for all push operations (OP_0... OP_16, OP_1NEGATE where possible, direct
5761
// pushes up to 75 bytes, OP_PUSHDATA up to 255 bytes, OP_PUSHDATA2 for anything larger). Evaluating
5862
// any other push causes the script to fail (BIP62 rule 3).
5963
// In addition, whenever a stack element is interpreted as a number, it must be of minimal length (BIP62 rule 4).
60-
// (softfork safe)
6164
SCRIPT_VERIFY_MINIMALDATA = (1U << 6),
6265

6366
// Discourage use of NOPs reserved for upgrades (NOP1-10)
@@ -68,12 +71,14 @@ enum
6871
// discouraged NOPs fails the script. This verification flag will never be
6972
// a mandatory flag applied to scripts in a block. NOPs that are not
7073
// executed, e.g. within an unexecuted IF ENDIF block, are *not* rejected.
74+
// NOPs that have associated forks to give them new meaning (CLTV, CSV)
75+
// are not subject to this rule.
7176
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS = (1U << 7),
7277

7378
// Require that only a single stack element remains after evaluation. This changes the success criterion from
7479
// "At least one stack element must remain, and when interpreted as a boolean, it must be true" to
7580
// "Exactly one stack element must remain, and when interpreted as a boolean, it must be true".
76-
// (softfork safe, BIP62 rule 6)
81+
// (BIP62 rule 6)
7782
// Note: CLEANSTACK should never be used without P2SH or WITNESS.
7883
SCRIPT_VERIFY_CLEANSTACK = (1U << 8),
7984

src/test/data/script_tests.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,6 @@
862862

863863
["Ensure 100% coverage of discouraged NOPS"],
864864
["1", "NOP1", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
865-
["1", "CHECKLOCKTIMEVERIFY", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
866-
["1", "CHECKSEQUENCEVERIFY", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
867865
["1", "NOP4", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
868866
["1", "NOP5", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
869867
["1", "NOP6", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],

0 commit comments

Comments
 (0)