Skip to content

feat: add cli to output for graphviz#344

Open
stringhandler wants to merge 1 commit intoBlockstreamResearch:masterfrom
stringhandler:feat/add-graphviz-output
Open

feat: add cli to output for graphviz#344
stringhandler wants to merge 1 commit intoBlockstreamResearch:masterfrom
stringhandler:feat/add-graphviz-output

Conversation

@stringhandler
Copy link

@stringhandler stringhandler commented Feb 11, 2026

Add a CLI command for outputting a binary program to .dot language, AKA graphviz.

The main reason is to easily compare programs created from SimplicityHL.

For example:
cargo run -- graph 4Am0vN8zP3zuXdYq0DFK50OFg4FN/m2W5xRsrPlArYt8C8wCEChBieAgWBxRsYCAawA=

will output

digraph G {
ordering="out";
  node0[label="unit"];
  node1[label="word(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)"];
  node2[label="comp"];
  node2->node0;
  node2->node1;
  node3[label="iden"];
  node4[label="pair"];
  node4->node2;
  node4->node3;
  node5[label="iden"];
  node6[label="take"];
  node6->node5;
  node7[label="unit"];
  node8[label="jet(sig_all_hash)"];
  node9[label="comp"];
  node9->node7;
  node9->node8;
  node10[label="pair"];
  node10->node6;
  node10->node9;
  node11[label="witness"];
  node12[label="pair"];
  node12->node10;
  node12->node11;
  node13[label="jet(bip_0340_verify)"];
  node14[label="comp"];
  node14->node12;
  node14->node13;
  node15[label="comp"];
  node15->node4;
  node15->node14;
}

@stringhandler stringhandler force-pushed the feat/add-graphviz-output branch from 98e05a7 to cac856d Compare February 11, 2026 15:23
@stringhandler
Copy link
Author

It seems that Github has built in support for mermaid diagrams, so I might add an option to export to .dot or .mermaid

flowchart TD
    node0["unit"]
    node1["word(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)"]
    node2["comp"]
    node3["iden"]
    node4["pair"]
    node5["iden"]
    node6["take"]
    node7["unit"]
    node8["jet(sig_all_hash)"]
    node9["comp"]
    node10["pair"]
    node11["witness"]
    node12["pair"]
    node13["jet(bip_0340_verify)"]
    node14["comp"]
    node15["comp"]

    node2 --> node0
    node2 --> node1

    node4 --> node2
    node4 --> node3

    node6 --> node5

    node9 --> node7
    node9 --> node8

    node10 --> node6
    node10 --> node9

    node12 --> node10
    node12 --> node11

    node14 --> node12
    node14 --> node13

    node15 --> node4
    node15 --> node14

Loading

@stringhandler
Copy link
Author

The actual command also might be better suited for hal-simplicity. Happy to move it there if need be.

@stringhandler stringhandler marked this pull request as ready for review February 11, 2026 15:50
@delta1
Copy link
Contributor

delta1 commented Feb 13, 2026

Nice one @stringhandler , I do think this fits better in hal-simplicity

@delta1
Copy link
Contributor

delta1 commented Feb 13, 2026

Although on second thought it does seem fine in the CLI here 🤷

@stringhandler
Copy link
Author

Ok, agreed. I'll leave the logic here, since it is the same place as the other DisplayExpr trait, but move the CLI logic to hal

@apoelstra
Copy link
Collaborator

CI breakage looks unrelated (seems we need to update the pins in .github/workflows/fuzz.yml because gitrandom broke us in a patch release) (arguably we should move all this over to rust-bitcoin-maintainer-tools, but that's a much bigger project).

Concept ACK adding this to simpcli for now, but yes, this CLI tool is basically abandoned and we are moving its functionality to hal-simplicity.

@apoelstra
Copy link
Collaborator

apoelstra commented Feb 14, 2026

Super cool that we can just inline the logic and don't need a dependency or anything!

I am a liiitle concerned about the exponential blowup inherent to this, but I think it's okay for now. The CLI tool may want to stick a guard on it and refuse to output more than 2^24 nodes or something without an extra --force flag.

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.

3 participants