CityOfZion / neo-storm

Smart contract framework for the NEO smart economy written in the Go programming language.
MIT License
38 stars 10 forks source link

Add more debugging info on testinvoke #56

Open aprasolova opened 5 years ago

aprasolova commented 5 years ago

Description of the issue

I'm trying to testinvoke a smart contract for working with storage from examples dir. When I run it I get "state": "FAULT, BREAK" result with no explanations why. It would be nice for invoker to write some trace on what have happened to help with SC debug.

Type

[x] feature request

My environment

Steps to reproduce

The code I run is

import (
    "github.com/CityOfZion/neo-storm/interop/storage"
)

func Main() interface{} {
    ctx := storage.GetContext()
        operation = "put"
        args = [1,2]
    if operation == "put" {
        if checkArgs(args, 2) {
            key := args[0].([]byte)
            value := args[1].([]byte)
            storage.Put(ctx, key, value)
            return key
        }
    }
    return false
}

func checkArgs(args []interface{}, length int) bool {
    if len(args) == length {
        return true
    }
    return false
}

Invoсation and result are


{
  "state": "FAULT, BREAK",
  "gas_consumed": "0.001",
  "script": "7061636b616765204e656f53746f726d546573740a0a696d706f727420280a09226769746875622e636f6d2f436974794f665a696f6e2f6e656f2d73746f726d2f696e7465726f702f73746f72616765220a290a0a66756e63204d61696e282920696e746572666163657b7d207b0a09637478203a3d2073746f726167652e476574436f6e7465787428290a20202020202020206f7065726174696f6e203d2022707574220a202020202020202061726773203d205b312c325d0a0a096966206f7065726174696f6e203d3d202270757422207b0a0909696620636865636b4172677328617267732c203229207b0a0909096b6579203a3d20617267735b305d2e285b5d62797465290a09090976616c7565203a3d20617267735b315d2e285b5d62797465290a09090973746f726167652e507574286374782c206b65792c2076616c7565290a09090972657475726e206b65790a09097d0a097d0a0a2f2a096966206f7065726174696f6e203d3d202267657422207b0a0909696620636865636b4172677328617267732c203129207b0a0909096b6579203a3d20617267735b305d2e285b5d62797465290a09090972657475726e2073746f726167652e476574286374782c206b6579290a09097d0a097d0a0a096966206f7065726174696f6e203d3d202264656c65746522207b0a09096b6579203a3d20617267735b305d2e285b5d62797465290a090973746f726167652e44656c657465286374782c206b6579290a090972657475726e20747275650a097d2a2f0a0972657475726e2066616c73650a7d0a0a66756e6320636865636b417267732861726773205b5d696e746572666163657b7d2c206c656e67746820696e742920626f6f6c207b0a096966206c656e286172677329203d3d206c656e677468207b0a090972657475726e20747275650a097d0a0a0972657475726e2066616c73650a7d0a0a",
  "Stack": []
}```
Nice to have here some report on execution details, events log, storage operations report to let me know what step in my SC is erroneous, like it is in neo-python vm.
anthdm commented 5 years ago

@aprasolova This will be possible once we operate on our internal VM. This should not be far away as a milestone.