Skip to content

Commit

Permalink
check error when creating contract executor
Browse files Browse the repository at this point in the history
  • Loading branch information
kroggen committed Jun 1, 2024
1 parent 3217eff commit b8f67f7
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions contract/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,13 @@ func Call(
ce := newExecutor(contract, contractAddress, ctx, &ci, ctx.curContract.amount, false, false, contractState)
defer ce.close()

startTime := time.Now()
// execute the contract call
ce.call(callMaxInstLimit, nil)
vmExecTime := time.Now().Sub(startTime).Microseconds()
vmLogger.Trace().Int64("execµs", vmExecTime).Stringer("txHash", types.LogBase58(ce.ctx.txHash)).Msg("tx execute time in vm")
if ce.err == nil {
startTime := time.Now()
// execute the contract call
ce.call(callMaxInstLimit, nil)
vmExecTime := time.Now().Sub(startTime).Microseconds()
vmLogger.Trace().Int64("execµs", vmExecTime).Stringer("txHash", types.LogBase58(ce.ctx.txHash)).Msg("tx execute time in vm")
}

// check if there is an error
err = ce.err
Expand Down Expand Up @@ -975,8 +977,10 @@ func Create(
ce := newExecutor(contract, contractAddress, ctx, &ci, ctx.curContract.amount, true, false, contractState)
defer ce.close()

// call the constructor
ce.call(callMaxInstLimit, nil)
if err == nil {
// call the constructor
ce.call(callMaxInstLimit, nil)
}

// check if the call failed
err = ce.err
Expand Down Expand Up @@ -1103,7 +1107,9 @@ func Query(contractAddress []byte, bs *state.BlockState, cdb ChainAccessor, cont
}
}()

ce.call(queryMaxInstLimit, nil)
if err == nil {
ce.call(queryMaxInstLimit, nil)
}

return []byte(ce.jsonRet), ce.err
}
Expand Down Expand Up @@ -1177,7 +1183,9 @@ func CheckFeeDelegation(contractAddress []byte, bs *state.BlockState, bi *types.
}
}()

ce.call(queryMaxInstLimit, nil)
if err == nil {
ce.call(queryMaxInstLimit, nil)
}

if ce.err != nil {
return ce.err
Expand Down

0 comments on commit b8f67f7

Please sign in to comment.