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
):
35
PrecompiledContract
([=](
bytesConstRef
_in) ->
bigint
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
44
ChainOperationParams::ChainOperationParams
():
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
56
EVMSchedule
const
&
ChainOperationParams::scheduleForBlockNumber
(
u256
const
& _blockNumber)
const
57
{
58
if
(_blockNumber >=
experimentalForkBlock
)
59
return
ExperimentalSchedule;
60
else
if
(_blockNumber >=
constantinopleFixForkBlock
)
61
return
ConstantinopleFixSchedule;
62
else
if
(_blockNumber >=
constantinopleForkBlock
)
63
return
ConstantinopleSchedule;
64
else
if
(_blockNumber >=
eWASMForkBlock
)
65
return
EWASMSchedule;
66
else
if
(_blockNumber >=
byzantiumForkBlock
)
67
return
ByzantiumSchedule;
68
else
if
(_blockNumber >=
EIP158ForkBlock
)
69
return
EIP158Schedule;
70
else
if
(_blockNumber >=
EIP150ForkBlock
)
71
return
EIP150Schedule;
72
else
if
(_blockNumber >=
homesteadForkBlock
)
73
return
HomesteadSchedule;
74
else
75
return
FrontierSchedule;
76
}
77
78
u256
ChainOperationParams::blockReward
(
EVMSchedule
const
& _schedule)
const
79
{
80
if
(_schedule.
blockRewardOverwrite
)
81
return
*_schedule.
blockRewardOverwrite
;
82
else
83
return
m_blockReward;
84
}
85
86
void
ChainOperationParams::setBlockReward
(
u256
const
& _newBlockReward)
87
{
88
m_blockReward = _newBlockReward;
89
}
dev::vector_ref< byte const >
dev::eth::PrecompiledContract
Definition:
ChainOperationParams.h:36
dev::eth::PrecompiledExecutor
std::function< std::pair< bool, bytes >(bytesConstRef _in)> PrecompiledExecutor
Definition:
Precompiled.h:34
dev::eth::ChainOperationParams::experimentalForkBlock
u256 experimentalForkBlock
Definition:
ChainOperationParams.h:98
dev::eth::ChainOperationParams::blockReward
u256 blockReward(EVMSchedule const &_schedule) const
Definition:
ChainOperationParams.cpp:78
dev::eth::EVMSchedule::blockRewardOverwrite
boost::optional< u256 > blockRewardOverwrite
Definition:
EVMSchedule.h:81
dev::eth::ChainOperationParams::ChainOperationParams
ChainOperationParams()
Definition:
ChainOperationParams.cpp:44
dev::eth::ChainOperationParams::homesteadForkBlock
u256 homesteadForkBlock
Definition:
ChainOperationParams.h:90
dev::eth::ChainOperationParams::EIP158ForkBlock
u256 EIP158ForkBlock
Definition:
ChainOperationParams.h:92
ChainOperationParams.h
dev::eth::ChainOperationParams::scheduleForBlockNumber
EVMSchedule const & scheduleForBlockNumber(u256 const &_blockNumber) const
Definition:
ChainOperationParams.cpp:56
dev::eth::ChainOperationParams::constantinopleFixForkBlock
u256 constantinopleFixForkBlock
Definition:
ChainOperationParams.h:96
dev::eth::ChainOperationParams::EIP150ForkBlock
u256 EIP150ForkBlock
Definition:
ChainOperationParams.h:91
CommonData.h
dev::eth::ChainOperationParams::constantinopleForkBlock
u256 constantinopleForkBlock
Definition:
ChainOperationParams.h:95
dev::bigint
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<> > bigint
Definition:
Common.h:118
dev::eth::ChainOperationParams::byzantiumForkBlock
u256 byzantiumForkBlock
Definition:
ChainOperationParams.h:93
std
Definition:
FixedHash.h:393
dev::eth::ChainOperationParams::setBlockReward
void setBlockReward(u256 const &_newBlockReward)
Definition:
ChainOperationParams.cpp:86
dev::u256
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
Definition:
Common.h:121
dev
Definition:
Address.cpp:21
dev::eth::ChainOperationParams::eWASMForkBlock
u256 eWASMForkBlock
Definition:
ChainOperationParams.h:94
dev::eth::EVMSchedule
Definition:
EVMSchedule.h:29
Log.h
libethcore
ChainOperationParams.cpp
Generated on Fri Sep 20 2019 00:00:00 for Ethereum by
1.8.18