feat: Refactor Logging to use Brillig foreign calls#1917
Conversation
|
Fixes #1925 |
Co-authored-by: jfecher <jake@aztecprotocol.com>
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
@TomAFrench I also need the AbiType though in order to convert an This PR is blocking for these issues: #1925 and #1953 that are caused by coverting arrays of structs to structs of arrays. Perhaps we can merge this in and revisit moving the Display to InputValue? |
|
If this is blocking for another issue, but the Display issue with this PR is blocking this one, we can split out the relevant change and merge only that. I'll leave the call to @TomAFrench whether Display is blocking this PR or not but it doesn't sound too major to me. |
jfecher
left a comment
There was a problem hiding this comment.
My issues are all solved. I still think passing along the json type data as an extra argument is a bit hacky but I suppose we can remove this once we add traits in Noir.
|
As far as updating the docs that result from this change, is it just that we are now able to log structs in addition to Fields, integers and arrays? |
|
Seems like so, @vezenovm could you confirm? |
|
@critesjosh yes you can now log structs, but also expressions now (such as |
Description
Reimplement logging in a more generic way uses Brillig foreign calls and AbiType for de/serialization
Problem*
Resolves #1615, #1910, #1925 and partial work towards #1911
Summary*
There is now a new logging function
As this matches the println used by the old SSA, some logic had to be adding to filter for the correct println function in the stdlib depending on whether the experimental ssa is activated.
During monomorphization of a function call we check whether we have an oracle for
println. We then serialize the AbiType to a string literal and attach it as the latest argument of the function.nargowho is executing the println oracles then know how to interpret these compiler attached arguments.The example program under
crates/nargo_cli/tests/test_data_ssa_refactor/debug_logs/src/main.nrwill give this output:The
enable_slicesflag was renamed toexperimental_ssaas it is needed in this PR.In order to avoid the struct serialization set by
aos_to_soain monomorphization I also added checks of theexperimental_ssaflag to monomorphization to avoid usingaos_to_soawhen we are compiling down to the new SSA pass.Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmton default settings.