Ethereum  PoC-8
The C++ Implementation of Ethereum
ChainOperationParams.cpp
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 */
22 #include "ChainOperationParams.h"
23 #include <libdevcore/Log.h>
24 #include <libdevcore/CommonData.h>
25 using namespace std;
26 using namespace dev;
27 using namespace eth;
28 
29 PrecompiledContract::PrecompiledContract(
30  unsigned _base,
31  unsigned _word,
32  PrecompiledExecutor const& _exec,
33  u256 const& _startingBlock
34 ):
36  {
37  bigint s = _in.size();
38  bigint b = _base;
39  bigint w = _word;
40  return b + (s + 31) / 32 * w;
41  }, _exec, _startingBlock)
42 {}
43 
45  m_blockReward("0x4563918244F40000"),
46  minGasLimit(0x1388),
47  maxGasLimit("0x7fffffffffffffff"),
48  gasLimitBoundDivisor(0x0400),
49  networkID(0x0),
50  minimumDifficulty(0x020000),
51  difficultyBoundDivisor(0x0800),
52  durationLimit(0x0d)
53 {
54 }
55 
57 {
58  if (_blockNumber >= experimentalForkBlock)
59  return ExperimentalSchedule;
60  else if (_blockNumber >= constantinopleForkBlock)
61  return ConstantinopleSchedule;
62  else if (_blockNumber >= eWASMForkBlock)
63  return EWASMSchedule;
64  else if (_blockNumber >= byzantiumForkBlock)
65  return ByzantiumSchedule;
66  else if (_blockNumber >= EIP158ForkBlock)
67  return EIP158Schedule;
68  else if (_blockNumber >= EIP150ForkBlock)
69  return EIP150Schedule;
70  else if (_blockNumber >= homesteadForkBlock)
71  return HomesteadSchedule;
72  else
73  return FrontierSchedule;
74 }
75 
77 {
78  if (_schedule.blockRewardOverwrite)
79  return *_schedule.blockRewardOverwrite;
80  else
81  return m_blockReward;
82 }
83 
84 void ChainOperationParams::setBlockReward(u256 const& _newBlockReward)
85 {
86  m_blockReward = _newBlockReward;
87 }
Definition: Address.cpp:20
u256 blockReward(EVMSchedule const &_schedule) const
Definition: FixedHash.h:390
EVMSchedule const & scheduleForBlockNumber(u256 const &_blockNumber) const
boost::optional< u256 > blockRewardOverwrite
Definition: EVMSchedule.h:81
void setBlockReward(u256 const &_newBlockReward)
std::function< std::pair< bool, bytes >(bytesConstRef _in)> PrecompiledExecutor
Definition: Precompiled.h:34
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<> > bigint
Definition: Common.h:118
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
Definition: Common.h:121