MCPcopy Create free account
hub / github.com/Jesserc/gevm / extcodecopy

Function extcodecopy

gevm/instructions.go:397–414  ·  view source on GitHub ↗

This is a mocked version and doesn't behave exactly as it would in a real EVM. extcodecopy copies a zero-length mocked byte slice to memory.

(evm *EVM)

Source from the content-addressed store, hash-verified

395//
396// extcodecopy copies a zero-length mocked byte slice to memory.
397func extcodecopy(evm *EVM) {
398 _ = evm.Stack.Pop() // Pop external address off the stack
399 destMemOffsetU256 := evm.Stack.Pop()
400 _ = evm.Stack.Pop() // Pop offset of the external code to copy. This isn't used.
401 sizeU256 := evm.Stack.Pop()
402
403 destMemOffset, size := destMemOffsetU256.Uint64(), sizeU256.Uint64()
404
405 extCodeCopy := []byte{} // mocked (no external code)
406 memExpansionCost := evm.Memory.Store(destMemOffset, extCodeCopy) // extCode has zero length
407
408 wordSize := toWordSize(size)
409 dynamicGas := 3*wordSize + memExpansionCost + 2600 // '2600' here represents "address access cost" and can be 100 for warm access, but we are assuming cold access since this is a mocked version.
410
411 evm.PC++
412 evm.deductGas(dynamicGas)
413 dgMap[EXTCODECOPY] = dynamicGas
414}
415
416// returndatasize pushes a mocked (zero-value) length of the return data onto the stack.
417func returndatasize(evm *EVM) {

Callers

nothing calls this directly

Calls 4

toWordSizeFunction · 0.85
PopMethod · 0.80
deductGasMethod · 0.80
StoreMethod · 0.45

Tested by

no test coverage detected