I was suggesting not changing any semantics at all; only changing the acceptable range of inputs to existing opcodes. If OP_MUL
or a variant thereof is added, I can see why detecting/dealing with overflows becomes an issue that the existing interface doesn’t deal well with.
If the different semantics are actually desirable, then I agree it shouldn’t reuse the existing opcodes. Even if so, I don’t see the benefit of introducing a different encoding.
Ok, I’ll accept that the variable-length approach complicates things a bit, but I also think having two different encodings is even worse. All things being equal, I prefer little-endian over big-endian (EDIT: two’s complement over sign-magnitude), but again, two encodings is worse than one.
It’s a wrapper around int64_t
with serialization, deserialization, and arithmetic operations that assert on overflow. I think you’d want to add overflow-detecting versions for your use, but otherwise it already does everything. I don’t think there would be a need to touch any of the existing functions/operators on CScriptNum
.
There is a restriction on the input length when converting a Script stack element to a CScriptNum
; my suggesting was to just relax that restriction from 4 bytes to 8 bytes when in 64-bit mode (whether that’s through an OP_SUCCESSx
, through a leaf version, or through a separate opcode). Note that OP_CHECKLOCKTIMEVERIFY
also uses CScriptNum
, but permits arguments up to 5 bytes rather than 4.
Fair point. So far, I have seen few use cases for integer values that are script inputs, but if you envision that changing, that would be a point in favor of a strict encoding (that could still be minimally-encoded integers in a variable-length regine, which is effectively already a policy rule).
Yeah, the OP_n
opcodes, plus direct pushes of integer encodings (e.g. the stack element for encoding the number 20 has no OP_n
, but you can push the 0x14 byte using a direct push instruction). Duplicating all the OP_n
opcodes seems like a pain, so a conversion opcode after the literal would make more sense. Alternatively, don’t introduce a separate encoding, so the semantics of OP_n
remains the same in both worlds.
It cannot. There are at least also:
- The position of the last executed
OP_CODESEPARATOR
, as it affects the sighashes. - The if/then/else conditional stack (which branches are we in)
- In tapscript, the remaining checksig budget
It’s certainly an increase; I don’t think it is dramatic at all. But fair enough, I’m convinced that a separate leaf version is cleaner than an OP_ENABLE64BIT
here.