From 0ceae612c6533fc01311505b145ed1143ad586e1 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Mon, 28 Nov 2022 10:46:53 +0300 Subject: [PATCH] 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: