diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2017-08-16 18:07:33 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-08-16 18:43:08 +0800 |
commit | 9bd6068fefe5687735bed342f3545f515fa717c8 (patch) | |
tree | d68767398eedd0a07c055fc8e880c4b4ab565a70 /core/vm/gas_table.go | |
parent | 76069eef38082089d2eaf99661a80e1a953bf271 (diff) | |
download | dexon-9bd6068fefe5687735bed342f3545f515fa717c8.tar dexon-9bd6068fefe5687735bed342f3545f515fa717c8.tar.gz dexon-9bd6068fefe5687735bed342f3545f515fa717c8.tar.bz2 dexon-9bd6068fefe5687735bed342f3545f515fa717c8.tar.lz dexon-9bd6068fefe5687735bed342f3545f515fa717c8.tar.xz dexon-9bd6068fefe5687735bed342f3545f515fa717c8.tar.zst dexon-9bd6068fefe5687735bed342f3545f515fa717c8.zip |
core/vm: implement RETURNDATA metropolis opcodes
Diffstat (limited to 'core/vm/gas_table.go')
-rw-r--r-- | core/vm/gas_table.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index 8a6c2741d..6cdbc5c39 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -91,6 +91,32 @@ func gasCalldataCopy(gt params.GasTable, evm *EVM, contract *Contract, stack *St return gas, nil } +func gasReturnDataCopy(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { + gas, err := memoryGasCost(mem, memorySize) + if err != nil { + return 0, err + } + + var overflow bool + if gas, overflow = math.SafeAdd(gas, GasFastestStep); overflow { + return 0, errGasUintOverflow + } + + words, overflow := bigUint64(stack.Back(2)) + if overflow { + return 0, errGasUintOverflow + } + + if words, overflow = math.SafeMul(toWordSize(words), params.CopyGas); overflow { + return 0, errGasUintOverflow + } + + if gas, overflow = math.SafeAdd(gas, words); overflow { + return 0, errGasUintOverflow + } + return gas, nil +} + func gasSStore(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { var ( y, x = stack.Back(1), stack.Back(0) |