Anoma NockVM error reporting

Anoma NockVM error reporting

The Anoma NockVM is used to interpret Nock code that’s submitted to Anoma. For
example:

  1. Nock computations via the /prove endpoint (used to compute transaction
    candidates)
  2. Transaction candidates submitted to the mempool
  3. Logic functions in Resources

An Anoma NockVM errors can occur when:

  1. The submitted Nock code is invalid (e.g it cannot be decoded)
  2. The interpreter reaches an error condition in Nock code
  3. A crash happens in a jet (i.e Elixir code)

The user only recieves feedback if a NockVM error occurs when calling /prove.
There’s currently no way to see errors that happen during logic function or
transaction candidate execution.

These errors are reported using the single error value :error with no
additional context.

This makes it hard for application authors to debug because it’s hard to
determine the cause of an error.

Ideas for error reporting

  1. Each :error value could have a string payload describing why the error
    occured. For example this could contain the name of the jet that failed if
    the error occured in a jet.

  2. Provide a mechanism for logging VM errors that occur in transaction
    candidates or logic functions that can be queried by the application author.
    Also making trace logs emitted by transaction candidates / logic functions
    would be useful here.

More long term ideas that we’ve discussed before:

  1. Provide an interface for injecting Juvix call-stack and source file/line
    number information into Nock terms so we can report a stack trace of the
    error to the user.
1 Like

We will be able to dump stack traces from the stateful VM (on error result, or interrupt) — the compiler will also be able to put Juvix stack trace information in by wrapping forms in hints (the hint’s semantic: push the hint value, evaluate the hinted subformula, pop the stack) when it’s emitting debug symbols. This is one of the things we need the stateful VM to do right (without further spaghettifying the already shaky interpreter).