github.com/klaytn/klaytn@v1.12.1/params/computation_cost_params.go (about)

     1  // Modifications Copyright 2019 The klaytn Authors
     2  // Copyright 2015 The go-ethereum Authors
     3  // This file is part of the go-ethereum library.
     4  //
     5  // The go-ethereum library is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Lesser General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // The go-ethereum library is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  // GNU Lesser General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Lesser General Public License
    16  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    17  //
    18  // This file is derived from params/protocol_params.go (2018/06/04).
    19  // Modified and improved for the klaytn development.
    20  
    21  package params
    22  
    23  import "github.com/klaytn/klaytn/common/math"
    24  
    25  const (
    26  	// Computation cost for opcodes
    27  	ExtCodeHashComputationCost    = 1000
    28  	Create2ComputationCost        = 10000
    29  	StaticCallComputationCost     = 10000
    30  	ReturnDataSizeComputationCost = 10
    31  	ReturnDataCopyComputationCost = 40
    32  	RevertComputationCost         = 0
    33  	DelegateCallComputationCost   = 696
    34  	StopComputationCost           = 0
    35  	AddComputationCost            = 150
    36  	MulComputationCost            = 200
    37  	SubComputationCost            = 219
    38  	DivComputationCost            = 404
    39  	SdivComputationCost           = 739
    40  	ModComputationCost            = 812
    41  	SmodComputationCost           = 560
    42  	AddmodComputationCost         = 3349
    43  	MulmodComputationCost         = 4757
    44  	ExpComputationCost            = 5000
    45  	ShlComputationCost            = 1603
    46  	ShrComputationCost            = 1346
    47  	SarComputationCost            = 1815
    48  	SignExtendComputationCost     = 481
    49  	LtComputationCost             = 201
    50  	GtComputationCost             = 264
    51  	SltComputationCost            = 176
    52  	SgtComputationCost            = 222
    53  	EqComputationCost             = 220
    54  	IszeroComputationCost         = 165
    55  	AndComputationCost            = 288
    56  	XorComputationCost            = 657
    57  	OrComputationCost             = 160
    58  	NotComputationCost            = 1289
    59  	ByteComputationCost           = 589
    60  	Sha3ComputationCost           = 2465
    61  	AddressComputationCost        = 284
    62  	BalanceComputationCost        = 1407
    63  	OriginComputationCost         = 210
    64  	CallerComputationCost         = 188
    65  	CallValueComputationCost      = 149
    66  	CallDataLoadComputationCost   = 596
    67  	CallDataSizeComputationCost   = 194
    68  	CallDataCopyComputationCost   = 100
    69  	CodeSizeComputationCost       = 145
    70  	CodeCopyComputationCost       = 898
    71  	GasPriceComputationCost       = 131
    72  	ExtCodeSizeComputationCost    = 1481
    73  	ExtCodeCopyComputationCost    = 1000
    74  	BlockHashComputationCost      = 500
    75  	CoinbaseComputationCost       = 189
    76  	TimestampComputationCost      = 265
    77  	NumberComputationCost         = 202
    78  	DifficultyComputationCost     = 180
    79  	GasLimitComputationCost       = 166
    80  	PopComputationCost            = 140
    81  	MloadComputationCost          = 376
    82  	MstoreComputationCost         = 288
    83  	Mstore8ComputationCost        = 5142
    84  	SloadComputationCost          = 835
    85  	SstoreComputationCost         = 1548
    86  	JumpComputationCost           = 253
    87  	JumpiComputationCost          = 176
    88  	PcComputationCost             = 147
    89  	MsizeComputationCost          = 137
    90  	GasComputationCost            = 230
    91  	JumpDestComputationCost       = 10
    92  	PushComputationCost           = 120
    93  	Dup1ComputationCost           = 190
    94  	Dup2ComputationCost           = 190
    95  	Dup3ComputationCost           = 176
    96  	Dup4ComputationCost           = 142
    97  	Dup5ComputationCost           = 177
    98  	Dup6ComputationCost           = 165
    99  	Dup7ComputationCost           = 147
   100  	Dup8ComputationCost           = 157
   101  	Dup9ComputationCost           = 138
   102  	Dup10ComputationCost          = 174
   103  	Dup11ComputationCost          = 141
   104  	Dup12ComputationCost          = 144
   105  	Dup13ComputationCost          = 157
   106  	Dup14ComputationCost          = 143
   107  	Dup15ComputationCost          = 237
   108  	Dup16ComputationCost          = 149
   109  	Swap1ComputationCost          = 141
   110  	Swap2ComputationCost          = 156
   111  	Swap3ComputationCost          = 145
   112  	Swap4ComputationCost          = 135
   113  	Swap5ComputationCost          = 115
   114  	Swap6ComputationCost          = 146
   115  	Swap7ComputationCost          = 199
   116  	Swap8ComputationCost          = 130
   117  	Swap9ComputationCost          = 160
   118  	Swap10ComputationCost         = 134
   119  	Swap11ComputationCost         = 147
   120  	Swap12ComputationCost         = 128
   121  	Swap13ComputationCost         = 121
   122  	Swap14ComputationCost         = 114
   123  	Swap15ComputationCost         = 197
   124  	Swap16ComputationCost         = 128
   125  	Log0ComputationCost           = 100
   126  	Log1ComputationCost           = 1000
   127  	Log2ComputationCost           = 1000
   128  	Log3ComputationCost           = 1000
   129  	Log4ComputationCost           = 1000
   130  	CreateComputationCost         = 2094
   131  	CallComputationCost           = 5000
   132  	CallCodeComputationCost       = 4000
   133  	ReturnComputationCost         = 0
   134  	SelfDestructComputationCost   = 0
   135  
   136  	// Computation cost for precompiled contracts
   137  	EcrecoverComputationCost                       = 113150
   138  	Sha256PerWordComputationCost                   = 100
   139  	Sha256BaseComputationCost                      = 1000
   140  	Ripemd160PerWordComputationCost                = 10
   141  	Ripemd160BaseComputationCost                   = 100
   142  	IdentityPerWordComputationCost                 = 0
   143  	IdentityBaseComputationCost                    = 0
   144  	BigModExpPerGasComputationCost                 = 10
   145  	BigModExpBaseComputationCost                   = 100
   146  	Bn256AddComputationCost                        = 8000
   147  	Bn256ScalarMulComputationCost                  = 100000
   148  	Bn256ParingBaseComputationCost                 = 2000000
   149  	Bn256ParingPerPointComputationCost             = 1000000
   150  	BlobTxPointEvaluationPrecompileComputationCost = 2200000
   151  	VMLogPerByteComputationCost                    = 0
   152  	VMLogBaseComputationCost                       = 10
   153  	FeePayerComputationCost                        = 10
   154  	ValidateSenderPerSigComputationCost            = 180000
   155  	ValidateSenderBaseComputationCost              = 10000
   156  
   157  	// computation costs added at istanbulCompatible
   158  	ChainIDComputationCost      = 120
   159  	SelfBalanceComputationCost  = 374
   160  	Blake2bBaseComputationCost  = 10000
   161  	Blake2bScaleComputationCost = 10
   162  
   163  	// computation cost added at londonCompatible
   164  	BaseFeeComputationCost = 198
   165  
   166  	// computation cost added at KoreCompatible
   167  	RandomComputationCost = 1498
   168  
   169  	// computation cost added at ShanghaiCompatible
   170  	Push0ComputationCost = 80
   171  
   172  	// computation cost added at CancunCompatible
   173  	McopyComputationCost       = 250
   174  	TloadComputationCost       = 220
   175  	TstoreComputationCost      = 280
   176  	BlobHashComptationCost     = 165
   177  	BlobBaseFeeComputationCost = 120
   178  
   179  	// opcode computation cost modification - istanbul
   180  	AddmodComputationCostIstanbul = 1410
   181  	MulmodComputationCostIstanbul = 1760
   182  	ShlComputationCostIstanbul    = 478
   183  	ShrComputationCostIstanbul    = 498
   184  	SarComputationCostIstanbul    = 834
   185  	XorComputationCostIstanbul    = 454
   186  	NotComputationCostIstanbul    = 364
   187  
   188  	// opcode computation cost codification - cancun
   189  	SdivComputationCostCancun    = 360
   190  	ModComputationCostCancun     = 320
   191  	AddmodComputationCostCancun  = 360
   192  	MulmodComputationCostCancun  = 700
   193  	ExpComputationCostCancun     = 720
   194  	Sha3ComputationCostCancun    = 560
   195  	Mstore8ComputationCostCancun = 230
   196  
   197  	SloadComputationCostCancun  = 2550
   198  	SstoreComputationCostCancun = 2510
   199  	Log1ComputationCostCancun   = 500
   200  	Log2ComputationCostCancun   = 500
   201  	Log3ComputationCostCancun   = 500
   202  	Log4ComputationCostCancun   = 500
   203  
   204  	OpcodeComputationCostLimit         = 100000000      // 100ms
   205  	OpcodeComputationCostLimitCancun   = 150000000      // 150ms
   206  	OpcodeComputationCostLimitInfinite = math.MaxUint64 // pass it to disable computation cost checks
   207  )
   208  
   209  // OpcodeComputationCostLimitOverride set by --opcode-computation-cost-limit.
   210  // Overrides chain default settings above.
   211  var OpcodeComputationCostLimitOverride = uint64(0)