diff options
author | Martin Holst Swende <martin@swende.se> | 2018-10-05 15:32:35 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-10-05 15:32:35 +0800 |
commit | 092df3ab59faae27b11ec737fffcadb3bc8ea636 (patch) | |
tree | c82582f25640ff7eea3766a42bde18a6328567fa /core/vm/gas_table.go | |
parent | 81375a3801564296a7ade3e7b5bde5fd63269d72 (diff) | |
download | dexon-092df3ab59faae27b11ec737fffcadb3bc8ea636.tar dexon-092df3ab59faae27b11ec737fffcadb3bc8ea636.tar.gz dexon-092df3ab59faae27b11ec737fffcadb3bc8ea636.tar.bz2 dexon-092df3ab59faae27b11ec737fffcadb3bc8ea636.tar.lz dexon-092df3ab59faae27b11ec737fffcadb3bc8ea636.tar.xz dexon-092df3ab59faae27b11ec737fffcadb3bc8ea636.tar.zst dexon-092df3ab59faae27b11ec737fffcadb3bc8ea636.zip |
core/vm: SHA3 word cost for CREATE2 (#17812)
* core/vm: create2 address generation tests
* core/vm: per byte cost of CREATE2
* core/vm: fix linter issue in test
Diffstat (limited to 'core/vm/gas_table.go')
-rw-r--r-- | core/vm/gas_table.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index 10b4f719a..df79f86ec 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -347,6 +347,17 @@ func gasCreate2(gt params.GasTable, evm *EVM, contract *Contract, stack *Stack, if gas, overflow = math.SafeAdd(gas, params.Create2Gas); overflow { return 0, errGasUintOverflow } + wordGas, overflow := bigUint64(stack.Back(2)) + if overflow { + return 0, errGasUintOverflow + } + if wordGas, overflow = math.SafeMul(toWordSize(wordGas), params.Sha3WordGas); overflow { + return 0, errGasUintOverflow + } + if gas, overflow = math.SafeAdd(gas, wordGas); overflow { + return 0, errGasUintOverflow + } + return gas, nil } |