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 static constexpr int64_t c_infiniteBlockNumer = 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;
90  u256 homesteadForkBlock = c_infiniteBlockNumer;
91  u256 EIP150ForkBlock = c_infiniteBlockNumer;
92  u256 EIP158ForkBlock = c_infiniteBlockNumer;
93  u256 byzantiumForkBlock = c_infiniteBlockNumer;
94  u256 eWASMForkBlock = c_infiniteBlockNumer;
95  u256 constantinopleForkBlock = c_infiniteBlockNumer;
96  u256 daoHardforkBlock = c_infiniteBlockNumer;
97  u256 experimentalForkBlock = c_infiniteBlockNumer;
98  int chainID = 0; // Distinguishes different chains (mainnet, Ropsten, etc).
99  int networkID = 0; // Distinguishes different sub protocols.
100 
104  bool allowFutureBlocks = false;
105 
107  std::unordered_map<Address, PrecompiledContract> precompiled;
108 };
109 
110 }
111 }
Definition: Address.cpp:20
u256 blockReward(EVMSchedule const &_schedule) const
PrecompiledContract(PrecompiledPricer const &_cost, PrecompiledExecutor const &_exec, u256 const &_startingBlock=0)
EVMSchedule const & scheduleForBlockNumber(u256 const &_blockNumber) const
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
std::pair< bool, bytes > execute(bytesConstRef _in) const
std::function< bigint(bytesConstRef _in)> PrecompiledPricer
Definition: Precompiled.h:35
u256 constexpr Invalid256
Definition: Common.h:147
std::unordered_map< Address, PrecompiledContract > precompiled
Precompiled contracts as specified in the chain params.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > u256
Definition: Common.h:121
std::string sealEngineName
The chain sealer name: e.g. Ethash, NoProof, BasicAuthority.
u256 const & startingBlock() const
bigint cost(bytesConstRef _in) const