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

Function gasCallCode

core/vm/gas_table.go:348–370  ·  view source on GitHub ↗
(gt configs.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64)

Source from the content-addressed store, hash-verified

346}
347
348func gasCallCode(gt configs.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
349 gas := gt.Calls
350 if stack.Back(2).Sign() != 0 {
351 gas += configs.CallValueTransferGas
352 }
353 memoryGas, err := memoryGasCost(mem, memorySize)
354 if err != nil {
355 return 0, err
356 }
357 var overflow bool
358 if gas, overflow = math.SafeAdd(gas, memoryGas); overflow {
359 return 0, errGasUintOverflow
360 }
361
362 evm.callGasTemp, err = callGas(gt, contract.Gas, gas, stack.Back(0))
363 if err != nil {
364 return 0, err
365 }
366 if gas, overflow = math.SafeAdd(gas, evm.callGasTemp); overflow {
367 return 0, errGasUintOverflow
368 }
369 return gas, nil
370}
371
372func gasReturn(gt configs.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
373 return memoryGasCost(mem, memorySize)

Callers

nothing calls this directly

Calls 4

memoryGasCostFunction · 0.85
callGasFunction · 0.85
BackMethod · 0.80
SignMethod · 0.45

Tested by

no test coverage detected