diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2017-01-05 03:17:24 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2017-02-14 04:44:25 +0800 |
commit | c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057 (patch) | |
tree | da94063644627d9da853a91c28bc37f2df341dd1 /params/gas_table.go | |
parent | 72dcd3c58bec0a281280d5d42ed53b6e429ce4af (diff) | |
download | go-tangerine-c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057.tar go-tangerine-c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057.tar.gz go-tangerine-c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057.tar.bz2 go-tangerine-c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057.tar.lz go-tangerine-c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057.tar.xz go-tangerine-c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057.tar.zst go-tangerine-c12f4df910e2da1cc5dd28c5c4bbe2d8721e1057.zip |
params: core, core/vm, miner: 64bit gas instructions
Reworked the EVM gas instructions to use 64bit integers rather than
arbitrary size big ints. All gas operations, be it additions,
multiplications or divisions, are checked and guarded against 64 bit
integer overflows.
In additon, most of the protocol paramaters in the params package have
been converted to uint64 and are now constants rather than variables.
* common/math: added overflow check ops
* core: vmenv, env renamed to evm
* eth, internal/ethapi, les: unmetered eth_call and cancel methods
* core/vm: implemented big.Int pool for evm instructions
* core/vm: unexported intPool methods & verification methods
* core/vm: added memoryGasCost overflow check and test
Diffstat (limited to 'params/gas_table.go')
-rw-r--r-- | params/gas_table.go | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/params/gas_table.go b/params/gas_table.go index 093dacc8b..a06053904 100644 --- a/params/gas_table.go +++ b/params/gas_table.go @@ -16,41 +16,35 @@ package params -import "math/big" - type GasTable struct { - ExtcodeSize *big.Int - ExtcodeCopy *big.Int - Balance *big.Int - SLoad *big.Int - Calls *big.Int - Suicide *big.Int + ExtcodeSize uint64 + ExtcodeCopy uint64 + Balance uint64 + SLoad uint64 + Calls uint64 + Suicide uint64 - ExpByte *big.Int + ExpByte uint64 // CreateBySuicide occurs when the // refunded account is one that does // not exist. This logic is similar // to call. May be left nil. Nil means // not charged. - CreateBySuicide *big.Int + CreateBySuicide uint64 } var ( // GasTableHomestead contain the gas prices for // the homestead phase. GasTableHomestead = GasTable{ - ExtcodeSize: big.NewInt(20), - ExtcodeCopy: big.NewInt(20), - Balance: big.NewInt(20), - SLoad: big.NewInt(50), - Calls: big.NewInt(40), - Suicide: big.NewInt(0), - ExpByte: big.NewInt(10), - - // explicitly set to nil to indicate - // this rule does not apply to homestead. - CreateBySuicide: nil, + ExtcodeSize: 20, + ExtcodeCopy: 20, + Balance: 20, + SLoad: 50, + Calls: 40, + Suicide: 0, + ExpByte: 10, } // GasTableHomestead contain the gas re-prices for @@ -58,26 +52,26 @@ var ( // // TODO rename to GasTableEIP150 GasTableHomesteadGasRepriceFork = GasTable{ - ExtcodeSize: big.NewInt(700), - ExtcodeCopy: big.NewInt(700), - Balance: big.NewInt(400), - SLoad: big.NewInt(200), - Calls: big.NewInt(700), - Suicide: big.NewInt(5000), - ExpByte: big.NewInt(10), + ExtcodeSize: 700, + ExtcodeCopy: 700, + Balance: 400, + SLoad: 200, + Calls: 700, + Suicide: 5000, + ExpByte: 10, - CreateBySuicide: big.NewInt(25000), + CreateBySuicide: 25000, } GasTableEIP158 = GasTable{ - ExtcodeSize: big.NewInt(700), - ExtcodeCopy: big.NewInt(700), - Balance: big.NewInt(400), - SLoad: big.NewInt(200), - Calls: big.NewInt(700), - Suicide: big.NewInt(5000), - ExpByte: big.NewInt(50), + ExtcodeSize: 700, + ExtcodeCopy: 700, + Balance: 400, + SLoad: 200, + Calls: 700, + Suicide: 5000, + ExpByte: 50, - CreateBySuicide: big.NewInt(25000), + CreateBySuicide: 25000, } ) |