noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
884 stars 194 forks source link

`nargo debug` does not step properly any more #5703

Closed smanilov closed 2 months ago

smanilov commented 2 months ago

Aim

Before https://github.com/noir-lang/noir/pull/5696 was merged (i.e. syncing at commit https://github.com/noir-lang/noir/commit/2882eaeb176988bb3d216d091c0e239f5b80f276), nargo debug exhibited the following behavior:

$ cd test_programs/execution_success/inline_never_basic
$ nargo debug
[inline_never_basic] Starting debugger
At opcode 0:0 :: BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 }), Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(1))], q_c: 0 })], outputs: []
> next
At opcode 0:0.6 :: Const { destination: MemoryAddress(4), bit_size: Integer(U32), value: 0 }
At /home/stan/code/repos/noir-upstream/test_programs/execution_success/inline_never_basic/src/main.nr:1:33
  1 -> fn main(x: Field, y: pub Field) {
  2        basic_check(x, y);
  3    }
  4
  5    #[inline(never)]
  6    fn basic_check(x: Field, y: Field) {
  7        assert(x != y);
  8    ...
> quit
Debugger execution halted.
$ 

After the PR is merged (i.e. syncing at commit https://github.com/noir-lang/noir/commit/e4f7dbe63b55807b3ff0b4d6f47a8b7f847299fb), next seems to step through the whole program and complete the execution:

$ cd test_programs/execution_success/inline_never_basic
$ nargo debug
[inline_never_basic] Starting debugger
At opcode 0:0 :: BRILLIG CALL func 0: inputs: [Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(0))], q_c: 0 }), Single(Expression { mul_terms: [], linear_combinations: [(1, Witness(1))], q_c: 0 })], outputs: []
> next
Finished execution
> quit
Debugger execution halted.
$ 

Alternatively, one could step through the program using the into command in the debugger. However, the call stack is still not displayed when functions are entered, while this used to be the case before the problematic PR.

I suspect that the source-mapping information is somehow lost after the change.

Could you please roll-back the change?

Expected Behavior

  1. nargo debug can be used to step through the program line by line via the next command.
  2. The into command steps through instructions and displays the call stack when functions are entered.

Bug

  1. The next command just terminates the execution; possibly, because the debugger does not recognize that the program contains any source lines.
  2. The into command steps through instructions but does not display the call stack when functions are entered.

To Reproduce

  1. navigate to test_programs/execution_success/inline_never_basic
  2. run nargo debug
  3. issue a next command

The debugger completes the execution, rather than stepping to the first source line (this used to be the behavior before).

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

Blocker

Blocker Context

We are leveraging the debugger in a tracer that we've built in the blocksense-network/noir fork. Now that it's not working as before, our tracer is broken.

Nargo Version

nargo version = 0.33.0 noirc version = 0.33.0+e4f7dbe63b55807b3ff0b4d6f47a8b7f847299fb (git version hash: e4f7dbe63b55807b3ff0b4d6f47a8b7f847299fb, is dirty: false)

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

smanilov commented 2 months ago

FYI @vezenovm @jfecher

smanilov commented 2 months ago

I see the PR that's opened to fix this. Thanks for taking a look.