Skip to content

Conversation

@apoelstra
Copy link
Contributor

This new command takes the same arguments as simplicity pset finalize but rather than finalizing the program it just executes it and returns a list of every jet that was executed along with some information. For example:

Example ``` cargo -q run -- simplicity pset run cHNldP8BAgQCAAAAAQMEAAAAAAEEAQEBBQECAfsEAgAAAAABAU4BSZqBhUX2uuOfwDtjfypOHmTlkMrBvDpvbXGqRENlTBQBAAAAAAABhqAAIlEgEBP/7knTh8NkfGQ1WN73z/IUVFFdZMaUebdBwr9DdrUBBwABCAEAAQ4gOIKIm4JAzV1Qi/FY8gT6HkHNhGHwXel8qKt9YAFIxgYBDwQAAAAAARAE/////yIVvlCSm3TBoElUt4tLYDXpel4HiloPKOyW1Ue/7prOgDrAIeUtAzeCiTmiGur4R+tWfhRNSHWbutmb1uWBjYqAYRr/vgEXIFCSm3TBoElUt4tLYDXpel4HiloPKOyW1Ue/7prOgDrAARggl54QEIIUw/dfOs4NSPjkr+n6aw5ddh46EhPYpQynHVMAAQMIPIYBAAAAAAAH/ARwc2V0AiBJmoGFRfa645/AO2N/Kk4eZOWQysG8Om9tcapEQ2VMFAEEFgAUtYwiFR9LoVniJVdnRyrIkTfoGDAAAQMIZAAAAAAAAAAH/ARwc2V0AiBJmoGFRfa645/AO2N/Kk4eZOWQysG8Om9tcapEQ2VMFAEEAAA= 0 5HJ+AEdxCCEChNpUJKbdMGgSVS3i0tgNel6XgeKWg8o7JbVR7/ums6AOsAEIFCDDQ4VdxGCEChOrIEIFCDE2KiQAgWDVYCECg2o3CTjhYNVyBCBQbgerEEIFBuJk/Cgj4cRghCRQzohnOQs8/+3xpn819ObmnDkhDQn925GJoUwiWnfmwmLhcXAoGYW1m3QCMAgTgJ+QAIBwYDhgHEwHGIHG4HIEDkOA '' ```
{
  "success": true,
  "jets": [
    {
      "jet": "script_cmr",
      "source_ty": "1",
      "target_ty": "2^256",
      "success": true,
      "input_hex": "",
      "output_hex": "e52d0337828939a21aeaf847eb567e144d48759bbad99bd6e5818d8a80611aff"
    },
    {
      "jet": "build_tapleaf_simplicity",
      "source_ty": "2^256",
      "target_ty": "2^256",
      "success": true,
      "input_hex": "e52d0337828939a21aeaf847eb567e144d48759bbad99bd6e5818d8a80611aff",
      "output_hex": "979e10108214c3f75f3ace0d48f8e4afe9fa6b0e5d761e3a1213d8a50ca71d53"
    },
    {
      "jet": "build_taptweak",
      "source_ty": "2^512",
      "target_ty": "2^256",
      "success": true,
      "input_hex": "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0979e10108214c3f75f3ace0d48f8e4afe9fa6b0e5d761e3a1213d8a50ca71d53",
      "output_hex": "1013ffee49d387c3647c643558def7cff21454515d64c69479b741c2bf4376b5"
    },
    {
      "jet": "sha_256_ctx_8_init",
      "source_ty": "1",
      "target_ty": "(2^256? × (2^128? × (2^64? × (2^32? × (2^16? × 2^8?))))) × (2^64 × 2^256)",
      "success": true,
      "input_hex": "",
      "output_hex": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19"
    },
    {
      "jet": "sha_256_ctx_8_add_2",
      "source_ty": "((2^256? × (2^128? × (2^64? × (2^32? × (2^16? × 2^8?))))) × (2^64 × 2^256)) × 2^16",
      "target_ty": "(2^256? × (2^128? × (2^64? × (2^32? × (2^16? × 2^8?))))) × (2^64 × 2^256)",
      "success": true,
      "input_hex": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd195120",
      "output_hex": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a2400000000000000000006a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19"
    },
    {
      "jet": "sha_256_ctx_8_add_32",
      "source_ty": "((2^256? × (2^128? × (2^64? × (2^32? × (2^16? × 2^8?))))) × (2^64 × 2^256)) × 2^256",
      "target_ty": "(2^256? × (2^128? × (2^64? × (2^32? × (2^16? × 2^8?))))) × (2^64 × 2^256)",
      "success": true,
      "input_hex": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a2400000000000000000006a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd191013ffee49d387c3647c643558def7cff21454515d64c69479b741c2bf4376b5",
      "output_hex": "2a2402027ffdc93a70f86c8f8c86ab1bdef9fe428a8a2bac98d28f36e83857e86000000000000000000000000000000000000000000000000000000002ed6a0000000000000000006a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19"
    },
    {
      "jet": "sha_256_ctx_8_finalize",
      "source_ty": "(2^256? × (2^128? × (2^64? × (2^32? × (2^16? × 2^8?))))) × (2^64 × 2^256)",
      "target_ty": "2^256",
      "success": true,
      "input_hex": "2a2402027ffdc93a70f86c8f8c86ab1bdef9fe428a8a2bac98d28f36e83857e86000000000000000000000000000000000000000000000000000000002ed6a0000000000000000006a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19",
      "output_hex": "d4ebf6dbe687ff523f80a8962c6d121850057cdaf789452996067a5cc7dcea9e"
    },
    {
      "jet": "current_index",
      "source_ty": "1",
      "target_ty": "2^32",
      "success": true,
      "input_hex": "",
      "output_hex": "0000000000000000"
    },
    {
      "jet": "input_script_hash",
      "source_ty": "2^32",
      "target_ty": "2^256?",
      "success": true,
      "input_hex": "0000000000000000",
      "output_hex": "0000000000000001d4ebf6dbe687ff523f80a8962c6d121850057cdaf789452996067a5cc7dcea9e"
    },
    {
      "jet": "eq_256",
      "source_ty": "2^512",
      "target_ty": "2",
      "success": true,
      "input_hex": "d4ebf6dbe687ff523f80a8962c6d121850057cdaf789452996067a5cc7dcea9ed4ebf6dbe687ff523f80a8962c6d121850057cdaf789452996067a5cc7dcea9e",
      "output_hex": "0000000000000001",
      "equality_check": [
        "d4ebf6dbe687ff523f80a8962c6d121850057cdaf789452996067a5cc7dcea9e",
        "d4ebf6dbe687ff523f80a8962c6d121850057cdaf789452996067a5cc7dcea9e"
      ]
    },
    {
      "jet": "verify",
      "source_ty": "2",
      "target_ty": "1",
      "success": true,
      "input_hex": "0000000000000001",
      "output_hex": ""
    }
  ]
}

