feat: add output op_return get_bytes jets#339
Conversation
Introduce OP_PUSHBYTES_1/2/4/8/16/32/64 variants for null-data push opcodes. Unlike OP_IMMEDIATE, these variants store the raw pushed bytes inline in opcode.data alongside the SHA-256 hash, allowing jets to access actual data for fixed-size pushes (1, 2, 4, 8, 16, 32, 64 bytes). parseNullData now maps byte-count pushes of those specific sizes to the corresponding OP_PUSHBYTES_* code; output_null_datum encodes them as OP_IMMEDIATE for wire compatibility.
|
We first need to develop some sort of versioning mechanism so that the Simplicity interpreter knows whether these jets are active or not. Directly enabling them like this would hardfork the Liquid network. |
|
Yeah, there is the version number in the tapleaf, but we may want to be sparing with version upgrades. Do you think we need a version for BlockstreamResearch/rust-simplicity#345 ? |
|
I did add this issue to discuss it #341, mainly to catalogue my thoughts, but we can brainstorm it there maybe. |
In the 8 years Liquid has been deployed, we have literally never used any of the multiple script upgrade mechanisms that exist, except when we deployed Taproot. If we find ourselves running low on version numbers there are lots of alternate schemes we could deploy, but I'm skeptical that we will.
No. That is just fixing rust-simplicity to support functionality that was already deployed. |
|
I've added stringhandler#1 as a possibly versioning solution. I'll give it some more thought though. |
Adds
output_null_get_bytes_{1,2,4,8,16,32,64}jets for reading raw byte data from null-data (OP_RETURN) outputs, and the supportingOP_PUSHBYTES_*opcode variants that make them possible.Background
Previously,
output_null_datumcould identify a push in a null-data script and return its SHA-256 hash, but there was no way for a Simplicity program to access the actual bytes. This matters for null-data outputs that carry small, fixed-size payloads (nonces, amounts, asset IDs, public keys, signatures) that a contract needs to inspect directly.New jets (
C/elements/elementsJets.c)simplicity_output_null_get_bytes_{1,2,4,8,16,32,64}- each takes an output index and a push index and returnsS (S TWO^N): nothing if the output isn't null-data, nothing if the indexed push isn't exactly N bytes, or the raw bytes.