Currently, the soft-fork system allows for new OPs that use a special format to be added to replace NOPs in a backwards-compatible way. It is also possible to create a hard-fork update by replacing NOPs with new OPs that do not follow the soft-fork convention for backwards compatibility. However, as it currently exists, there will never be more than 256 total OPs. This is likely more than enough, but it would be helpful in more ways than one to make a system for extended instruction sets available for hard-forks to utilize instead of overwriting NOPs, which could lead to unanticipated behaviors.
To ensure that hard-forks do not result in unanticipated behaviors in systems that lack the new OPs, I propose introducing 16 new OPs that invoke an extended instruction set (XIS) if it has been installed or otherwise raise a NotImplementedError
. These new OPs will be named OP_EXTENDED_0
through OP_EXTENDED_15
, with aliases X0
through X15
and byte codes xF0
through xFF
.
During compilation, when one of these X{n}
instructions is encountered, if the XIS has been registered, the compiler will invoke the registered compiler's parse_next
method instead of its own. If the XIS has not been registered, an error will be generated, and compilation will fail.
During execution, when one of the xF{n}
byte codes is encountered, if the XIS has been registered, the runtime will read the next byte as the XIS instruction and attempt to invoke that OP from the XIS. If the XIS has not been registered, or if the OP does not exist within it, an error will be generated, and execution will fail.
To ensure that there will always be enough NOPs available for soft-forks, XIS 0 will be populated with NOPs, and the soft-fork tools will need to be updated to enable use of this extended instruction set.
This will remove 16 NOPs from the base instruction set, but it will add 256 new NOPs, maintaining utility for soft-forks. However, documentation around this will have to change: specifically, the recommendation to start at xFF
with soft-forks will have to change to xEF
or possibly to use the new XIS.
This will also add 3840 possible OPs for language additions and modules.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too