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

Function gasExtCodeCopy

core/vm/gas_table.go:218–242  ·  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

216}
217
218func gasExtCodeCopy(gt configs.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
219 gas, err := memoryGasCost(mem, memorySize)
220 if err != nil {
221 return 0, err
222 }
223
224 var overflow bool
225 if gas, overflow = math.SafeAdd(gas, gt.ExtcodeCopy); overflow {
226 return 0, errGasUintOverflow
227 }
228
229 wordGas, overflow := bigUint64(stack.Back(3))
230 if overflow {
231 return 0, errGasUintOverflow
232 }
233
234 if wordGas, overflow = math.SafeMul(toWordSize(wordGas), configs.CopyGas); overflow {
235 return 0, errGasUintOverflow
236 }
237
238 if gas, overflow = math.SafeAdd(gas, wordGas); overflow {
239 return 0, errGasUintOverflow
240 }
241 return gas, nil
242}
243
244func gasMLoad(gt configs.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
245 var overflow bool

Callers

nothing calls this directly

Calls 4

memoryGasCostFunction · 0.85
bigUint64Function · 0.85
toWordSizeFunction · 0.85
BackMethod · 0.80

Tested by

no test coverage detected