Ethereum  PoC-8
The C++ Implementation of Ethereum
ChainOperationParams.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 */
22 #pragma once
23 
24 #include <libdevcore/Common.h>
25 #include <libethcore/Precompiled.h>
26 
27 #include "Common.h"
28 #include "EVMSchedule.h"
29 
30 namespace dev
31 {
32 namespace eth
33 {
34 
36 {
37 public:
38  PrecompiledContract() = default;
40  PrecompiledPricer const& _cost,
41  PrecompiledExecutor const& _exec,
42  u256 const& _startingBlock = 0
43  ):
44  m_cost(_cost),
45  m_execute(_exec),
46  m_startingBlock(_startingBlock)
47  {}
49  unsigned _base,
50  unsigned _word,
51  PrecompiledExecutor const& _exec,
52  u256 const& _startingBlock = 0
53  );
54 
55  bigint cost(bytesConstRef _in) const { return m_cost(_in); }
56  std::pair<bool, bytes> execute(bytesConstRef _in) const { return m_execute(_in); }
57 
58  u256 const& startingBlock() const { return m_startingBlock; }
59 
60 private:
61  PrecompiledPricer m_cost;
62  PrecompiledExecutor m_execute;
63  u256 m_startingBlock = 0;
64 };
65 
66 constexpr int64_t c_infiniteBlockNumber = std::numeric_limits<int64_t>::max();
67 
69 {
71 
72  explicit operator bool() const { return accountStartNonce != Invalid256; }
73 
75  std::string sealEngineName = "NoProof";
76 
78 private:
79  u256 m_blockReward;
80 public:
81  EVMSchedule const& scheduleForBlockNumber(u256 const& _blockNumber) const;
82  u256 blockReward(EVMSchedule const& _schedule) const;
83  void setBlockReward(u256 const& _newBlockReward);
86  bool tieBreakingGas = true;
99  int chainID = 0; // Distinguishes different chains (mainnet, Ropsten, etc).
100  int networkID = 0; // Distinguishes different sub protocols.
101 
105  bool allowFutureBlocks = false;
106 
108  std::unordered_map<Address, PrecompiledContract> precompiled;
109 };
110 
111 }
112 }
dev::eth::ChainOperationParams::durationLimit
u256 durationLimit
Definition: ChainOperationParams.h:104
dev::eth::ChainOperationParams::allowFutureBlocks
bool allowFutureBlocks
Definition: ChainOperationParams.h:105
dev::eth::ChainOperationParams::difficultyBoundDivisor
u256 difficultyBoundDivisor
Definition: ChainOperationParams.h:103
dev::eth::PrecompiledContract::PrecompiledContract
PrecompiledContract(PrecompiledPricer const &_cost, PrecompiledExecutor const &_exec, u256 const &_startingBlock=0)
Definition: ChainOperationParams.h:39
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::gasLimitBoundDivisor
u256 gasLimitBoundDivisor
Definition: ChainOperationParams.h:89
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::c_infiniteBlockNumber
constexpr int64_t c_infiniteBlockNumber
Definition: ChainOperationParams.h:66
dev::eth::ChainOperationParams::ChainOperationParams
ChainOperationParams()
Definition: ChainOperationParams.cpp:44
dev::eth::ChainOperationParams::maxGasLimit
u256 maxGasLimit
Definition: ChainOperationParams.h:88
dev::eth::ChainOperationParams::homesteadForkBlock
u256 homesteadForkBlock
Definition: ChainOperationParams.h:90
dev::eth::ChainOperationParams::daoHardforkBlock
u256 daoHardforkBlock
Definition: ChainOperationParams.h:97
dev::eth::ChainOperationParams::EIP158ForkBlock
u256 EIP158ForkBlock
Definition: ChainOperationParams.h:92
dev::eth::PrecompiledContract::PrecompiledContract
PrecompiledContract()=default
dev::eth::PrecompiledContract::execute
std::pair< bool, bytes > execute(bytesConstRef _in) const
Definition: ChainOperationParams.h:56
dev::eth::ChainOperationParams::sealEngineName
std::string sealEngineName
The chain sealer name: e.g. Ethash, NoProof, BasicAuthority.
Definition: ChainOperationParams.h:75
EVMSchedule.h
Common.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::PrecompiledPricer
std::function< bigint(bytesConstRef _in)> PrecompiledPricer
Definition: Precompiled.h:35
Common.h
dev::eth::ChainOperationParams::EIP150ForkBlock
u256 EIP150ForkBlock
Definition: ChainOperationParams.h:91
dev::eth::ChainOperationParams::networkID
int networkID
Definition: ChainOperationParams.h:100
dev::eth::ChainOperationParams::chainID
int chainID
Definition: ChainOperationParams.h:99
dev::eth::ChainOperationParams::maximumExtraDataSize
u256 maximumExtraDataSize
Definition: ChainOperationParams.h:84
dev::Invalid256
constexpr u256 Invalid256
Definition: Common.h:147
dev::eth::ChainOperationParams::minimumDifficulty
u256 minimumDifficulty
Definition: ChainOperationParams.h:102
Precompiled.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::precompiled
std::unordered_map< Address, PrecompiledContract > precompiled
Precompiled contracts as specified in the chain params.
Definition: ChainOperationParams.h:108
dev::eth::ChainOperationParams::byzantiumForkBlock
u256 byzantiumForkBlock
Definition: ChainOperationParams.h:93
dev::eth::ChainOperationParams::tieBreakingGas
bool tieBreakingGas
Definition: ChainOperationParams.h:86
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::ChainOperationParams::minGasLimit
u256 minGasLimit
Definition: ChainOperationParams.h:87
dev::eth::PrecompiledContract::cost
bigint cost(bytesConstRef _in) const
Definition: ChainOperationParams.h:55
dev::eth::EVMSchedule
Definition: EVMSchedule.h:29
dev::eth::ChainOperationParams
Definition: ChainOperationParams.h:69
dev::eth::PrecompiledContract::startingBlock
u256 const & startingBlock() const
Definition: ChainOperationParams.h:58
dev::eth::ChainOperationParams::accountStartNonce
u256 accountStartNonce
Definition: ChainOperationParams.h:85