3

Since the earliest public release of Bitcoin, OP_RESERVED, OP_RESERVED1, and OP_RESERVED2 have been defined at 0x50 (80), 0x89 (137), and 0x8a (138), respectively.

Why?

The intended purpose of all the other now-disabled opcodes seem to be well documented, but do we have any record or explanation for why the OP_RESERVED{1,2} opcodes were assigned at their current locations?

OP_RESERVED seems pretty clearly placed to allow OP_1 (0x51, 81) through OP_16 (0x60, 96) to match each pushed number 1-to-1 with the second half of the byte (such that 0x515253 is easily read as OP_1 OP_2 OP_3). It may also be reserved to ensure users writing raw contracts don't accidentally assume 0x50 is either OP_0 (0x00) or OP_1NEGATE (0x4f, 79), which might be easily confused because 0x80 is basically a negative sign in the Script Number encoding. (Any other ideas as to why Satoshi didn't fill in OP_RESERVED?)

For OP_RESERVED1 and OP_RESERVED2, the reasoning seems less obvious.

In the oldest commit they are listed under // bit logic, a set of 8 opcodes which begins at 0x83 (131) and continue through OP_RESERVED2 (0x8a, 138).

These don't seem to fall on any particularly special codepoints, and neither of the preceding or following opcode "groups" begin or end at any obviously special codepoints.

Is there something unusual about 0x89/137 and 0x8a/138 for which Satoshi might have reserved these codepoints?

Is there some other instruction set which reserves them (or where reserving them makes the "Bitcoin instruction set" consistent with that instruction set)?

4

Since the earliest public release of Bitcoin, OP_RESERVED, OP_RESERVED1, and OP_RESERVED2 have been defined at 0x50 (80), 0x89 (137), and 0x8a (138), respectively.

I doubt there's any known reason for them to exist. The script engine in Bitcoin obviously underwent a lot of changes during development and in the year following; a good portion of all the opcodes were completely rewritten, the behaviour of OP_FALSE was inverted, OP_CODESEPERATOR was effectively removed by execution changes, and so forth. There's many remnants of those changes and removals, and many of the opcodes have non-obvious quirks about how they are handled as a result.

It's worth remembering that the original releases of Bitcoin had > 8 bit opcodes at least partially implemented, and they were removed in the following year, so some of the space was reserved for the byte indicating their extension.

Is there some other instruction set which reserves them (or where reserving them makes the "Bitcoin instruction set" consistent with that instruction set)?

Bitcoin script's instruction set seems to be influenced by a research paper from the early 2000s that describes "security forth", but the copies of this online seem to be well and truly rotted. Notably, the order of the operators is the same and it has matching oddities such as OP_2OVER and OP_3DUP, but these is shared by a number of other similar languages from the time as well.

3
  • Thanks for the info, I'd never found a close match for the instruction set! Do you have any reference or other information about that research paper? Do you know what the title was, or do you know where it might have been published? Apr 27 at 19:41
  • 2
    I don’t recall anything other than the phrase “security forth”, it was just in a PDF on a university website that I saw a decade ago.
    – Claris
    Apr 27 at 19:57
  • Thanks for the tip! I'll mark this as the solution since it seems most likely so far. I also started a separate question to attempt to locate that research paper: bitcoin.stackexchange.com/questions/105805/… Apr 27 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.