Skip to content

The Builtin Actor Debugging Story #592

@vyzo

Description

@vyzo

The Debug Problem

It has become quite apparent, especially as we are getting closer to the nv16 upgrade, that we need a mechanism to debug builtin actors.

This goes beyond enabling the actor_debugging context option (which enables the debug syscall), as debug code has to be compiled in and will diverge from the mainline code, at the very least in gas (eg debug prints, assertions, possibly different code paths for testing and so on).

At the root of the problem we have two issues:

  • the debug code CID is different from the mainnet code CID.
  • the gas/execution of the debug code will produce different results, diverging from mainnet.

Debugging Strategy

Here we propose a strategy for resolving the issue in a way that supports our debugging needs, without forking from mainnet.

The strategy is two fold:

  • at the fvm side, support code redirects for dual execution.
  • at the builtin-actors side, provide a special mainnet debug bundle, with debugging features enabled.

Dual Code Execution

More specifically, we can provide a debug manifest at fvm instantiation.
Upon message execution time, we concurrently execute the mainnet code (for the result and gas) and the debug code, redirecting mainnet code to the debug code in the debug execution, which has actor_debugging enabled. The result of message execution will be the result of the mainnet code execution. The debug code will be executed for side effects, which can be observed through stdout/stderr or by collecting and side-returning the debug result/trace.

Debug Bundles

At the very least we need to enable tracing/debug for logs, through a build feature.
The same feature test can also be used to enable debug logic (assertions, experimental features and so on).
The bundle can either be built by the developer for testing, or be part of the release workflow matrix which would build a builtin-actors-mainnet-debug.car bundle for consumption by lotus.

Lotus Integration

This is the easiest part, as we could simply load the debug bundle in the blockstore and pass the manifest CID to the fvm when enabling debug. This is probably best done by using an environment variable.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions