MCPcopy Create free account
hub / github.com/CPChain/chain / opCall

Function opCall

core/vm/instructions.go:668–695  ·  view source on GitHub ↗
(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack)

Source from the content-addressed store, hash-verified

666}
667
668func opCall(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
669 // Pop gas. The actual gas in in evm.callGasTemp.
670 evm.interpreter.intPool.put(stack.pop())
671 gas := evm.callGasTemp
672 // Pop other call parameters.
673 addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
674 toAddr := common.BigToAddress(addr)
675 value = math.U256(value)
676 // Get the arguments from the memory.
677 args := memory.Get(inOffset.Int64(), inSize.Int64())
678
679 if value.Sign() != 0 {
680 gas += configs.CallStipend
681 }
682 ret, returnGas, err := evm.Call(contract, toAddr, args, gas, value)
683 if err != nil {
684 stack.push(evm.interpreter.intPool.getZero())
685 } else {
686 stack.push(evm.interpreter.intPool.get().SetUint64(1))
687 }
688 if err == nil || err == errExecutionReverted {
689 memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
690 }
691 contract.Gas += returnGas
692
693 evm.interpreter.intPool.put(addr, value, inOffset, inSize, retOffset, retSize)
694 return ret, nil
695}
696
697func opCallCode(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
698 // Pop gas. The actual gas is in evm.callGasTemp.

Callers

nothing calls this directly

Calls 11

popMethod · 0.80
Int64Method · 0.80
getZeroMethod · 0.80
Uint64Method · 0.80
GetMethod · 0.65
CallMethod · 0.65
putMethod · 0.45
SignMethod · 0.45
pushMethod · 0.45
getMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected