From c38ecd95d99f247d5ff669c3bf6493699d93e412 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 4 Feb 2015 10:29:56 -0800 Subject: [PATCH] Split canon blockchain and basic blockchain. --- alethzero/MainWin.cpp | 17 +++-- libethereum/All.h | 2 +- libethereum/BlockChain.cpp | 62 +++--------------- libethereum/BlockChain.h | 18 +---- libethereum/CanonBlockChain.cpp | 80 ++++++++++++++++++++++- libethereum/CanonBlockChain.h | 76 +++++++++++++++++++-- libethereum/Client.h | 6 +- libethereum/State.cpp | 11 ++-- libethereum/State.h | 4 +- libweb3jsonrpc/WebThreeStubServerBase.cpp | 5 +- mix/MixClient.cpp | 6 +- test/fork.cpp | 2 +- test/genesis.cpp | 8 +-- test/state.cpp | 2 +- test/stateOriginal.cpp | 4 +- test/txTest.cpp | 2 +- third/MainWin.cpp | 6 +- 17 files changed, 199 insertions(+), 112 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 1921e80cd..8d24dc36c 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -136,9 +136,9 @@ Main::Main(QWidget *parent) : #endif m_servers.append(QString::fromStdString(Host::pocHost() + ":30303")); - cerr << "State root: " << BlockChain::genesis().stateRoot << endl; - auto block = BlockChain::createGenesisBlock(); - cerr << "Block Hash: " << BlockChain::genesis().hash << endl; + cerr << "State root: " << CanonBlockChain::genesis().stateRoot << endl; + auto block = CanonBlockChain::createGenesisBlock(); + cerr << "Block Hash: " << CanonBlockChain::genesis().hash << endl; cerr << "Block RLP: " << RLP(block) << endl; cerr << "Block Hex: " << toHex(block) << endl; cerr << "Network protocol version: " << c_protocolVersion << endl; @@ -1047,7 +1047,7 @@ void Main::refreshBlockCount() ui->blockCount->setText(QString("%6 #%1 @%3 T%2 PV%4 D%5").arg(d.number).arg(toLog2(d.totalDifficulty)).arg(toLog2(diff)).arg(c_protocolVersion).arg(c_databaseVersion).arg(m_privateChain.size() ? "[" + m_privateChain + "] " : "testnet")); } -static bool blockMatch(string const& _f, BlockDetails const& _b, h256 _h, BlockChain const& _bc) +static bool blockMatch(string const& _f, BlockDetails const& _b, h256 _h, CanonBlockChain const& _bc) { try { @@ -1189,7 +1189,10 @@ void Main::timerEvent(QTimerEvent*) { auto ls = ethereum()->checkWatch(i.first); if (ls.size()) + { + cnote << "FIRING WATCH" << i.first << ls.size(); i.second(ls); + } } } @@ -1202,7 +1205,7 @@ string Main::renderDiff(StateDiff const& _d) const { s << "
"; - AccountDiff const& ad = i.second; + AccountDiff ad = i.second; s << "" << lead(ad.changeType()) << " " << " " << render(i.first).toStdString() << ""; if (!ad.exist.to()) continue; @@ -1210,7 +1213,7 @@ string Main::renderDiff(StateDiff const& _d) const if (ad.balance) { s << "
" << indent << "Balance " << dec << ad.balance.to() << " [=" << formatBalance(ad.balance.to()) << "]"; - auto d = (((dev::bigint)ad.balance.to()) - ((dev::bigint)ad.balance.from())); + bigint d = (dev::bigint)ad.balance.to() - (dev::bigint)ad.balance.from(); s << " " << showpos << dec << d << " [=" << formatBalance(d) << "]" << noshowpos << ""; } if (ad.nonce) diff --git a/libethereum/All.h b/libethereum/All.h index 11e0d55f3..24109cb87 100644 --- a/libethereum/All.h +++ b/libethereum/All.h @@ -1,7 +1,7 @@ #pragma once #include "Account.h" -#include "BlockChain.h" +#include "CanonBlockChain.h" #include "Client.h" #include "Defaults.h" #include "Executive.h" diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 1addcbc14..11ab08ce6 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -53,30 +53,6 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) return _out; } -std::map const& dev::eth::genesisState() -{ - static std::map s_ret; - if (s_ret.empty()) - { - // Initialise. - for (auto i: vector({ - "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", - "e6716f9544a56c530d868e4bfbacb172315bdead", - "b9c015918bdaba24b4ff057a92a3873d6eb201be", - "1a26338f0d905e295fccb71fa9ea849ffa12aaf4", - "2ef47100e0787b915105fd5e3f4ff6752079d5cb", - "cd2a3d9f938e13cd947ec05abc7fe734df8dd826", - "6c386a4b26f73c802f34673f7248bb118f97424a", - "e4157b34ea9615cfbde6b4fda419828124b70c78" - })) - s_ret[Address(fromHex(i))] = Account(u256(1) << 200, Account::NormalCreation); - } - return s_ret; -} - -std::unique_ptr BlockChain::s_genesis; -boost::shared_mutex BlockChain::x_genesis; - ldb::Slice dev::eth::toSlice(h256 _h, unsigned _sub) { #if ALL_COMPILERS_ARE_CPP11_COMPLIANT @@ -91,31 +67,11 @@ ldb::Slice dev::eth::toSlice(h256 _h, unsigned _sub) #endif } -bytes BlockChain::createGenesisBlock() -{ - RLPStream block(3); - - h256 stateRoot; - { - MemoryDB db; - TrieDB state(&db); - state.init(); - dev::eth::commit(genesisState(), db, state); - stateRoot = state.root(); - } - - block.appendList(14) - << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); - block.appendRaw(RLPEmptyList); - block.appendRaw(RLPEmptyList); - return block.out(); -} - -BlockChain::BlockChain(std::string _path, bool _killExisting) +BlockChain::BlockChain(bytes const& _genesisBlock, std::string _path, bool _killExisting) { // Initialise with the genesis as the last block on the longest chain. - m_genesisHash = BlockChain::genesis().hash; - m_genesisBlock = BlockChain::createGenesisBlock(); + m_genesisBlock = _genesisBlock; + m_genesisHash = sha3(RLP(m_genesisBlock)[0].data()); open(_path, _killExisting); } @@ -353,7 +309,7 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) } #endif -// cnote << "Parent " << bi.parentHash << " has " << details(bi.parentHash).children.size() << " children."; + // cnote << "Parent " << bi.parentHash << " has " << details(bi.parentHash).children.size() << " children."; h256s ret; // This might be the new best block... @@ -377,7 +333,7 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) h256s BlockChain::treeRoute(h256 _from, h256 _to, h256* o_common, bool _pre, bool _post) const { -// cdebug << "treeRoute" << _from.abridged() << "..." << _to.abridged(); + // cdebug << "treeRoute" << _from.abridged() << "..." << _to.abridged(); if (!_from || !_to) { return h256s(); @@ -386,14 +342,14 @@ h256s BlockChain::treeRoute(h256 _from, h256 _to, h256* o_common, bool _pre, boo h256s back; unsigned fn = details(_from).number; unsigned tn = details(_to).number; -// cdebug << "treeRoute" << fn << "..." << tn; + // cdebug << "treeRoute" << fn << "..." << tn; while (fn > tn) { if (_pre) ret.push_back(_from); _from = details(_from).parent; fn--; -// cdebug << "from:" << fn << _from.abridged(); + // cdebug << "from:" << fn << _from.abridged(); } while (fn < tn) { @@ -401,7 +357,7 @@ h256s BlockChain::treeRoute(h256 _from, h256 _to, h256* o_common, bool _pre, boo back.push_back(_to); _to = details(_to).parent; tn--; -// cdebug << "to:" << tn << _to.abridged(); + // cdebug << "to:" << tn << _to.abridged(); } while (_from != _to) { @@ -415,7 +371,7 @@ h256s BlockChain::treeRoute(h256 _from, h256 _to, h256* o_common, bool _pre, boo back.push_back(_to); fn--; tn--; -// cdebug << "from:" << fn << _from.abridged() << "; to:" << tn << _to.abridged(); + // cdebug << "from:" << fn << _from.abridged() << "; to:" << tn << _to.abridged(); } if (o_common) *o_common = _from; diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 4e5d66c9a..50ad78dac 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -69,8 +69,7 @@ ldb::Slice toSlice(h256 _h, unsigned _sub = 0); class BlockChain { public: - BlockChain(bool _killExisting = false): BlockChain(std::string(), _killExisting) {} - BlockChain(std::string _path, bool _killExisting = false); + BlockChain(bytes const& _genesisBlock, std::string _path, bool _killExisting); ~BlockChain(); void reopen(std::string _path, bool _killExisting = false) { close(); open(_path, _killExisting); } @@ -82,7 +81,7 @@ public: /// Sync the chain with any incoming blocks. All blocks should, if processed in order h256s sync(BlockQueue& _bq, OverlayDB const& _stateDB, unsigned _max); - /// Attempt to import the given block directly into the BlockChain and sync with the state DB. + /// Attempt to import the given block directly into the CanonBlockChain and sync with the state DB. /// @returns the block hashes of any blocks that came into/went out of the canonical block chain. h256s attemptImport(bytes const& _block, OverlayDB const& _stateDB) noexcept; @@ -131,13 +130,6 @@ public: /// togther with all their quoted uncles. h256Set allUnclesFrom(h256 _parent) const; - /// @returns the genesis block header. - static BlockInfo const& genesis() { UpgradableGuard l(x_genesis); if (!s_genesis) { auto gb = createGenesisBlock(); UpgradeGuard ul(l); s_genesis.reset(new BlockInfo); s_genesis->populate(&gb); } return *s_genesis; } - - /// @returns the genesis block as its RLP-encoded byte array. - /// @note This is slow as it's constructed anew each call. Consider genesis() instead. - static bytes createGenesisBlock(); - /** @returns the hash of all blocks between @a _from and @a _to, all blocks are ordered first by a number of * blocks that are parent-to-child, then two sibling blocks, then a number of blocks that are child-to-parent. * @@ -171,7 +163,7 @@ private: m_extrasDB->Get(m_readOptions, toSlice(_h, N), &s); if (s.empty()) { - // cout << "Not found in DB: " << _h << endl; +// cout << "Not found in DB: " << _h << endl; return _n; } @@ -208,10 +200,6 @@ private: ldb::WriteOptions m_writeOptions; friend std::ostream& operator<<(std::ostream& _out, BlockChain const& _bc); - - /// Static genesis info and its lock. - static boost::shared_mutex x_genesis; - static std::unique_ptr s_genesis; }; std::ostream& operator<<(std::ostream& _out, BlockChain const& _bc); diff --git a/libethereum/CanonBlockChain.cpp b/libethereum/CanonBlockChain.cpp index 04713dc7e..fc7107154 100644 --- a/libethereum/CanonBlockChain.cpp +++ b/libethereum/CanonBlockChain.cpp @@ -1,12 +1,86 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CanonBlockChain.cpp + * @author Gav Wood + * @date 2014 + */ + #include "CanonBlockChain.h" -CanonBlockChain::CanonBlockChain() -{ +#include +#include +#include +#include +#include +#include +#include +#include +#include "State.h" +#include "Defaults.h" +using namespace std; +using namespace dev; +using namespace dev::eth; + +#define ETH_CATCH 1 +std::map const& dev::eth::genesisState() +{ + static std::map s_ret; + if (s_ret.empty()) + { + // Initialise. + for (auto i: vector({ + "dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6", + "e6716f9544a56c530d868e4bfbacb172315bdead", + "b9c015918bdaba24b4ff057a92a3873d6eb201be", + "1a26338f0d905e295fccb71fa9ea849ffa12aaf4", + "2ef47100e0787b915105fd5e3f4ff6752079d5cb", + "cd2a3d9f938e13cd947ec05abc7fe734df8dd826", + "6c386a4b26f73c802f34673f7248bb118f97424a", + "e4157b34ea9615cfbde6b4fda419828124b70c78" + })) + s_ret[Address(fromHex(i))] = Account(u256(1) << 200, Account::NormalCreation); + } + return s_ret; } -CanonBlockChain::~CanonBlockChain() +std::unique_ptr CanonBlockChain::s_genesis; +boost::shared_mutex CanonBlockChain::x_genesis; + +bytes CanonBlockChain::createGenesisBlock() { + RLPStream block(3); + + h256 stateRoot; + { + MemoryDB db; + TrieDB state(&db); + state.init(); + dev::eth::commit(genesisState(), db, state); + stateRoot = state.root(); + } + block.appendList(14) + << h256() << EmptyListSHA3 << h160() << stateRoot << EmptyTrie << EmptyTrie << LogBloom() << c_genesisDifficulty << 0 << 1000000 << 0 << (unsigned)0 << string() << sha3(bytes(1, 42)); + block.appendRaw(RLPEmptyList); + block.appendRaw(RLPEmptyList); + return block.out(); } +CanonBlockChain::CanonBlockChain(std::string _path, bool _killExisting): BlockChain(CanonBlockChain::createGenesisBlock(), _path, _killExisting) +{ +} diff --git a/libethereum/CanonBlockChain.h b/libethereum/CanonBlockChain.h index bc17e23ac..d9739097a 100644 --- a/libethereum/CanonBlockChain.h +++ b/libethereum/CanonBlockChain.h @@ -1,12 +1,76 @@ -#ifndef CANONBLOCKCHAIN_H -#define CANONBLOCKCHAIN_H +/* + This file is part of cpp-ethereum. + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -class CanonBlockChain + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file CanonBlockChain.h + * @author Gav Wood + * @date 2014 + */ + +#pragma once + +#pragma warning(push) +#pragma warning(disable: 4100 4267) +#include +#pragma warning(pop) + +#include +#include +#include +#include +#include +#include +#include "BlockDetails.h" +#include "Account.h" +#include "BlockQueue.h" +#include "BlockChain.h" +namespace ldb = leveldb; + +namespace dev +{ + +namespace eth +{ + +// TODO: Move all this Genesis stuff into Genesis.h/.cpp +std::map const& genesisState(); + +/** + * @brief Implements the blockchain database. All data this gives is disk-backed. + * @threadsafe + * @todo Make not memory hog (should actually act as a cache and deallocate old entries). + */ +class CanonBlockChain: public BlockChain { public: - CanonBlockChain(); - ~CanonBlockChain(); + CanonBlockChain(bool _killExisting = false): CanonBlockChain(std::string(), _killExisting) {} + CanonBlockChain(std::string _path, bool _killExisting = false); + ~CanonBlockChain() {} + + /// @returns the genesis block header. + static BlockInfo const& genesis() { UpgradableGuard l(x_genesis); if (!s_genesis) { auto gb = createGenesisBlock(); UpgradeGuard ul(l); s_genesis.reset(new BlockInfo); s_genesis->populate(&gb); } return *s_genesis; } + + /// @returns the genesis block as its RLP-encoded byte array. + /// @note This is slow as it's constructed anew each call. Consider genesis() instead. + static bytes createGenesisBlock(); + +private: + /// Static genesis info and its lock. + static boost::shared_mutex x_genesis; + static std::unique_ptr s_genesis; }; -#endif // CANONBLOCKCHAIN_H +} +} diff --git a/libethereum/Client.h b/libethereum/Client.h index d53781d90..0476db4fd 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -34,7 +34,7 @@ #include #include #include -#include "BlockChain.h" +#include "CanonBlockChain.h" #include "TransactionQueue.h" #include "State.h" #include "CommonNet.h" @@ -228,7 +228,7 @@ public: /// Get the object representing the current state of Ethereum. dev::eth::State postState() const { ReadGuard l(x_stateDB); return m_postMine; } /// Get the object representing the current canonical blockchain. - BlockChain const& blockChain() const { return m_bc; } + CanonBlockChain const& blockChain() const { return m_bc; } // Mining stuff: @@ -308,7 +308,7 @@ private: State asOf(unsigned _h) const; VersionChecker m_vc; ///< Dummy object to check & update the protocol version. - BlockChain m_bc; ///< Maintains block database. + CanonBlockChain m_bc; ///< Maintains block database. TransactionQueue m_tq; ///< Maintains a list of incoming transactions not yet in a block on the blockchain. BlockQueue m_bq; ///< Maintains a list of incoming blocks not yet on the blockchain (to be imported). diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 3f81cd4c9..fd5f9187f 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -35,6 +35,7 @@ #include "ExtVM.h" #include "Executive.h" #include "CachedAddressState.h" +#include "CanonBlockChain.h" using namespace std; using namespace dev; using namespace dev::eth; @@ -74,18 +75,16 @@ State::State(Address _coinbaseAddress, OverlayDB const& _db, BaseState _bs): paranoia("beginning of normal construction.", true); - if (_bs == BaseState::Genesis) + if (_bs == BaseState::CanonGenesis) { dev::eth::commit(genesisState(), m_db, m_state); m_db.commit(); paranoia("after DB commit of normal construction.", true); - m_previousBlock = BlockChain::genesis(); + m_previousBlock = CanonBlockChain::genesis(); } else - { m_previousBlock.setEmpty(); - } resetCurrent(); @@ -304,7 +303,7 @@ bool State::sync(BlockChain const& _bc, h256 _block, BlockInfo const& _bi) // (Most recent state dump might end up being genesis.) std::vector chain; - while (bi.stateRoot != BlockChain::genesis().hash && m_db.lookup(bi.stateRoot).empty()) // while we don't have the state root of the latest block... + while (bi.number != 0 && m_db.lookup(bi.stateRoot).empty()) // while we don't have the state root of the latest block... { chain.push_back(bi.hash); // push back for later replay. bi.populate(_bc.block(bi.parentHash)); // move to parent. @@ -698,7 +697,7 @@ void State::commitToMine(BlockChain const& _bc) RLPStream unclesData; unsigned unclesCount = 0; - if (m_previousBlock != BlockChain::genesis()) + if (m_previousBlock.number != 0) { // Find great-uncles (or second-cousins or whatever they are) - children of great-grandparents, great-great-grandparents... that were not already uncles in previous generations. // cout << "Checking " << m_previousBlock.hash << ", parent=" << m_previousBlock.parentHash << endl; diff --git a/libethereum/State.h b/libethereum/State.h index 0a288238d..65a333fb4 100644 --- a/libethereum/State.h +++ b/libethereum/State.h @@ -53,7 +53,7 @@ struct StateTrace: public LogChannel { static const char* name() { return "=S="; struct StateDetail: public LogChannel { static const char* name() { return "/S/"; } static const int verbosity = 14; }; struct StateSafeExceptions: public LogChannel { static const char* name() { return "(S)"; } static const int verbosity = 21; }; -enum class BaseState { Empty, Genesis }; +enum class BaseState { Empty, CanonGenesis }; /** * @brief Model of the current state of the ledger. @@ -68,7 +68,7 @@ class State public: /// Construct state object. - State(Address _coinbaseAddress = Address(), OverlayDB const& _db = OverlayDB(), BaseState _bs = BaseState::Genesis); + State(Address _coinbaseAddress = Address(), OverlayDB const& _db = OverlayDB(), BaseState _bs = BaseState::CanonGenesis); /// Construct state object from arbitrary point in blockchain. State(OverlayDB const& _db, BlockChain const& _bc, h256 _hash); diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index c8aff938f..26a3382c8 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/libweb3jsonrpc/WebThreeStubServerBase.cpp @@ -342,7 +342,10 @@ std::string WebThreeStubServerBase::eth_call(Json::Value const& _json) Json::Value WebThreeStubServerBase::eth_changed(int const& _id) { - return toJson(client()->checkWatch(_id)); + auto entries = client()->checkWatch(_id); + if (entries.size()) + cnote << "FIRING WATCH" << _id << entries.size(); + return toJson(entries); } std::string WebThreeStubServerBase::eth_codeAt(string const& _address) diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index a6c833532..ccc67ff50 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ void MixClient::resetState(u256 _balance) Guard fl(m_filterLock); m_filters.clear(); m_watches.clear(); - m_state = eth::State(m_userAccount.address(), m_stateDB, BaseState::Genesis); + m_state = eth::State(m_userAccount.address(), m_stateDB, BaseState::CanonGenesis); m_state.addBalance(m_userAccount.address(), _balance); Block genesis; genesis.state = m_state; @@ -164,7 +164,7 @@ void MixClient::mine() Block& block = m_blocks.back(); m_state.mine(0, true); m_state.completeMine(); - m_state.commitToMine(BlockChain()); + m_state.commitToMine(CanonBlockChain()); m_state.cleanup(true); block.state = m_state; block.info = m_state.info(); diff --git a/test/fork.cpp b/test/fork.cpp index 1cdb8822c..bc6ed87bc 100644 --- a/test/fork.cpp +++ b/test/fork.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include "TestHelper.h" using namespace std; diff --git a/test/genesis.cpp b/test/genesis.cpp index 8cdb84024..7ca741ee9 100644 --- a/test/genesis.cpp +++ b/test/genesis.cpp @@ -24,7 +24,7 @@ #include #include "JsonSpiritHeaders.h" #include -#include +#include #include #include "TestHelper.h" @@ -58,9 +58,9 @@ BOOST_AUTO_TEST_CASE(genesis_tests) js::mObject o = v.get_obj(); - BOOST_CHECK_EQUAL(BlockChain::genesis().stateRoot, h256(o["genesis_state_root"].get_str())); - BOOST_CHECK_EQUAL(toHex(BlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str()))); - BOOST_CHECK_EQUAL(BlockInfo::headerHash(BlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str())); + BOOST_CHECK_EQUAL(CanonBlockChain::genesis().stateRoot, h256(o["genesis_state_root"].get_str())); + BOOST_CHECK_EQUAL(toHex(CanonBlockChain::createGenesisBlock()), toHex(fromHex(o["genesis_rlp_hex"].get_str()))); + BOOST_CHECK_EQUAL(BlockInfo::headerHash(CanonBlockChain::createGenesisBlock()), h256(o["genesis_hash"].get_str())); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/state.cpp b/test/state.cpp index 100634be3..fb54a62ae 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -24,7 +24,7 @@ #include #include "JsonSpiritHeaders.h" #include -#include +#include #include #include #include diff --git a/test/stateOriginal.cpp b/test/stateOriginal.cpp index b1a7c0d8e..65ff5084f 100644 --- a/test/stateOriginal.cpp +++ b/test/stateOriginal.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include using namespace std; @@ -40,7 +40,7 @@ int stateTest() Defaults::setDBPath(boost::filesystem::temp_directory_path().string()); OverlayDB stateDB = State::openDB(); - BlockChain bc; + CanonBlockChain bc; State s(myMiner.address(), stateDB); cout << bc; diff --git a/test/txTest.cpp b/test/txTest.cpp index cc78c26a2..8d067f9bb 100644 --- a/test/txTest.cpp +++ b/test/txTest.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include "TestHelper.h" using namespace std; diff --git a/third/MainWin.cpp b/third/MainWin.cpp index eae421c24..64f90a761 100644 --- a/third/MainWin.cpp +++ b/third/MainWin.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -97,8 +97,8 @@ Main::Main(QWidget *parent) : setWindowFlags(Qt::Window); ui->setupUi(this); - cerr << "State root: " << BlockChain::genesis().stateRoot << endl; - auto gb = BlockChain::createGenesisBlock(); + cerr << "State root: " << CanonBlockChain::genesis().stateRoot << endl; + auto gb = CanonBlockChain::createGenesisBlock(); cerr << "Block Hash: " << sha3(gb) << endl; cerr << "Block RLP: " << RLP(gb) << endl; cerr << "Block Hex: " << toHex(gb) << endl;