Merge pull request #2824 from nspcc-dev/fix-load

core, vm: improve script invocation errors
This commit is contained in:
Roman Khimov 2022-11-28 22:10:21 +07:00 committed by GitHub
commit 4ca478dfc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View file

@ -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")

View file

@ -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,

View file

@ -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: