inkdevhub / drink

De-chained Ready-to-play ink! playground
Apache License 2.0
69 stars 15 forks source link

Add execution trace (export). #30

Closed deuszx closed 9 months ago

deuszx commented 1 year ago

Over the course of transaction execution, it will pass through various elements of the stack:

  1. Check accounts
  2. Pull contract data from storage
  3. Call method on a contract
  4. Read more data from storage (like Mapping::get)
  5. Call other contract (address, method, arguments)
  6. Call chain extension/call_runtime (other pallet).
  7. Mutate storage
  8. etc

We could log each of these steps of execution (let's call it execution trace) and export to a file for later interpretation/manipulation.

These files can serve multiple purposes:

  1. As "golden traces" (akin to protobuf's golden files) -- a reference execution, can be used to protect from regressions.
  2. If a certain execution trace is deemed invalid, these files can serve as failure persistence files.
  3. In the case of "unknown contracts" (contracts for which we do not hold metadata at the moment of trace collection), we can get ahold of these metadata files in the future and use it to retroactively "decode" the trace's step.
  4. As test setup: Executing up to n-th step and then running changed logic
deuszx commented 9 months ago

I think this can be closed. Now that the interception is possible the execution trace can be done on the "implementation" side.