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

Function gasCodeCopy

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

192}
193
194func gasCodeCopy(gt configs.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
195 gas, err := memoryGasCost(mem, memorySize)
196 if err != nil {
197 return 0, err
198 }
199
200 var overflow bool
201 if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow {
202 return 0, errGasUintOverflow
203 }
204
205 wordGas, overflow := bigUint64(stack.Back(2))
206 if overflow {
207 return 0, errGasUintOverflow
208 }
209 if wordGas, overflow = math.SafeMul(toWordSize(wordGas), configs.CopyGas); overflow {
210 return 0, errGasUintOverflow
211 }
212 if gas, overflow = math.SafeAdd(gas, wordGas); overflow {
213 return 0, errGasUintOverflow
214 }
215 return gas, nil
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)

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