Neo Global Development (NGD) Seattle has released a refreshed version of its Neo Smart Contract Debugger for Neo3 Preview3, bringing with it the first completed implementation of time travel debugging support. The new debugger version also includes support for exception breakpoints, making use of the recent addition of try/catch exception handling support in Neo3’s VM.
This new functionality for Neo3 is intended to help make smart contracts behave more like traditional applications that can recover from unexpected behavior. In the default mode, breakpoints are triggered by uncaught exceptions, but it can also be changed to break on caught exceptions instead.
Accompanying the debugger update is a refresh to the Preview3 version of Neo Express, which adds in the ability for contract execution traces to be captured and saved from neo-express blockchain instances.
First introduced at Consensus: Distributed in May, time travel debugging is a technique that allows developers to rewind and replay code execution in order to observe the steps leading to a bug. This is intended to make it much easier to understand the context in which a bug arises, and can considerably reduce the amount of time spent attempting to reproduce faults.
This form of debugging is achieved through the use of trace capture. Traces can be compared to a recording of a contract execution, which alongside the compiled contract and debug info files enable the ability to step back through the steps of an execution or run it in reverse.
Currently only transactions run with the Application trigger are supported, with Verification mode to be supported in a future debugger version. All other functionality, such as variable inspection and the disassembler view are available for both trace debugging and traditional contract debugging.
Although Neo Express is the first tool capable of trace capture, in the future plugins will also be released for node clients to allow execution traces to be captured from all networks, including MainNet and TestNet. This will allow developers to debug contracts in production environments where traditional debugging would not ordinarily be possible.
For example, a developer could run a Neo3 TestNet node and set it to capture all the traces from a contract they have deployed. If one of the invocations resulted in an unexpected failure, the trace could be examined more closely in the VS Code debugger in order to identify and correct the bug. Likewise, the technique could be used to conduct a post-mortem on bugs that occur in MainNet contracts, helping narrow down a potential resolution.
A trace debugging demo has been provided alongside the release, showing users how to use the new functionality with included trace files, neo-express checkpoints, and step-by-step instructions.
About The Author: Brett Rhodes
Brett is a blockchain enthusiast and freelance writer who originally began producing content for the gaming & eSports industries. Now he spends most of his time contributing in the Neo ecosystem.
More posts by Brett Rhodes