mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Remove NOP1..10 (#1761)
This commit is contained in:
parent
9bedf84740
commit
bdd42903b4
@ -1216,38 +1216,12 @@
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"'NOP_1_to_10'",
|
||||
"NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 'NOP_1_to_10' EQUAL",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"OK",
|
||||
"Discourage NOPx flag allows OP_NOP"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
"IF NOP10 ENDIF 1",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"OK",
|
||||
"Discouraged NOPs are allowed if not executed"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
"IF 0xbc ELSE 1 ENDIF",
|
||||
"IF 0xb2 ELSE 1 ENDIF",
|
||||
"",
|
||||
"OK",
|
||||
"opcodes above NOP10 invalid if executed"
|
||||
"opcodes above OP_CHECKSEQUENCEVERIFY invalid if executed"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
@ -2187,66 +2161,6 @@
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP1 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP2 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP3 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP4 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP5 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP6 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP7 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP8 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP9 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP10 1",
|
||||
"",
|
||||
"OK"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"0 0 CHECKMULTISIG VERIFY DEPTH 0 EQUAL",
|
||||
@ -3760,88 +3674,6 @@
|
||||
"DISABLED_OPCODE",
|
||||
"disabled"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL",
|
||||
"",
|
||||
"EVAL_FALSE"
|
||||
],
|
||||
[
|
||||
"'NOP_1_to_10'",
|
||||
"NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 'NOP_1_to_11' EQUAL",
|
||||
"",
|
||||
"EVAL_FALSE"
|
||||
],
|
||||
[
|
||||
"Ensure 100% coverage of discouraged NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP1",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP2",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP3",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP4",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP5",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP6",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP7",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP8",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP9",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"NOP10",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS"
|
||||
],
|
||||
[
|
||||
"1 0x01 0xbb",
|
||||
"BLAKE2B 0x20 0x4324d0dc945c746e3be93be15b636ec1684108806912a479e8a34b2858be114a EQUAL",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"DISCOURAGE_UPGRADABLE_NOPS",
|
||||
"Discouraged NOP10 in redeemScript"
|
||||
],
|
||||
[
|
||||
"0x50",
|
||||
"1",
|
||||
@ -3851,10 +3683,70 @@
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xbc ELSE 1 ENDIF",
|
||||
"IF 0xb2 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE",
|
||||
"opcodes above NOP10 invalid if executed"
|
||||
"opcodes above OP_CHECKSEQUENCEVERIFY invalid if executed"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xb3 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xb4 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xb5 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xb6 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xb7 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xb8 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xb9 ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xba ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xbb ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"IF 0xbc ELSE 1 ENDIF",
|
||||
"",
|
||||
"BAD_OPCODE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
@ -4337,12 +4229,6 @@
|
||||
"SCRIPT_SIZE",
|
||||
"10,001-byte scriptPubKey"
|
||||
],
|
||||
[
|
||||
"",
|
||||
"NOP1 NOP10",
|
||||
"",
|
||||
"EVAL_FALSE"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"VER",
|
||||
@ -4387,10 +4273,10 @@
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0xbc",
|
||||
"0xb2",
|
||||
"",
|
||||
"BAD_OPCODE",
|
||||
"0xbc == OP_NOP10 + 1"
|
||||
"0xb2 == OP_CHECKSEQUENCEVERIFY + 1"
|
||||
],
|
||||
[
|
||||
"2147483648",
|
||||
@ -4847,12 +4733,6 @@
|
||||
"SIG_PUSHONLY",
|
||||
"Tests for Script.IsPushOnly()"
|
||||
],
|
||||
[
|
||||
"NOP1 0x01 1",
|
||||
"BLAKE2B 0x20 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL",
|
||||
"",
|
||||
"SIG_PUSHONLY"
|
||||
],
|
||||
[
|
||||
"0 0x01 0x50",
|
||||
"BLAKE2B 0x20 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL",
|
||||
|
@ -20,14 +20,6 @@ type ScriptFlags uint32
|
||||
const (
|
||||
// ScriptNoFlags is used when you want to use ScriptFlags without raising any flags
|
||||
ScriptNoFlags ScriptFlags = 0
|
||||
|
||||
// ScriptDiscourageUpgradableNops defines whether to verify that
|
||||
// NOP1 through NOP10 are reserved for future soft-fork upgrades. This
|
||||
// flag must not be used for consensus critical code nor applied to
|
||||
// blocks as this flag is only for stricter standard transaction
|
||||
// checks. This flag is only applied when the above opcodes are
|
||||
// executed.
|
||||
ScriptDiscourageUpgradableNops ScriptFlags = 1 << iota
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -201,11 +201,6 @@ const (
|
||||
// Failures related to soft forks.
|
||||
// -------------------------------
|
||||
|
||||
// ErrDiscourageUpgradableNOPs is returned when the
|
||||
// ScriptDiscourageUpgradableNops flag is set and a NOP opcode is
|
||||
// encountered in a script.
|
||||
ErrDiscourageUpgradableNOPs
|
||||
|
||||
// ErrNegativeLockTime is returned when a script contains an opcode that
|
||||
// interprets a negative lock time.
|
||||
ErrNegativeLockTime
|
||||
@ -226,46 +221,45 @@ const (
|
||||
|
||||
// Map of ErrorCode values back to their constant names for pretty printing.
|
||||
var errorCodeStrings = map[ErrorCode]string{
|
||||
ErrInternal: "ErrInternal",
|
||||
ErrInvalidFlags: "ErrInvalidFlags",
|
||||
ErrInvalidIndex: "ErrInvalidIndex",
|
||||
ErrUnsupportedAddress: "ErrUnsupportedAddress",
|
||||
ErrNotMultisigScript: "ErrNotMultisigScript",
|
||||
ErrTooManyRequiredSigs: "ErrTooManyRequiredSigs",
|
||||
ErrEarlyReturn: "ErrEarlyReturn",
|
||||
ErrEmptyStack: "ErrEmptyStack",
|
||||
ErrEvalFalse: "ErrEvalFalse",
|
||||
ErrScriptUnfinished: "ErrScriptUnfinished",
|
||||
ErrInvalidProgramCounter: "ErrInvalidProgramCounter",
|
||||
ErrScriptTooBig: "ErrScriptTooBig",
|
||||
ErrElementTooBig: "ErrElementTooBig",
|
||||
ErrTooManyOperations: "ErrTooManyOperations",
|
||||
ErrStackOverflow: "ErrStackOverflow",
|
||||
ErrInvalidPubKeyCount: "ErrInvalidPubKeyCount",
|
||||
ErrInvalidSignatureCount: "ErrInvalidSignatureCount",
|
||||
ErrNumberTooBig: "ErrNumberTooBig",
|
||||
ErrVerify: "ErrVerify",
|
||||
ErrEqualVerify: "ErrEqualVerify",
|
||||
ErrNumEqualVerify: "ErrNumEqualVerify",
|
||||
ErrCheckSigVerify: "ErrCheckSigVerify",
|
||||
ErrCheckMultiSigVerify: "ErrCheckMultiSigVerify",
|
||||
ErrDisabledOpcode: "ErrDisabledOpcode",
|
||||
ErrReservedOpcode: "ErrReservedOpcode",
|
||||
ErrMalformedPush: "ErrMalformedPush",
|
||||
ErrInvalidStackOperation: "ErrInvalidStackOperation",
|
||||
ErrUnbalancedConditional: "ErrUnbalancedConditional",
|
||||
ErrMinimalData: "ErrMinimalData",
|
||||
ErrInvalidSigHashType: "ErrInvalidSigHashType",
|
||||
ErrSigLength: "ErrSigLength",
|
||||
ErrSigHighS: "ErrSigHighS",
|
||||
ErrNotPushOnly: "ErrNotPushOnly",
|
||||
ErrPubKeyFormat: "ErrPubKeyFormat",
|
||||
ErrCleanStack: "ErrCleanStack",
|
||||
ErrNullFail: "ErrNullFail",
|
||||
ErrDiscourageUpgradableNOPs: "ErrDiscourageUpgradableNOPs",
|
||||
ErrNegativeLockTime: "ErrNegativeLockTime",
|
||||
ErrUnsatisfiedLockTime: "ErrUnsatisfiedLockTime",
|
||||
ErrMinimalIf: "ErrMinimalIf",
|
||||
ErrInternal: "ErrInternal",
|
||||
ErrInvalidFlags: "ErrInvalidFlags",
|
||||
ErrInvalidIndex: "ErrInvalidIndex",
|
||||
ErrUnsupportedAddress: "ErrUnsupportedAddress",
|
||||
ErrNotMultisigScript: "ErrNotMultisigScript",
|
||||
ErrTooManyRequiredSigs: "ErrTooManyRequiredSigs",
|
||||
ErrEarlyReturn: "ErrEarlyReturn",
|
||||
ErrEmptyStack: "ErrEmptyStack",
|
||||
ErrEvalFalse: "ErrEvalFalse",
|
||||
ErrScriptUnfinished: "ErrScriptUnfinished",
|
||||
ErrInvalidProgramCounter: "ErrInvalidProgramCounter",
|
||||
ErrScriptTooBig: "ErrScriptTooBig",
|
||||
ErrElementTooBig: "ErrElementTooBig",
|
||||
ErrTooManyOperations: "ErrTooManyOperations",
|
||||
ErrStackOverflow: "ErrStackOverflow",
|
||||
ErrInvalidPubKeyCount: "ErrInvalidPubKeyCount",
|
||||
ErrInvalidSignatureCount: "ErrInvalidSignatureCount",
|
||||
ErrNumberTooBig: "ErrNumberTooBig",
|
||||
ErrVerify: "ErrVerify",
|
||||
ErrEqualVerify: "ErrEqualVerify",
|
||||
ErrNumEqualVerify: "ErrNumEqualVerify",
|
||||
ErrCheckSigVerify: "ErrCheckSigVerify",
|
||||
ErrCheckMultiSigVerify: "ErrCheckMultiSigVerify",
|
||||
ErrDisabledOpcode: "ErrDisabledOpcode",
|
||||
ErrReservedOpcode: "ErrReservedOpcode",
|
||||
ErrMalformedPush: "ErrMalformedPush",
|
||||
ErrInvalidStackOperation: "ErrInvalidStackOperation",
|
||||
ErrUnbalancedConditional: "ErrUnbalancedConditional",
|
||||
ErrMinimalData: "ErrMinimalData",
|
||||
ErrInvalidSigHashType: "ErrInvalidSigHashType",
|
||||
ErrSigLength: "ErrSigLength",
|
||||
ErrSigHighS: "ErrSigHighS",
|
||||
ErrNotPushOnly: "ErrNotPushOnly",
|
||||
ErrPubKeyFormat: "ErrPubKeyFormat",
|
||||
ErrCleanStack: "ErrCleanStack",
|
||||
ErrNullFail: "ErrNullFail",
|
||||
ErrNegativeLockTime: "ErrNegativeLockTime",
|
||||
ErrUnsatisfiedLockTime: "ErrUnsatisfiedLockTime",
|
||||
ErrMinimalIf: "ErrMinimalIf",
|
||||
}
|
||||
|
||||
// String returns the ErrorCode as a human-readable name.
|
||||
|
@ -52,7 +52,6 @@ func TestErrorCodeStringer(t *testing.T) {
|
||||
{ErrPubKeyFormat, "ErrPubKeyFormat"},
|
||||
{ErrCleanStack, "ErrCleanStack"},
|
||||
{ErrNullFail, "ErrNullFail"},
|
||||
{ErrDiscourageUpgradableNOPs, "ErrDiscourageUpgradableNOPs"},
|
||||
{ErrNegativeLockTime, "ErrNegativeLockTime"},
|
||||
{ErrUnsatisfiedLockTime, "ErrUnsatisfiedLockTime"},
|
||||
{ErrMinimalIf, "ErrMinimalIf"},
|
||||
|
@ -213,16 +213,16 @@ const (
|
||||
OpCheckMultiSigVerify = 0xaf // 175
|
||||
OpCheckLockTimeVerify = 0xb0 // 176
|
||||
OpCheckSequenceVerify = 0xb1 // 177
|
||||
OpNop1 = 0xb2 // 178
|
||||
OpNop2 = 0xb3 // 179
|
||||
OpNop3 = 0xb4 // 180
|
||||
OpNop4 = 0xb5 // 181
|
||||
OpNop5 = 0xb6 // 182
|
||||
OpNop6 = 0xb7 // 183
|
||||
OpNop7 = 0xb8 // 184
|
||||
OpNop8 = 0xb9 // 185
|
||||
OpNop9 = 0xba // 186
|
||||
OpNop10 = 0xbb // 187
|
||||
OpUnknown178 = 0xb2 // 178
|
||||
OpUnknown179 = 0xb3 // 179
|
||||
OpUnknown180 = 0xb4 // 180
|
||||
OpUnknown181 = 0xb5 // 181
|
||||
OpUnknown182 = 0xb6 // 182
|
||||
OpUnknown183 = 0xb7 // 183
|
||||
OpUnknown184 = 0xb8 // 184
|
||||
OpUnknown185 = 0xb9 // 185
|
||||
OpUnknown186 = 0xba // 186
|
||||
OpUnknown187 = 0xbb // 187
|
||||
OpUnknown188 = 0xbc // 188
|
||||
OpUnknown189 = 0xbd // 189
|
||||
OpUnknown190 = 0xbe // 190
|
||||
@ -494,21 +494,19 @@ var opcodeArray = [256]opcode{
|
||||
OpCheckMultiSig: {OpCheckMultiSig, "OP_CHECKMULTISIG", 1, opcodeCheckMultiSig},
|
||||
OpCheckMultiSigVerify: {OpCheckMultiSigVerify, "OP_CHECKMULTISIGVERIFY", 1, opcodeCheckMultiSigVerify},
|
||||
|
||||
// Reserved opcodes.
|
||||
OpNop1: {OpNop1, "OP_NOP1", 1, opcodeNop},
|
||||
OpNop2: {OpNop2, "OP_NOP2", 1, opcodeNop},
|
||||
OpNop3: {OpNop3, "OP_NOP3", 1, opcodeNop},
|
||||
OpNop4: {OpNop4, "OP_NOP4", 1, opcodeNop},
|
||||
OpNop5: {OpNop5, "OP_NOP5", 1, opcodeNop},
|
||||
OpNop6: {OpNop6, "OP_NOP6", 1, opcodeNop},
|
||||
OpNop7: {OpNop7, "OP_NOP7", 1, opcodeNop},
|
||||
OpNop8: {OpNop8, "OP_NOP8", 1, opcodeNop},
|
||||
OpNop9: {OpNop9, "OP_NOP9", 1, opcodeNop},
|
||||
OpNop10: {OpNop10, "OP_NOP10", 1, opcodeNop},
|
||||
|
||||
// Undefined opcodes.
|
||||
OpUnknown166: {OpUnknown166, "OP_UNKNOWN166", 1, opcodeInvalid},
|
||||
OpUnknown167: {OpUnknown167, "OP_UNKNOWN167", 1, opcodeInvalid},
|
||||
OpUnknown178: {OpUnknown188, "OP_UNKNOWN178", 1, opcodeInvalid},
|
||||
OpUnknown179: {OpUnknown189, "OP_UNKNOWN179", 1, opcodeInvalid},
|
||||
OpUnknown180: {OpUnknown190, "OP_UNKNOWN180", 1, opcodeInvalid},
|
||||
OpUnknown181: {OpUnknown191, "OP_UNKNOWN181", 1, opcodeInvalid},
|
||||
OpUnknown182: {OpUnknown192, "OP_UNKNOWN182", 1, opcodeInvalid},
|
||||
OpUnknown183: {OpUnknown193, "OP_UNKNOWN183", 1, opcodeInvalid},
|
||||
OpUnknown184: {OpUnknown194, "OP_UNKNOWN184", 1, opcodeInvalid},
|
||||
OpUnknown185: {OpUnknown195, "OP_UNKNOWN185", 1, opcodeInvalid},
|
||||
OpUnknown186: {OpUnknown196, "OP_UNKNOWN186", 1, opcodeInvalid},
|
||||
OpUnknown187: {OpUnknown197, "OP_UNKNOWN187", 1, opcodeInvalid},
|
||||
OpUnknown188: {OpUnknown188, "OP_UNKNOWN188", 1, opcodeInvalid},
|
||||
OpUnknown189: {OpUnknown189, "OP_UNKNOWN189", 1, opcodeInvalid},
|
||||
OpUnknown190: {OpUnknown190, "OP_UNKNOWN190", 1, opcodeInvalid},
|
||||
@ -613,17 +611,6 @@ type parsedOpcode struct {
|
||||
data []byte
|
||||
}
|
||||
|
||||
// isUpgradableNop returns whether or not the opcode is a numbered nop
|
||||
// that is intended to be upgradable by a soft fork
|
||||
func isUpgradableNop(pop *parsedOpcode) bool {
|
||||
switch pop.opcode.value {
|
||||
case OpNop1, OpNop2, OpNop3, OpNop4, OpNop5,
|
||||
OpNop6, OpNop7, OpNop8, OpNop9, OpNop10:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// isDisabled returns whether or not the opcode is disabled and thus is always
|
||||
// bad to see in the instruction stream (even if turned off by a conditional).
|
||||
func (pop *parsedOpcode) isDisabled() bool {
|
||||
@ -913,13 +900,6 @@ func opcodeN(op *parsedOpcode, vm *Engine) error {
|
||||
// implies it generally does nothing, however, it will return an error when
|
||||
// the flag to discourage use of NOPs is set for select opcodes.
|
||||
func opcodeNop(op *parsedOpcode, vm *Engine) error {
|
||||
if isUpgradableNop(op) {
|
||||
if vm.hasFlag(ScriptDiscourageUpgradableNops) {
|
||||
str := fmt.Sprintf("OP_NOP%d reserved for soft-fork "+
|
||||
"upgrades", op.opcode.value-(OpNop1-1))
|
||||
return scriptError(ErrDiscourageUpgradableNOPs, str)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -109,10 +109,6 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||
data = []byte{val}
|
||||
expectedStr = strconv.Itoa(int(val))
|
||||
|
||||
case isNumberedNop(opcodeVal):
|
||||
val := byte(opcodeVal - (OpNop1 - 1))
|
||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||
|
||||
// OP_UNKNOWN#.
|
||||
case isOpUnknown(opcodeVal):
|
||||
expectedStr = "OP_UNKNOWN" + strconv.Itoa(int(opcodeVal))
|
||||
@ -165,10 +161,6 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||
data = []byte{val}
|
||||
expectedStr = "OP_" + strconv.Itoa(int(val))
|
||||
|
||||
case isNumberedNop(opcodeVal):
|
||||
val := byte(opcodeVal - (OpNop1 - 1))
|
||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||
|
||||
// OP_UNKNOWN#.
|
||||
case isOpUnknown(opcodeVal):
|
||||
expectedStr = "OP_UNKNOWN" + strconv.Itoa(int(opcodeVal))
|
||||
@ -186,10 +178,6 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||
}
|
||||
|
||||
func isOpUnknown(opcodeVal int) bool {
|
||||
return opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc ||
|
||||
return opcodeVal >= 0xb2 && opcodeVal <= 0xf9 || opcodeVal == 0xfc ||
|
||||
opcodeVal == 0xa6 || opcodeVal == 0xa7
|
||||
}
|
||||
|
||||
func isNumberedNop(opcodeVal int) bool {
|
||||
return opcodeVal >= OpNop1 && opcodeVal <= OpNop10
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
package txscript
|
||||
|
||||
const (
|
||||
// StandardVerifyFlags are the script flags which are used when
|
||||
// executing transaction scripts to enforce additional checks which
|
||||
// are required for the script to be considered standard. These checks
|
||||
// help reduce issues related to transaction malleability as well as
|
||||
// allow pay-to-script hash transactions. Note these flags are
|
||||
// different than what is required for the consensus rules in that they
|
||||
// are more strict.
|
||||
StandardVerifyFlags = ScriptDiscourageUpgradableNops
|
||||
)
|
@ -139,8 +139,6 @@ func parseScriptFlags(flagStr string) (ScriptFlags, error) {
|
||||
switch flag {
|
||||
case "":
|
||||
// Nothing.
|
||||
case "DISCOURAGE_UPGRADABLE_NOPS":
|
||||
flags |= ScriptDiscourageUpgradableNops
|
||||
default:
|
||||
return flags, errors.Errorf("invalid flag: %s", flag)
|
||||
}
|
||||
@ -188,8 +186,6 @@ func parseExpectedResult(expected string) ([]ErrorCode, error) {
|
||||
return []ErrorCode{ErrInvalidStackOperation}, nil
|
||||
case "DISABLED_OPCODE":
|
||||
return []ErrorCode{ErrDisabledOpcode}, nil
|
||||
case "DISCOURAGE_UPGRADABLE_NOPS":
|
||||
return []ErrorCode{ErrDiscourageUpgradableNOPs}, nil
|
||||
case "PUSH_SIZE":
|
||||
return []ErrorCode{ErrElementTooBig}, nil
|
||||
case "OP_COUNT":
|
||||
|
@ -3395,166 +3395,6 @@ func TestUnparsingInvalidOpcodes(t *testing.T) {
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP1",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop1],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP1 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop1],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP2",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop2],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP2 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop2],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP3",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop3],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP3 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop3],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP4",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop4],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP4 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop4],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP5",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop5],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP5 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop5],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP6",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop6],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP6 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop6],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP7",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop7],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP7 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop7],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP8",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop8],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP8 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop8],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP9",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop9],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP9 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop9],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_NOP10",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop10],
|
||||
data: nil,
|
||||
},
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
name: "OP_NOP10 long",
|
||||
pop: &parsedOpcode{
|
||||
opcode: &opcodeArray[OpNop10],
|
||||
data: make([]byte, 1),
|
||||
},
|
||||
expectedErr: scriptError(ErrInternal, ""),
|
||||
},
|
||||
{
|
||||
name: "OP_PUBKEYHASH",
|
||||
pop: &parsedOpcode{
|
||||
|
Loading…
x
Reference in New Issue
Block a user