Skip to content

Commit 6bad78e

Browse files
committed
Fix timeout handling on multi depth call (experimental)
1 parent b865ae5 commit 6bad78e

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎contract/vm.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const (
5454
checkFeeDelegationFn = "check_delegation"
5555
constructor = "constructor"
5656

57-
vmTimeoutErrMsg = "[Contract.LuaCallContract] call err: contract timeout"
57+
vmTimeoutErrMsg = "contract timeout of VmTimeoutError"
5858
)
5959

6060
var (
@@ -621,9 +621,9 @@ func (ce *executor) call(instLimit C.int, target *LState) C.int {
621621
ce.err = errors.New(errMsg)
622622
}
623623
}
624-
ctrLgr.Debug().Err(ce.err).Str(
624+
ctrLgr.Debug().Err(ce.err).Stringer(
625625
"contract",
626-
types.EncodeAddress(ce.ctx.curContract.contractId),
626+
types.LogAddr(ce.ctx.curContract.contractId),
627627
).Msg("contract is failed")
628628
if target != nil {
629629
if C.luaL_hasuncatchablerror(ce.L) != C.int(0) {

‎contract/vm_callback.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,13 @@ func luaCallContract(L *LState, service C.int, contractId *C.char, fname *C.char
343343
if ctx.traceFile != nil {
344344
_, _ = ctx.traceFile.WriteString(fmt.Sprintf("recovery snapshot: %d\n", seq))
345345
}
346-
return -1, C.CString("[Contract.LuaCallContract] call err: " + ce.err.Error())
346+
switch ceErr := ce.err.(type) {
347+
case *VmTimeoutError:
348+
return -1, C.CString(ceErr.Error())
349+
default:
350+
return -1, C.CString("[Contract.LuaCallContract] call err: " + ceErr.Error())
351+
352+
}
347353
}
348354

349355
if seq == 1 {

0 commit comments

Comments
 (0)