aboutsummaryrefslogtreecommitdiffstats
path: root/params
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-08-05 16:01:02 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-08-05 16:01:02 +0800
commitaa6005b469fdd1aa7a95f501ce87908011f43159 (patch)
tree53a14d1b2f32798bbf22b2d74d4cbf16239b86b7 /params
parenta7de796840eeb267e298bcc98cdaa3a538234bef (diff)
downloadgo-tangerine-aa6005b469fdd1aa7a95f501ce87908011f43159.tar
go-tangerine-aa6005b469fdd1aa7a95f501ce87908011f43159.tar.gz
go-tangerine-aa6005b469fdd1aa7a95f501ce87908011f43159.tar.bz2
go-tangerine-aa6005b469fdd1aa7a95f501ce87908011f43159.tar.lz
go-tangerine-aa6005b469fdd1aa7a95f501ce87908011f43159.tar.xz
go-tangerine-aa6005b469fdd1aa7a95f501ce87908011f43159.tar.zst
go-tangerine-aa6005b469fdd1aa7a95f501ce87908011f43159.zip
core/vm, params: refactor chain configuration (#19735)
* params, core/vm: deprecating gastable, part 1 * core/vm, params: deprecate gastable, use both constant and dynamic gas * core/vm, params: remove gastable, remove copypaste * core/vm: make use of the chainrules * interpreter: make tracing count constant+dynamic gas * core/vm: review concerns (param/method name changes) * core/vm: make use of chainrules more
Diffstat (limited to 'params')
-rw-r--r--params/config.go19
-rw-r--r--params/gas_table.go93
-rw-r--r--params/protocol_params.go58
3 files changed, 42 insertions, 128 deletions
diff --git a/params/config.go b/params/config.go
index 2c7be848a..8c40b797d 100644
--- a/params/config.go
+++ b/params/config.go
@@ -386,25 +386,6 @@ func (c *ChainConfig) IsEWASM(num *big.Int) bool {
return isForked(c.EWASMBlock, num)
}
-// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
-//
-// The returned GasTable's fields shouldn't, under any circumstances, be changed.
-func (c *ChainConfig) GasTable(num *big.Int) GasTable {
- if num == nil {
- return GasTableHomestead
- }
- switch {
- case c.IsConstantinople(num):
- return GasTableConstantinople
- case c.IsEIP158(num):
- return GasTableEIP158
- case c.IsEIP150(num):
- return GasTableEIP150
- default:
- return GasTableHomestead
- }
-}
-
// CheckCompatible checks whether scheduled fork transitions have been imported
// with a mismatching chain configuration.
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *ConfigCompatError {
diff --git a/params/gas_table.go b/params/gas_table.go
deleted file mode 100644
index 6c4a38269..000000000
--- a/params/gas_table.go
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package params
-
-// GasTable organizes gas prices for different ethereum phases.
-type GasTable struct {
- ExtcodeSize uint64
- ExtcodeCopy uint64
- ExtcodeHash uint64
- Balance uint64
- SLoad uint64
- Calls uint64
- Suicide uint64
-
- 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 uint64
-}
-
-// Variables containing gas prices for different ethereum phases.
-var (
- // GasTableHomestead contain the gas prices for
- // the homestead phase.
- GasTableHomestead = GasTable{
- ExtcodeSize: 20,
- ExtcodeCopy: 20,
- Balance: 20,
- SLoad: 50,
- Calls: 40,
- Suicide: 0,
- ExpByte: 10,
- }
-
- // GasTableEIP150 contain the gas re-prices for
- // the EIP150 phase.
- GasTableEIP150 = GasTable{
- ExtcodeSize: 700,
- ExtcodeCopy: 700,
- Balance: 400,
- SLoad: 200,
- Calls: 700,
- Suicide: 5000,
- ExpByte: 10,
-
- CreateBySuicide: 25000,
- }
- // GasTableEIP158 contain the gas re-prices for
- // the EIP155/EIP158 phase.
- GasTableEIP158 = GasTable{
- ExtcodeSize: 700,
- ExtcodeCopy: 700,
- Balance: 400,
- SLoad: 200,
- Calls: 700,
- Suicide: 5000,
- ExpByte: 50,
-
- CreateBySuicide: 25000,
- }
- // GasTableConstantinople contain the gas re-prices for
- // the constantinople phase.
- GasTableConstantinople = GasTable{
- ExtcodeSize: 700,
- ExtcodeCopy: 700,
- ExtcodeHash: 400,
- Balance: 400,
- SLoad: 200,
- Calls: 700,
- Suicide: 5000,
- ExpByte: 50,
-
- CreateBySuicide: 25000,
- }
-)
diff --git a/params/protocol_params.go b/params/protocol_params.go
index 14750f6a1..01dc197af 100644
--- a/params/protocol_params.go
+++ b/params/protocol_params.go
@@ -52,22 +52,48 @@ const (
NetSstoreResetRefund uint64 = 4800 // Once per SSTORE operation for resetting to the original non-zero value
NetSstoreResetClearRefund uint64 = 19800 // Once per SSTORE operation for resetting to the original zero value
- JumpdestGas uint64 = 1 // Once per JUMPDEST operation.
- EpochDuration uint64 = 30000 // Duration between proof-of-work epochs.
- CallGas uint64 = 40 // Once per CALL operation & message call transaction.
- CreateDataGas uint64 = 200 //
- CallCreateDepth uint64 = 1024 // Maximum depth of call/create stack.
- ExpGas uint64 = 10 // Once per EXP instruction
- LogGas uint64 = 375 // Per LOG* operation.
- CopyGas uint64 = 3 //
- StackLimit uint64 = 1024 // Maximum size of VM stack allowed.
- TierStepGas uint64 = 0 // Once per operation, for a selection of them.
- LogTopicGas uint64 = 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas.
- CreateGas uint64 = 32000 // Once per CREATE operation & contract-creation transaction.
- Create2Gas uint64 = 32000 // Once per CREATE2 operation
- SuicideRefundGas uint64 = 24000 // Refunded following a suicide operation.
- MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.
- TxDataNonZeroGas uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
+ JumpdestGas uint64 = 1 // Once per JUMPDEST operation.
+ EpochDuration uint64 = 30000 // Duration between proof-of-work epochs.
+
+ CreateDataGas uint64 = 200 //
+ CallCreateDepth uint64 = 1024 // Maximum depth of call/create stack.
+ ExpGas uint64 = 10 // Once per EXP instruction
+ LogGas uint64 = 375 // Per LOG* operation.
+ CopyGas uint64 = 3 //
+ StackLimit uint64 = 1024 // Maximum size of VM stack allowed.
+ TierStepGas uint64 = 0 // Once per operation, for a selection of them.
+ LogTopicGas uint64 = 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas.
+ CreateGas uint64 = 32000 // Once per CREATE operation & contract-creation transaction.
+ Create2Gas uint64 = 32000 // Once per CREATE2 operation
+ SelfdestructRefundGas uint64 = 24000 // Refunded following a selfdestruct operation.
+ MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.
+ TxDataNonZeroGas uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
+
+ // These have been changed during the course of the chain
+ CallGasFrontier uint64 = 40 // Once per CALL operation & message call transaction.
+ CallGasEIP150 uint64 = 700 // Static portion of gas for CALL-derivates after EIP 150 (Tangerine)
+ BalanceGasFrontier uint64 = 20 // The cost of a BALANCE operation
+ BalanceGasEIP150 uint64 = 400 // The cost of a BALANCE operation after Tangerine
+ ExtcodeSizeGasFrontier uint64 = 20 // Cost of EXTCODESIZE before EIP 150 (Tangerine)
+ ExtcodeSizeGasEIP150 uint64 = 700 // Cost of EXTCODESIZE after EIP 150 (Tangerine)
+ SloadGasFrontier uint64 = 50
+ SloadGasEIP150 uint64 = 200
+ ExtcodeHashGas uint64 = 400 // Cost of EXTCODEHASH (introduced in Constantinople)
+ SelfdestructGasEIP150 uint64 = 5000 // Cost of SELFDESTRUCT post EIP 150 (Tangerine)
+
+ // EXP has a dynamic portion depending on the size of the exponent
+ ExpByteFrontier uint64 = 10 // was set to 10 in Frontier
+ ExpByteEIP158 uint64 = 50 // was raised to 50 during Eip158 (Spurious Dragon)
+
+ // Extcodecopy has a dynamic AND a static cost. This represents only the
+ // static portion of the gas. It was changed during EIP 150 (Tangerine)
+ ExtcodeCopyBaseFrontier uint64 = 20
+ ExtcodeCopyBaseEIP150 uint64 = 700
+
+ // CreateBySelfdestructGas is used when the refunded account is one that does
+ // not exist. This logic is similar to call.
+ // Introduced in Tangerine Whistle (Eip 150)
+ CreateBySelfdestructGas uint64 = 25000
MaxCodeSize = 24576 // Maximum bytecode to permit for a contract