diff --git a/src/core_read.cpp b/src/core_read.cpp --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -26,8 +26,8 @@ static std::map mapOpNames; if (mapOpNames.empty()) { - for (int op = 0; op <= OP_NOP10; op++) { - // Allow OP_RESERVED to get into mapOpNames + for (int op = 0; op < FIRST_UNDEFINED_OP_VALUE; op++) { + // ignore all "PUSHDATA" ops, but dont ignore OP_RESERVED if (op < OP_NOP && op != OP_RESERVED) { continue; } diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -332,12 +332,12 @@ return set_error(serror, SCRIPT_ERR_OP_COUNT); } - if (opcode == OP_CAT || opcode == OP_SUBSTR || opcode == OP_LEFT || - opcode == OP_RIGHT || opcode == OP_INVERT || opcode == OP_AND || - opcode == OP_OR || opcode == OP_XOR || opcode == OP_2MUL || - opcode == OP_2DIV || opcode == OP_MUL || opcode == OP_DIV || - opcode == OP_MOD || opcode == OP_LSHIFT || - opcode == OP_RSHIFT) { + if (opcode == OP_CAT || opcode == OP_SPLIT || + opcode == OP_NUM2BIN || opcode == OP_BIN2NUM || + opcode == OP_INVERT || opcode == OP_AND || opcode == OP_OR || + opcode == OP_XOR || opcode == OP_2MUL || opcode == OP_2DIV || + opcode == OP_MUL || opcode == OP_DIV || opcode == OP_MOD || + opcode == OP_LSHIFT || opcode == OP_RSHIFT) { // Disabled opcodes. return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); } diff --git a/src/script/script.h b/src/script/script.h --- a/src/script/script.h +++ b/src/script/script.h @@ -102,9 +102,9 @@ // splice ops OP_CAT = 0x7e, - OP_SUBSTR = 0x7f, - OP_LEFT = 0x80, - OP_RIGHT = 0x81, + OP_SPLIT = 0x7f, // after monolith upgrade (May 2018) + OP_NUM2BIN = 0x80, // after monolith upgrade (May 2018) + OP_BIN2NUM = 0x81, // after monolith upgrade (May 2018) OP_SIZE = 0x82, // bit logic @@ -175,6 +175,9 @@ OP_NOP9 = 0xb8, OP_NOP10 = 0xb9, + // the first op_code value after all defined opcodes + FIRST_UNDEFINED_OP_VALUE, + // template matching params OP_SMALLINTEGER = 0xfa, OP_PUBKEYS = 0xfb, diff --git a/src/script/script.cpp b/src/script/script.cpp --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -121,12 +121,12 @@ // splice ops case OP_CAT: return "OP_CAT"; - case OP_SUBSTR: - return "OP_SUBSTR"; - case OP_LEFT: - return "OP_LEFT"; - case OP_RIGHT: - return "OP_RIGHT"; + case OP_SPLIT: + return "OP_SPLIT"; + case OP_NUM2BIN: + return "OP_NUM2BIN"; + case OP_BIN2NUM: + return "OP_BIN2NUM"; case OP_SIZE: return "OP_SIZE"; diff --git a/src/test/data/script_tests.json b/src/test/data/script_tests.json --- a/src/test/data/script_tests.json +++ b/src/test/data/script_tests.json @@ -240,7 +240,7 @@ ["0", "IF NOP10 ENDIF 1", "P2SH,STRICTENC,DISCOURAGE_UPGRADABLE_NOPS", "OK", "Discouraged NOPs are allowed if not executed"], -["0", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "OK", "opcodes above NOP10 invalid if executed"], +["0", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "OK", "opcodes >= FIRST_UNDEFINED_OP_VALUE invalid if executed"], ["0", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"], ["0", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"], ["0", "IF 0xbd ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"], @@ -819,10 +819,10 @@ ["'a' 'b'", "CAT", "P2SH,STRICTENC", "DISABLED_OPCODE", "CAT disabled"], ["'a' 'b' 0", "IF CAT ELSE 1 ENDIF", "P2SH,STRICTENC", "DISABLED_OPCODE", "CAT disabled"], -["'abc' 1 1", "SUBSTR", "P2SH,STRICTENC", "DISABLED_OPCODE", "SUBSTR disabled"], -["'abc' 1 1 0", "IF SUBSTR ELSE 1 ENDIF", "P2SH,STRICTENC", "DISABLED_OPCODE", "SUBSTR disabled"], -["'abc' 2 0", "IF LEFT ELSE 1 ENDIF", "P2SH,STRICTENC", "DISABLED_OPCODE", "LEFT disabled"], -["'abc' 2 0", "IF RIGHT ELSE 1 ENDIF", "P2SH,STRICTENC", "DISABLED_OPCODE", "RIGHT disabled"], +["'abc' 1 1", "SPLIT", "P2SH,STRICTENC", "DISABLED_OPCODE", "SPLIT disabled"], +["'abc' 1 1 0", "IF SPLIT ELSE 1 ENDIF", "P2SH,STRICTENC", "DISABLED_OPCODE", "SPLIT disabled"], +["'abc' 2 0", "IF NUM2BIN ELSE 1 ENDIF", "P2SH,STRICTENC", "DISABLED_OPCODE", "NUM2BIN disabled"], +["'abc' 2 0", "IF BIN2NUM ELSE 1 ENDIF", "P2SH,STRICTENC", "DISABLED_OPCODE", "BIN2NUM disabled"], ["NOP", "SIZE 1", "P2SH,STRICTENC", "INVALID_STACK_OPERATION"], @@ -878,7 +878,7 @@ "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS", "Discouraged NOP10 in redeemScript"], ["0x50","1", "P2SH,STRICTENC", "BAD_OPCODE", "opcode 0x50 is reserved"], -["1", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE", "opcodes above NOP10 invalid if executed"], +["1", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE", "opcodes >= FIRST_UNDEFINED_OP_VALUE invalid if executed"], ["1", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"], ["1", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"], ["1", "IF 0xbd ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"], @@ -1001,7 +1001,7 @@ ["1","RESERVED", "P2SH,STRICTENC", "BAD_OPCODE", "OP_RESERVED is reserved"], ["1","RESERVED1", "P2SH,STRICTENC", "BAD_OPCODE", "OP_RESERVED1 is reserved"], ["1","RESERVED2", "P2SH,STRICTENC", "BAD_OPCODE", "OP_RESERVED2 is reserved"], -["1","0xba", "P2SH,STRICTENC", "BAD_OPCODE", "0xba == OP_NOP10 + 1"], +["1","0xba", "P2SH,STRICTENC", "BAD_OPCODE", "0xba == FIRST_UNDEFINED_OP_VALUE"], ["2147483648", "1ADD 1", "P2SH,STRICTENC", "UNKNOWN_ERROR", "We cannot do math on 5-byte integers"], ["2147483648", "NEGATE 1", "P2SH,STRICTENC", "UNKNOWN_ERROR", "We cannot do math on 5-byte integers"], diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py --- a/test/functional/test_framework/script.py +++ b/test/functional/test_framework/script.py @@ -170,9 +170,9 @@ # splice ops OP_CAT = CScriptOp(0x7e) -OP_SUBSTR = CScriptOp(0x7f) -OP_LEFT = CScriptOp(0x80) -OP_RIGHT = CScriptOp(0x81) +OP_SPLIT = CScriptOp(0x7f) +OP_NUM2BIN = CScriptOp(0x80) +OP_BIN2NUM = CScriptOp(0x81) OP_SIZE = CScriptOp(0x82) # bit logic @@ -301,9 +301,9 @@ OP_TUCK, OP_CAT, - OP_SUBSTR, - OP_LEFT, - OP_RIGHT, + OP_SPLIT, + OP_NUM2BIN, + OP_BIN2NUM, OP_SIZE, OP_INVERT, @@ -427,9 +427,9 @@ OP_SWAP: 'OP_SWAP', OP_TUCK: 'OP_TUCK', OP_CAT: 'OP_CAT', - OP_SUBSTR: 'OP_SUBSTR', - OP_LEFT: 'OP_LEFT', - OP_RIGHT: 'OP_RIGHT', + OP_SPLIT: 'OP_SPLIT', + OP_NUM2BIN: 'OP_NUM2BIN', + OP_BIN2NUM: 'OP_BIN2NUM', OP_SIZE: 'OP_SIZE', OP_INVERT: 'OP_INVERT', OP_AND: 'OP_AND', @@ -546,9 +546,9 @@ 'OP_SWAP': OP_SWAP, 'OP_TUCK': OP_TUCK, 'OP_CAT': OP_CAT, - 'OP_SUBSTR': OP_SUBSTR, - 'OP_LEFT': OP_LEFT, - 'OP_RIGHT': OP_RIGHT, + 'OP_SPLIT': OP_SPLIT, + 'OP_NUM2BIN': OP_NUM2BIN, + 'OP_BIN2NUM': OP_BIN2NUM, 'OP_SIZE': OP_SIZE, 'OP_INVERT': OP_INVERT, 'OP_AND': OP_AND,