From 0ceae612c6533fc01311505b145ed1143ad586e1 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 28 Nov 2022 10:46:53 +0300 Subject: [PATCH 1/2] vm: improve failed SYSCALL logging For better user experience. --- cli/vm/cli_test.go | 4 ++-- pkg/vm/vm.go | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cli/vm/cli_test.go b/cli/vm/cli_test.go index 0fdc20964..2b32b8f79 100644 --- a/cli/vm/cli_test.go +++ b/cli/vm/cli_test.go @@ -924,7 +924,7 @@ func TestRunWithHistoricState(t *testing.T) { e.checkNextLine(t, "READY: loaded 36 instructions") e.checkStack(t, []byte{1}) e.checkNextLine(t, "READY: loaded 36 instructions") - e.checkNextLineExact(t, "Error: at instruction 31 (SYSCALL): failed to invoke syscall 1381727586: called contract cd583ac7a1a4faef70d6e9f513bc988dde22f672 not found: key not found\n") + e.checkNextLineExact(t, "Error: at instruction 31 (SYSCALL): System.Contract.Call failed: called contract cd583ac7a1a4faef70d6e9f513bc988dde22f672 not found: key not found\n") } func TestEvents(t *testing.T) { @@ -1178,7 +1178,7 @@ func TestLoaddeployed(t *testing.T) { e.checkNextLine(t, "READY: loaded \\d+ instructions") e.checkStack(t, []byte{2}) e.checkNextLine(t, "READY: loaded \\d+ instructions") - e.checkError(t, errors.New("at instruction 63 (SYSCALL): failed to invoke syscall 837311890: insufficient amount of gas")) + e.checkError(t, errors.New("at instruction 63 (SYSCALL): System.Storage.Get failed: insufficient amount of gas")) e.checkNextLine(t, "READY: loaded \\d+ instructions") e.checkStack(t, []byte{2}) e.checkNextLine(t, "READY: loaded \\d+ instructions") diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index ef8c41351..e3944c72f 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -1462,7 +1462,11 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro } err := v.SyscallHandler(v, interopID) if err != nil { - panic(fmt.Sprintf("failed to invoke syscall %d: %s", interopID, err)) + iName, iErr := interopnames.FromID(interopID) + if iErr == nil { + panic(fmt.Sprintf("%s failed: %s", iName, err)) + } + panic(fmt.Sprintf("%d failed: %s", interopID, err)) } case opcode.RET: From 6d3cc0f7e72465ebe3cf2ca620e24bf64ffb792a Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 28 Nov 2022 11:44:24 +0300 Subject: [PATCH 2/2] core: extend error text for storage context in dynamic script --- pkg/core/interop/storage/basic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/core/interop/storage/basic.go b/pkg/core/interop/storage/basic.go index a3cd1db63..3029af183 100644 --- a/pkg/core/interop/storage/basic.go +++ b/pkg/core/interop/storage/basic.go @@ -70,7 +70,7 @@ func GetReadOnlyContext(ic *interop.Context) error { func getContextInternal(ic *interop.Context, isReadOnly bool) error { contract, err := ic.GetContract(ic.VM.GetCurrentScriptHash()) if err != nil { - return err + return fmt.Errorf("storage context can not be retrieved in dynamic scripts: %w", err) } sc := &Context{ ID: contract.ID,