Ethereum  PoC-8
The C++ Implementation of Ethereum
EVMSchedule.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #pragma once
19 
20 #include <array>
21 #include <boost/optional.hpp>
22 
23 namespace dev
24 {
25 namespace eth
26 {
27 
29 {
30  EVMSchedule(): tierStepGas(std::array<unsigned, 8>{{0, 2, 3, 5, 8, 10, 20, 0}}) {}
31  EVMSchedule(bool _efcd, bool _hdc, unsigned const& _txCreateGas): exceptionalFailedCodeDeposit(_efcd), haveDelegateCall(_hdc), tierStepGas(std::array<unsigned, 8>{{0, 2, 3, 5, 8, 10, 20, 0}}), txCreateGas(_txCreateGas) {}
33  bool haveDelegateCall = true;
34  bool eip150Mode = false;
35  bool eip158Mode = false;
36  bool eip1283Mode = false;
37  bool haveBitwiseShifting = false;
38  bool haveRevert = false;
39  bool haveReturnData = false;
40  bool haveStaticCall = false;
41  bool haveCreate2 = false;
42  bool haveExtcodehash = false;
43  std::array<unsigned, 8> tierStepGas;
44  unsigned expGas = 10;
45  unsigned expByteGas = 10;
46  unsigned sha3Gas = 30;
47  unsigned sha3WordGas = 6;
48  unsigned sloadGas = 50;
49  unsigned sstoreSetGas = 20000;
50  unsigned sstoreResetGas = 5000;
51  unsigned sstoreUnchangedGas = 200;
52  unsigned sstoreRefundGas = 15000;
53  unsigned sstoreRefundNonzeroGas = 4800;
54  unsigned jumpdestGas = 1;
55  unsigned logGas = 375;
56  unsigned logDataGas = 8;
57  unsigned logTopicGas = 375;
58  unsigned createGas = 32000;
59  unsigned callGas = 40;
60  unsigned callStipend = 2300;
61  unsigned callValueTransferGas = 9000;
62  unsigned callNewAccountGas = 25000;
63  unsigned suicideRefundGas = 24000;
64  unsigned memoryGas = 3;
65  unsigned quadCoeffDiv = 512;
66  unsigned createDataGas = 200;
67  unsigned txGas = 21000;
68  unsigned txCreateGas = 53000;
69  unsigned txDataZeroGas = 4;
70  unsigned txDataNonZeroGas = 68;
71  unsigned copyGas = 3;
72 
73  unsigned extcodesizeGas = 20;
74  unsigned extcodecopyGas = 20;
75  unsigned extcodehashGas = 400;
76  unsigned balanceGas = 20;
77  unsigned suicideGas = 0;
78  unsigned blockhashGas = 20;
79  unsigned maxCodeSize = unsigned(-1);
80 
81  boost::optional<u256> blockRewardOverwrite;
82 
83  bool staticCallDepthLimit() const { return !eip150Mode; }
84  bool suicideChargesNewAccountGas() const { return eip150Mode; }
85  bool emptinessIsNonexistence() const { return eip158Mode; }
87 };
88 
89 static const EVMSchedule DefaultSchedule = EVMSchedule();
90 static const EVMSchedule FrontierSchedule = EVMSchedule(false, false, 21000);
91 static const EVMSchedule HomesteadSchedule = EVMSchedule(true, true, 53000);
92 
93 static const EVMSchedule EIP150Schedule = []
94 {
95  EVMSchedule schedule = HomesteadSchedule;
96  schedule.eip150Mode = true;
97  schedule.extcodesizeGas = 700;
98  schedule.extcodecopyGas = 700;
99  schedule.balanceGas = 400;
100  schedule.sloadGas = 200;
101  schedule.callGas = 700;
102  schedule.suicideGas = 5000;
103  return schedule;
104 }();
105 
106 static const EVMSchedule EIP158Schedule = []
107 {
108  EVMSchedule schedule = EIP150Schedule;
109  schedule.expByteGas = 50;
110  schedule.eip158Mode = true;
111  schedule.maxCodeSize = 0x6000;
112  return schedule;
113 }();
114 
115 static const EVMSchedule ByzantiumSchedule = []
116 {
117  EVMSchedule schedule = EIP158Schedule;
118  schedule.haveRevert = true;
119  schedule.haveReturnData = true;
120  schedule.haveStaticCall = true;
121  schedule.blockRewardOverwrite = {3 * ether};
122  return schedule;
123 }();
124 
125 static const EVMSchedule EWASMSchedule = []
126 {
127  EVMSchedule schedule = ByzantiumSchedule;
128  schedule.maxCodeSize = std::numeric_limits<unsigned>::max();
129  return schedule;
130 }();
131 
132 static const EVMSchedule ConstantinopleSchedule = []
133 {
134  EVMSchedule schedule = ByzantiumSchedule;
135  schedule.haveCreate2 = true;
136  schedule.haveBitwiseShifting = true;
137  schedule.haveExtcodehash = true;
138  schedule.eip1283Mode = true;
139  schedule.blockRewardOverwrite = {2 * ether};
140  return schedule;
141 }();
142 
143 static const EVMSchedule ExperimentalSchedule = [] {
144  EVMSchedule schedule = ConstantinopleSchedule;
145  schedule.blockhashGas = 800;
146  return schedule;
147 }();
148 }
149 }
Definition: Address.cpp:20
unsigned sstoreRefundNonzeroGas
Definition: EVMSchedule.h:53
Definition: FixedHash.h:390
unsigned txDataNonZeroGas
Definition: EVMSchedule.h:70
boost::optional< u256 > blockRewardOverwrite
Definition: EVMSchedule.h:81
bool exceptionalFailedCodeDeposit
Definition: EVMSchedule.h:32
std::array< unsigned, 8 > tierStepGas
Definition: EVMSchedule.h:43
unsigned suicideRefundGas
Definition: EVMSchedule.h:63
bool zeroValueTransferChargesNewAccountGas() const
Definition: EVMSchedule.h:86
unsigned callValueTransferGas
Definition: EVMSchedule.h:61
unsigned sstoreUnchangedGas
Definition: EVMSchedule.h:51
bool emptinessIsNonexistence() const
Definition: EVMSchedule.h:85
unsigned sstoreRefundGas
Definition: EVMSchedule.h:52
bool staticCallDepthLimit() const
Definition: EVMSchedule.h:83
EVMSchedule(bool _efcd, bool _hdc, unsigned const &_txCreateGas)
Definition: EVMSchedule.h:31
unsigned callNewAccountGas
Definition: EVMSchedule.h:62
bool suicideChargesNewAccountGas() const
Definition: EVMSchedule.h:84