-
Notifications
You must be signed in to change notification settings - Fork 329
feat(ssa): SSA CLI #9826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ssa): SSA CLI #9826
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20
.
Benchmark suite | Current: 254542e | Previous: 35b7c14 | Ratio |
---|---|---|---|
test_report_zkpassport_noir-ecdsa_ |
2 s |
1 s |
2 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
85680c0
to
d661814
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice tool!
6f21c42
to
c9c18dd
Compare
It just occurred to me that |
Description
Problem*
Resolves #8503
Summary*
Adds a
noir-ssa
CLI tool. There are two main sub-commands:transform
applies SSA pass(es) and prints the resulting SSAinterpret
takes a TOML formatted input file and runs it with the SSA interpreterBoth take SSA from a file or
stdin
, so it is possible to chain multiple commands with by piping the output, for example:We can specify multiple
--ssa-pass
options, which is a bit less verbose than piping, and saves re-parsing the SSA after each pass. The passes are executed in the order of appearance, unlike withnargo interpret
, where they are just a filter to tell at which point the SSA should be interpreted, while it goes through the whole pipeline.We can also use the
--show-ssa
and--show-ssa-pass
options to see the SSA along the way, but only the last state is printed tostdout
, so that it can be piped tointerpret
for example; the interim states go tostderr
.The inputs for the circuit are expected to be in JSON or TOML format, with the same syntax as the ABI values in a typical
Prover.toml
, but using the SSA variable IDs for parameter names. For example if we have this Noir function:and it's turned into this SSA:
then we can
interpret
it with the following inputs:The way it works is that we generate an artificial ABI from SSA, and use that ABI to parse the input file. (For this we are reusing some existing utilities that are a bit scattered around. There is already a ticket to move them: #8707).
The inputs can come from a file with
--input-path
, or for quick and simple cases it can be specified on the CLI using--input-toml
or--input-json
. When using--input-toml
, we can use;
to define multiple keys, likev0 = 1; v1 = [2,3]
.interpret
prints the output tostdout
, but not the SSA source. This could potentially be useful if we wanted to alternate transforming and interpreting, but it's probably an overkill. Easy to add later anyway.Additional Context
Follow up ideas
Interactive mode
For quickly trying out some SSA. Maybe it could ask for the SSA, then the TOML, which the user would copy-paste or type in.
Currently this works for example like this:
Render the CFG
We often use pen and paper to draw out a CFG to better follow the jumps. It would be great to visualise it with Mermaid for example.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.