-
Notifications
You must be signed in to change notification settings - Fork 0
feat(debugger): debug tests functions (#5208) #8
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(debugger): debug tests functions (#5208) #8
Conversation
|
Thank you for your contribution to the Noir language. Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch. Thanks for your understanding. |
the repl communicates with the debugger through mpsc channels
- clean brillig_solver, witness_stack and acvm_stack fields as well
inspired in Gus' old comments
re-accomodate debug_cmd to make use of it
mverzilli
left a comment
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.
Left some suggestions to enhance the docs
|
|
||
| _String, optional._ | ||
|
|
||
| JSON RPC url to solve oracle calls |
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.
| JSON RPC url to solve oracle calls | |
| JSON RPC URL to solve oracle calls. |
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.
Let's add a little more explanation, it is true that this sets the target for oracle calls, but from the perspective of users/newcomers it is kind of obscure. I'd expand telling that this lets you interact with a TXE, which enables debugging tests that use aztec-contracts
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.
Mmmh, I'm not sure about that. I thought about it when writing this, but then I changed my mind because these docs are about noir-lang, not about aztec framework.
I definitively think that there should be a "How to debug aztec contracts tests" guide, but I think that that guide should live in aztec's docs, not in noir's.
The dbg_session read buffer was not being able to retain all the lines produced after all the commands sent without reading the results
* Also fix test to support REPL prompt to be rendered at the beginning of debugger output (since now debugger runs in a different thread)
mverzilli
left a comment
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.
Looking great!
| let num_steps = 16; | ||
| for _ in 1..=num_steps { | ||
| let expected_lines_by_command: Vec<VecDeque<&str>> = vec![ | ||
| VecDeque::from(["fn main(x: Field, y: pub Field) {"]), |
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.
Nit (only if it doesn't generate a borrow checker headache, which I can't tell without trying): maybe refactor to get the Vec<VecDeque<&str>> from a string array of arrays, to reduce the "visual noise" in this.
It could be a good idea to add a trim somewhere so the test isn't sensitive to white space, which should also help make it easier to maintain this test and/or add new ones
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.
This maybe a good use case for a macro?
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.
I changed it to VecDeque becuase it has the pop_front method that consumes the first element from the vector
I got to it by reading the Vec::pop doc that says
/// If you'd like to pop the first element, consider using
/// [VecDeque::pop_front] instead.
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.
On the other hand, I removed the useless whitespace on the expected lines and replaced the trim_start() with a trim() on the other branch (and cherry-picked it here for later)
104be72
into
feat/5208-debug-tests-2025
Description
Expand debugger funcionality to support debugging test functions and configure an external oracle-resolver url.
This will allow to debug contract tests using the TXE as oracle resolver
Problem*
Resolves noir-lang#5208
Summary*
Debug testcodelens request. Related vscode-noir PR (feat(codelens): add debug test codelens vscode-noir#3))Additional Context
Debugger changes
test-nameandoracle-resolverarg options to debugger (both repl and dap interfaces)DebugForeignCallExecutorto support setting aresolver_urlmainfunctionDebugExecutionResultenum that represents the possible outcomes of debugging a programshould_fail)ReplDebuggerintoAsyncReplDebugger_cmdto the debugger mod, and from thereplto thecontext- like creating theBn254BlackBoxSolveror restarting the debugging contextDebugCommandAPIenumModifications in
nargomoduleOpcodeResolutionErrorto anExecutionErrorfromnargo::ops::executeinto a new functionnargo::errors::execution_error_from. Use this new function indebugger::contextandnargo::ops::executenargo::ops::debugmodule. Extract reused debug functions into it.The moved functions are mostly about knowing how to compile or prepare the package for compiling for debugging. This also avoids generating inter-dependencies between
debug_cmdanddap_cmdcheck_crate_and_report_errorsfromcheck_cmdtonargo::opssince it was being used in different commandsnargo::ops::testfunctions publicTestResult::newfunction to be able to construct one from dapRPCForeignCallExecutorto apply workaround for RPCForeignCallExecutor fails on long delays between requests noir-lang/noir#7463Modifications in
noirc_frontend::debugmoduleDebugInstrumenterto instrument contract functions in addition to top-level functionsObservations
Things to improve down the road
repland thedapare keeping track of thelast_result. Perhaps this is something that could be moved to the contextDocumentation*
Check one:
PR Checklist*
cargo fmton default settings.