There are many improvements we can make here but already I think this is pretty useful and worth slipping into the next release.

We want to reuse this for "pset run".
@apoelstra
Copy link
Contributor Author

cc @delta1 @canndrew

@apoelstra
Copy link
Contributor Author

apoelstra commented Dec 3, 2025

Oh, and I'm using this script locally to test a "no witness program" which is indifferent to its input amount/asset:

#!/bin/sh

PROG64="$1"

INPUT_ADDR=$(cargo -q run -- simplicity info "$PROG64" | jq -r .liquid_address_unconf)
INPUT_CMR=$(cargo -q run -- simplicity info "$PROG64" | jq -r .cmr)
INPUT_SPK=$(cargo -q run -- address inspect "$INPUT_ADDR" | jq -r '.script_pub_key | .hex')

# Create a dummy PSBT
PSET_JSON=$(cargo -q run -- simplicity pset create  '[ { "txid": "06c64801607daba87ce95df06184cd411efa04f258f18b505dcd40829b888238", "vout": 0 } ]' '[ { "tex1qkkxzy9glfws4nc392an5w2kgjym7sxpshuwkjy": 0.00099900 }, { "fee": 0.00000100 } ]' | jq -r .pset)

PSET_JSON=$(cargo -q run -- simplicity pset update-input "$PSET_JSON" 0 --input-utxo "$INPUT_SPK:144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49:0.00100000" -c "$INPUT_CMR" -p 50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0 | jq -r .pset)

echo "Program: $PROG64"
echo "SPK: $INPUT_SPK"
echo "CMR: $INPUT_CMR"

set -x
cargo -q run -- simplicity pset run "$PSET_JSON" 0 "$PROG64" ""

Copy link
Contributor Author

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 45fb439 successfully ran local tests

…and outputs

This is a bit of a hacky and incomplete implementation but it's already very
useful so I think we should ship it. It runs through a program and outputs
information about each jet that it hits. It special-cases the equality jets
and also splits up the input so you can see which values it's comparing.

It is not encoding input/output data correctly if the data length isn't a
multiple of 8 (or 64 actually); it just takes the raw words from the bit
machine and outputs them. It also doesn't attempt to parse values or do
any other interpretation, except for the equality checks (and it doesn't
do eq_1 or eq_2 since those would require parsing out the nybbles rather
than just splitting the hex string).

It also doesn't understand the `dbg!` construction although this looks
like it will not be too hard to add.

Should definitely extend and better-document the ExecTracer trait upstream.
But for now this is already pretty useful.
Copy link
Contributor

@delta1 delta1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 895cddd

Ran tests locally

@apoelstra apoelstra merged commit 9d60d1b into BlockstreamResearch:master Dec 4, 2025
11 checks passed
@apoelstra apoelstra deleted the 2025-12/pset-run branch December 4, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants