38 ChainParams::ChainParams()
40 for (
unsigned i = 1; i <= 4; ++i)
49 ChainParams::ChainParams(
string const& _json,
h256 const& _stateRoot)
51 *
this = loadConfig(_json, _stateRoot);
54 ChainParams ChainParams::loadConfig(
string const& _json,
h256 const& _stateRoot)
const 66 cp.
tieBreakingGas = params.count(
"tieBreakingGas") ? params[
"tieBreakingGas"].get_bool() :
true;
69 if (i.first !=
"accountStartNonce" && i.first !=
"maximumExtraDataSize" && i.first !=
"blockReward" && i.first !=
"tieBreakingGas")
80 ChainParams ChainParams::loadGenesisState(
string const& _json,
h256 const& _stateRoot)
const 88 ChainParams ChainParams::loadGenesis(
string const& _json,
h256 const& _stateRoot)
const 105 if ((genesis.count(
"mixhash") || genesis.count(
"mixHash")) && genesis.count(
"nonce"))
107 h256 mixHash(genesis[genesis.count(
"mixhash") ?
"mixhash" :
"mixHash"].get_str());
118 SealEngineFace* ret = SealEngineRegistrar::create(sealEngineName);
119 assert(ret &&
"Seal engine not found");
131 void ChainParams::populateFromGenesis(
bytes const& _genesisRLP,
AccountMap const& _state)
143 sealFields = r[0].
itemCount() - BlockHeader::BasicFields;
145 for (
unsigned i = BlockHeader::BasicFields; i < r[0].
itemCount(); ++i)
146 sealRLP += r[0][i].
data();
148 calculateStateRoot(
true);
150 auto b = genesisBlock();
151 if (
b != _genesisRLP)
154 cdebug <<
"Genesis now:" << BlockHeader::headerHashFromBlock(
b);
156 cdebug << RLP(_genesisRLP);
161 h256 ChainParams::calculateStateRoot(
bool _force)
const 166 if (!stateRoot || _force)
171 stateRoot = state.root();
176 bytes ChainParams::genesisBlock()
const 180 calculateStateRoot();
182 block.
appendList(BlockHeader::BasicFields + sealFields)
const Object & get_obj() const
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
h256 calculateStateRoot(bool _force=false) const
std::unordered_map< Address, Account > AccountMap
bytes rlp(_T _t)
Export a single item in RLP format, returning a byte array.
ChainParams loadGenesisState(std::string const &_json, h256 const &_stateRoot=h256()) const
Models the state of a single Ethereum account.
std::unordered_map< std::string, std::string > otherParams
Additional parameters.
bytes const & out() const
Read the byte stream.
std::unordered_map< Address, Account > const & genesisState()
h160 Address
An Ethereum address: 20 bytes.
std::hash for asio::adress
assert(len-trim+(2 *lenIndices)<=WIDTH)
Different view on a GenericTrieDB that can use different key types.
u256 maximumExtraDataSize
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
bool read_string(const String_type &s, Value_type &value)
ChainParams loadGenesis(std::string const &_json, h256 const &_stateRoot=h256()) const
h256 stateRoot
Only pre-populate if known equivalent to genesisState's root. If they're different Bad Things Will Ha...
std::unordered_map< Address, PrecompiledContract > precompiled
Precompiled contracts as specified in the chain params.
std::vector< byte > bytes
RLPStream & appendList(size_t _items)
Appends a list.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
mConfig::Object_type mObject
h256 parentHash
Genesis params.
Value_type::String_type write_string(const Value_type &value, bool pretty)
AccountMap jsonToAccountMap(std::string const &_json, u256 const &_defaultNonce=0, AccountMaskMap *o_mask=nullptr, PrecompiledContractMap *o_precompiled=nullptr)
std::string sealEngineName
The chain sealer name: e.g. Ethash, NoProof, BasicAuthority.
void setChainParams(ChainOperationParams const &_params)
h2048 LogBloom
The log bloom's size (2048-bit).
virtual bytes sealRLP() const
AddressHash commit(AccountMap const &_cache, SecureTrieDB< Address, DB > &_state)
u256 blockReward
General chain params.
virtual unsigned sealFields() const
std::string get_str(std::string::const_iterator begin, std::string::const_iterator end)
Class for writing to an RLP bytestream.
RLPStream & appendRaw(bytesConstRef _rlp, size_t _itemCount=1)
Appends raw (pre-serialised) RLP data. Use with caution.
Class for interpreting Recursive Linear-Prefix Data.
bytes RLPEmptyList
The empty list in RLP format.