Add a simplicity pset run command which outputs a trace of all jets called#32
Merged
apoelstra merged 2 commits intoBlockstreamResearch:masterfrom Dec 4, 2025
Merged
Conversation
We want to reuse this for "pset run".
Contributor
Author
9d14148 to
45fb439
Compare
Contributor
Author
|
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" "" |
…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.
45fb439 to
895cddd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This new command takes the same arguments as
simplicity pset finalizebut 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 '' ```There are many improvements we can make here but already I think this is pretty useful and worth slipping into the next release.