Couldn't we add opcodes contexts via the script version?

By context I mean an opcode that loads a 1 to N byte map rewriting the mapping from opcode number to what instruction that number signifies. This should let you have an infinite number of instructions. You could change the context multiple times in a script as a cost of only two or three bytes.



On Mon, Nov 18, 2024, 1:36 PM Brandon Black <freedom@reardencode.com> wrote:
Hi Weikeng, thanks for your thoughts on this!

> We can, however, solve that by allowing multi-byte opcodes.
>
> Say, for example, we can have:
>     OP_OP { 0x1521 }
> which will set the current opcode to be the one with the assigned number
> 0x1521.
>
> Another idea is maybe OP_OP takes a stack element as the opcode.
>     { 0x1521 } OP_OP

Another option that works for many cases is to have opcode families
where an argument is augmented with flags to determine the behavior. We
can consider this to already be the case for OP_CHECKSIG* where the
signature determines the behavior of the hashing portion of the opcode.

This is also how OP_CHECKTEMPLATEVERIFY is designed, and how
OP_CHECKSIGFROMSTACKVERIFY as currently spec'd in the PR is designed.
CTV and CSFSV only constrain 32-byte first arguments, but not other
lengths leaving open extensions using any other length, including using
other lengths of either opcode as OP_OP, or as variants on CTV and CSFSV
respectively.

The benefit of this approach is that it doesn't "waste" the length byte
only to specify the opcode behavior, but enables it to do double duty as
specifying the total length of the first argument including both flags
and data.

Best,

--Brandon

--
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/Zzt2OCE6Aj9H3DiY%40console.

--
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/CAEM%3Dy%2BVpeEwqWtXqs%2BRpOFrO%3DWGzbSkPEEqBqBxc-87Z4ruh2g%40mail.gmail.com.