From 5e0fd432ca19a834cf2eca12b07681a47520a90c Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Sun, 19 Jul 2015 01:17:13 +0200 Subject: [PATCH 01/12] Message save/load functionality upgraded --- libwhisper/Message.h | 19 ++++++++----- libwhisper/WhisperDB.cpp | 58 ++++++++++++++++++++++++++++++++++++-- libwhisper/WhisperDB.h | 6 ++++ libwhisper/WhisperHost.cpp | 49 +++++++++++++++++--------------- test/libp2p/peer.cpp | 9 +++--- 5 files changed, 103 insertions(+), 38 deletions(-) diff --git a/libwhisper/Message.h b/libwhisper/Message.h index ae61f210a..8953d1200 100644 --- a/libwhisper/Message.h +++ b/libwhisper/Message.h @@ -64,10 +64,11 @@ public: Envelope() {} Envelope(RLP const& _m); - operator bool() const { return !!m_expiry; } - void streamRLP(RLPStream& _s, IncludeNonce _withNonce = WithNonce) const { _s.appendList(_withNonce ? 5 : 4) << m_expiry << m_ttl << m_topic << m_data; if (_withNonce) _s << m_nonce; } h256 sha3(IncludeNonce _withNonce = WithNonce) const { RLPStream s; streamRLP(s, _withNonce); return dev::sha3(s.out()); } + Message open(Topics const& _t, Secret const& _s = Secret()) const; + unsigned workProved() const; + void proveWork(unsigned _ms); unsigned sent() const { return m_expiry - m_ttl; } unsigned expiry() const { return m_expiry; } @@ -75,12 +76,12 @@ public: AbridgedTopics const& topic() const { return m_topic; } bytes const& data() const { return m_data; } - Message open(Topics const& _t, Secret const& _s = Secret()) const; - - unsigned workProved() const; - void proveWork(unsigned _ms); - bool matchesBloomFilter(TopicBloomFilterHash const& f) const; + void setStoreForever() { m_storeForever = true; } + bool isStoreForever() const { return m_storeForever; } + bool isExpired() const { return !m_storeForever && m_expiry <= (unsigned)time(0); } + void setWatched() { m_watched = true; } + bool isWatched() const { return m_watched; } private: Envelope(unsigned _exp, unsigned _ttl, AbridgedTopics const& _topic): m_expiry(_exp), m_ttl(_ttl), m_topic(_topic) {} @@ -91,6 +92,10 @@ private: AbridgedTopics m_topic; bytes m_data; + + /// Metainformation + bool m_storeForever = false; + bool m_watched = false; }; enum /*Message Flags*/ diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index 7104723d7..9c4c77f43 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -84,7 +84,6 @@ void WhisperDB::loadAll(std::map& o_dst) op.fill_cache = false; op.verify_checksums = true; vector wasted; - unsigned now = (unsigned)time(0); unique_ptr it(m_db->NewIterator(op)); for (it->SeekToFirst(); it->Valid(); it->Next()) @@ -96,16 +95,18 @@ void WhisperDB::loadAll(std::map& o_dst) try { RLP rlp((byte const*)v.data(), v.size()); - Envelope e(rlp); + Envelope e(rlp[1]); h256 h2 = e.sha3(); h256 h1; + readMetaInfo(rlp[0], e); + if (k.size() == h256::size) h1 = h256((byte const*)k.data(), h256::ConstructFromPointer); if (h1 != h2) cwarn << "Corrupted data in Level DB:" << h1.hex() << "versus" << h2.hex(); - else if (e.expiry() > now) + else if (!e.isExpired()) { o_dst[h1] = e; useless = false; @@ -134,3 +135,54 @@ void WhisperDB::loadAll(std::map& o_dst) } } +void WhisperDB::save(h256 const& _key, Envelope const& _e) +{ + try + { + RLPStream meta; + streamMetaInfo(meta, _e); + + RLPStream msg; + _e.streamRLP(msg); + + RLPStream res(2); + res.appendRaw(meta.out()); + res.appendRaw(msg.out()); + + bytes b; + res.swapOut(b); + insert(_key, b); + } + catch(RLPException const& ex) + { + cwarn << "RLPException in WhisperDB::save():" << ex.what(); + } + catch(FailedInsertInLevelDB const& ex) + { + cwarn << "Exception in WhisperDB::save() - failed to insert:" << ex.what(); + } +} + +void WhisperDB::streamMetaInfo(RLPStream& _rlp, Envelope const& _e) +{ + uint32_t x = 0; + + if (_e.isStoreForever()) + x |= StoreForeverFlag; + + if (_e.isWatched()) + x |= WatchedFlag; + + _rlp.append(x); +} + +void WhisperDB::readMetaInfo(RLP const& _rlp, Envelope& _e) +{ + unsigned x = (uint32_t)_rlp; + + if (x & StoreForeverFlag) + _e.setStoreForever(); + + if (x & WatchedFlag) + _e.setWatched(); +} diff --git a/libwhisper/WhisperDB.h b/libwhisper/WhisperDB.h index 5079dfeb4..1fc20b9ab 100644 --- a/libwhisper/WhisperDB.h +++ b/libwhisper/WhisperDB.h @@ -47,11 +47,17 @@ class WhisperDB void insert(dev::h256 const& _key, bytes const& _value); void kill(dev::h256 const& _key); void loadAll(std::map& o_dst); + void save(dev::h256 const& _key, Envelope const& _e); private: + void streamMetaInfo(RLPStream& _rlp, Envelope const& _e); + void readMetaInfo(RLP const& _rlp, Envelope& _e); + leveldb::ReadOptions m_readOptions; leveldb::WriteOptions m_writeOptions; std::unique_ptr m_db; + + enum MetaInformation { StoreForeverFlag = 1, WatchedFlag = 2 }; }; } diff --git a/libwhisper/WhisperHost.cpp b/libwhisper/WhisperHost.cpp index 82c173378..781e6d73f 100644 --- a/libwhisper/WhisperHost.cpp +++ b/libwhisper/WhisperHost.cpp @@ -59,7 +59,7 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) cnote << this << ": inject: " << _m.expiry() << _m.ttl() << _m.topic() << toHex(_m.data()); - if (_m.expiry() <= (unsigned)time(0)) + if (_m.isExpired()) return; auto h = _m.sha3(); @@ -69,13 +69,15 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) return; UpgradeGuard ll(l); m_messages[h] = _m; - m_expiryQueue.insert(make_pair(_m.expiry(), h)); + if (!_m.isStoreForever()) + m_expiryQueue.insert(make_pair(_m.expiry(), h)); } // rating of incoming message from remote host is assessed according to the following criteria: // 1. installed watch match; 2. bloom filter match; 2. ttl; 3. proof of work int rating = 0; + bool match_watch = false; DEV_GUARDED(m_filterLock) if (_m.matchesBloomFilter(m_bloom)) @@ -84,10 +86,11 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) for (auto const& f: m_filters) if (f.second.filter.matches(_m)) for (auto& i: m_watches) - if (i.second.id == f.first) + if (i.second.id == f.first) // match one of the watches { i.second.changes.push_back(h); rating += 2; + match_watch = true; } } @@ -100,6 +103,14 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) rating += _m.workProved(); } + if (match_watch) + { + WriteGuard g(x_messages); + auto j = m_messages.find(h); + if (m_messages.end() != j) + j->second.setWatched(); + } + // TODO p2p: capability-based rating for (auto i: peerSessions()) { @@ -195,7 +206,12 @@ void WhisperHost::cleanup() unsigned now = (unsigned)time(0); WriteGuard l(x_messages); for (auto it = m_expiryQueue.begin(); it != m_expiryQueue.end() && it->first <= now; it = m_expiryQueue.erase(it)) - m_messages.erase(it->second); + { + auto j = m_messages.find(it->second); + if (j != m_messages.end()) + if (!j->second.isStoreForever()) + m_messages.erase(it->second); + } } void WhisperHost::noteAdvertiseTopicsOfInterest() @@ -213,31 +229,15 @@ void WhisperHost::saveMessagesToBD() { WhisperDB db; ReadGuard g(x_messages); + unsigned now = (unsigned)time(0); for (auto const& m: m_messages) - { - RLPStream rlp; - m.second.streamRLP(rlp); - bytes b; - rlp.swapOut(b); - db.insert(m.first, b); - } + if (m.second.isStoreForever() || (m.second.expiry() > now && m.second.isWatched())) + db.save(m.first, m.second); } catch(FailedToOpenLevelDB const& ex) { cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed to open DB:" << ex.what(); } - catch(FailedInsertInLevelDB const& ex) - { - cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed to insert:" << ex.what(); - } - catch(FailedLookupInLevelDB const& ex) - { - cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed lookup:" << ex.what(); - } - catch(FailedDeleteInLevelDB const& ex) - { - cwarn << "Exception in WhisperHost::saveMessagesToBD() - failed to delete:" << ex.what(); - } catch(Exception const& ex) { cwarn << "Exception in WhisperHost::saveMessagesToBD():" << ex.what(); @@ -260,6 +260,9 @@ void WhisperHost::loadMessagesFromBD() db.loadAll(m); WriteGuard g(x_messages); m_messages.swap(m); + for (auto const& msg: m) + if (!msg.second.isStoreForever()) + m_expiryQueue.insert(make_pair(msg.second.expiry(), msg.first)); } catch(Exception const& ex) { diff --git a/test/libp2p/peer.cpp b/test/libp2p/peer.cpp index 03cac3c80..acc420c96 100644 --- a/test/libp2p/peer.cpp +++ b/test/libp2p/peer.cpp @@ -44,8 +44,8 @@ BOOST_AUTO_TEST_CASE(host) return; VerbosityHolder setTemporaryLevel(10); - NetworkPreferences host1prefs("127.0.0.1", 30301, false); - NetworkPreferences host2prefs("127.0.0.1", 30302, false); + NetworkPreferences host1prefs("127.0.0.1", 30311, false); + NetworkPreferences host2prefs("127.0.0.1", 30312, false); Host host1("Test", host1prefs); Host host2("Test", host2prefs); host1.start(); @@ -67,9 +67,8 @@ BOOST_AUTO_TEST_CASE(host) for (int i = 0; i < 3000 && (!host1.peerCount() || !host2.peerCount()); i += step) this_thread::sleep_for(chrono::milliseconds(step)); - //Temporary disabled - //BOOST_REQUIRE_EQUAL(host1.peerCount(), 1); - //BOOST_REQUIRE_EQUAL(host2.peerCount(), 1); + BOOST_REQUIRE_EQUAL(host1.peerCount(), 1); + BOOST_REQUIRE_EQUAL(host2.peerCount(), 1); } BOOST_AUTO_TEST_CASE(networkConfig) From 2fa7375720f88d2ba83a3227b3f41f7bc5f3d779 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Sun, 19 Jul 2015 13:00:37 +0200 Subject: [PATCH 02/12] installWatch() call in test --- test/libwhisper/whisperDB.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/libwhisper/whisperDB.cpp b/test/libwhisper/whisperDB.cpp index 0639d9844..6b96410a0 100644 --- a/test/libwhisper/whisperDB.cpp +++ b/test/libwhisper/whisperDB.cpp @@ -141,6 +141,7 @@ BOOST_AUTO_TEST_CASE(messages) auto wh = h.registerCapability(new WhisperHost(true)); preexisting = wh->all(); cnote << preexisting.size() << "preexisting messages in DB"; + wh->installWatch(BuildTopic("test")); for (unsigned i = 0; i < TestSize; ++i) wh->post(us.sec(), RLPStream().append(i).out(), BuildTopic("test"), 0xFFFFF); @@ -152,6 +153,7 @@ BOOST_AUTO_TEST_CASE(messages) p2p::Host h("Test"); auto wh = h.registerCapability(new WhisperHost(true)); map m2 = wh->all(); + wh->installWatch(BuildTopic("test")); BOOST_REQUIRE_EQUAL(m1.size(), m2.size()); BOOST_REQUIRE_EQUAL(m1.size() - preexisting.size(), TestSize); From 184c1b36cbbf6c017878f585c1589cd7f5007eb1 Mon Sep 17 00:00:00 2001 From: Vlad Gluhovsky Date: Mon, 20 Jul 2015 18:14:02 +0200 Subject: [PATCH 03/12] metainformation removed --- libwhisper/Message.h | 10 +------- libwhisper/WhisperDB.cpp | 49 +++++++------------------------------- libwhisper/WhisperDB.h | 3 --- libwhisper/WhisperHost.cpp | 40 ++++++++++++++----------------- libwhisper/WhisperHost.h | 1 + 5 files changed, 28 insertions(+), 75 deletions(-) diff --git a/libwhisper/Message.h b/libwhisper/Message.h index 8953d1200..4d8b34548 100644 --- a/libwhisper/Message.h +++ b/libwhisper/Message.h @@ -77,11 +77,7 @@ public: bytes const& data() const { return m_data; } bool matchesBloomFilter(TopicBloomFilterHash const& f) const; - void setStoreForever() { m_storeForever = true; } - bool isStoreForever() const { return m_storeForever; } - bool isExpired() const { return !m_storeForever && m_expiry <= (unsigned)time(0); } - void setWatched() { m_watched = true; } - bool isWatched() const { return m_watched; } + bool isExpired() const { return m_expiry <= (unsigned)time(0); } private: Envelope(unsigned _exp, unsigned _ttl, AbridgedTopics const& _topic): m_expiry(_exp), m_ttl(_ttl), m_topic(_topic) {} @@ -92,10 +88,6 @@ private: AbridgedTopics m_topic; bytes m_data; - - /// Metainformation - bool m_storeForever = false; - bool m_watched = false; }; enum /*Message Flags*/ diff --git a/libwhisper/WhisperDB.cpp b/libwhisper/WhisperDB.cpp index 9c4c77f43..327ff1521 100644 --- a/libwhisper/WhisperDB.cpp +++ b/libwhisper/WhisperDB.cpp @@ -85,6 +85,7 @@ void WhisperDB::loadAll(std::map& o_dst) op.verify_checksums = true; vector wasted; unique_ptr it(m_db->NewIterator(op)); + unsigned const now = (unsigned)time(0); for (it->SeekToFirst(); it->Valid(); it->Next()) { @@ -95,18 +96,16 @@ void WhisperDB::loadAll(std::map& o_dst) try { RLP rlp((byte const*)v.data(), v.size()); - Envelope e(rlp[1]); + Envelope e(rlp); h256 h2 = e.sha3(); h256 h1; - readMetaInfo(rlp[0], e); - if (k.size() == h256::size) h1 = h256((byte const*)k.data(), h256::ConstructFromPointer); if (h1 != h2) cwarn << "Corrupted data in Level DB:" << h1.hex() << "versus" << h2.hex(); - else if (!e.isExpired()) + else if (e.expiry() > now) { o_dst[h1] = e; useless = false; @@ -139,50 +138,18 @@ void WhisperDB::save(h256 const& _key, Envelope const& _e) { try { - RLPStream meta; - streamMetaInfo(meta, _e); - - RLPStream msg; - _e.streamRLP(msg); - - RLPStream res(2); - res.appendRaw(meta.out()); - res.appendRaw(msg.out()); - + RLPStream rlp; + _e.streamRLP(rlp); bytes b; - res.swapOut(b); + rlp.swapOut(b); insert(_key, b); } catch(RLPException const& ex) { - cwarn << "RLPException in WhisperDB::save():" << ex.what(); + cwarn << boost::diagnostic_information(ex); } catch(FailedInsertInLevelDB const& ex) { - cwarn << "Exception in WhisperDB::save() - failed to insert:" << ex.what(); + cwarn << boost::diagnostic_information(ex); } } - -void WhisperDB::streamMetaInfo(RLPStream& _rlp, Envelope const& _e) -{ - uint32_t x = 0; - - if (_e.isStoreForever()) - x |= StoreForeverFlag; - - if (_e.isWatched()) - x |= WatchedFlag; - - _rlp.append(x); -} - -void WhisperDB::readMetaInfo(RLP const& _rlp, Envelope& _e) -{ - unsigned x = (uint32_t)_rlp; - - if (x & StoreForeverFlag) - _e.setStoreForever(); - - if (x & WatchedFlag) - _e.setWatched(); -} diff --git a/libwhisper/WhisperDB.h b/libwhisper/WhisperDB.h index 1fc20b9ab..f56ae1005 100644 --- a/libwhisper/WhisperDB.h +++ b/libwhisper/WhisperDB.h @@ -50,9 +50,6 @@ class WhisperDB void save(dev::h256 const& _key, Envelope const& _e); private: - void streamMetaInfo(RLPStream& _rlp, Envelope const& _e); - void readMetaInfo(RLP const& _rlp, Envelope& _e); - leveldb::ReadOptions m_readOptions; leveldb::WriteOptions m_writeOptions; std::unique_ptr m_db; diff --git a/libwhisper/WhisperHost.cpp b/libwhisper/WhisperHost.cpp index 781e6d73f..1f5d28bcc 100644 --- a/libwhisper/WhisperHost.cpp +++ b/libwhisper/WhisperHost.cpp @@ -69,15 +69,13 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) return; UpgradeGuard ll(l); m_messages[h] = _m; - if (!_m.isStoreForever()) - m_expiryQueue.insert(make_pair(_m.expiry(), h)); + m_expiryQueue.insert(make_pair(_m.expiry(), h)); } // rating of incoming message from remote host is assessed according to the following criteria: // 1. installed watch match; 2. bloom filter match; 2. ttl; 3. proof of work int rating = 0; - bool match_watch = false; DEV_GUARDED(m_filterLock) if (_m.matchesBloomFilter(m_bloom)) @@ -90,7 +88,6 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) { i.second.changes.push_back(h); rating += 2; - match_watch = true; } } @@ -103,14 +100,6 @@ void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) rating += _m.workProved(); } - if (match_watch) - { - WriteGuard g(x_messages); - auto j = m_messages.find(h); - if (m_messages.end() != j) - j->second.setWatched(); - } - // TODO p2p: capability-based rating for (auto i: peerSessions()) { @@ -206,12 +195,7 @@ void WhisperHost::cleanup() unsigned now = (unsigned)time(0); WriteGuard l(x_messages); for (auto it = m_expiryQueue.begin(); it != m_expiryQueue.end() && it->first <= now; it = m_expiryQueue.erase(it)) - { - auto j = m_messages.find(it->second); - if (j != m_messages.end()) - if (!j->second.isStoreForever()) - m_messages.erase(it->second); - } + m_messages.erase(it->second); } void WhisperHost::noteAdvertiseTopicsOfInterest() @@ -220,6 +204,18 @@ void WhisperHost::noteAdvertiseTopicsOfInterest() i.first->cap().get()->noteAdvertiseTopicsOfInterest(); } +bool WhisperHost::isWatched(Envelope const& _e) const +{ + DEV_GUARDED(m_filterLock) + if (_e.matchesBloomFilter(m_bloom)) + for (auto const& f: m_filters) + if (f.second.filter.matches(_e)) + for (auto const& i: m_watches) + if (i.second.id == f.first) + return true; + return false; +} + void WhisperHost::saveMessagesToBD() { if (!m_useDB) @@ -231,8 +227,9 @@ void WhisperHost::saveMessagesToBD() ReadGuard g(x_messages); unsigned now = (unsigned)time(0); for (auto const& m: m_messages) - if (m.second.isStoreForever() || (m.second.expiry() > now && m.second.isWatched())) - db.save(m.first, m.second); + if (m.second.expiry() > now) + if (isWatched(m.second)) + db.save(m.first, m.second); } catch(FailedToOpenLevelDB const& ex) { @@ -261,8 +258,7 @@ void WhisperHost::loadMessagesFromBD() WriteGuard g(x_messages); m_messages.swap(m); for (auto const& msg: m) - if (!msg.second.isStoreForever()) - m_expiryQueue.insert(make_pair(msg.second.expiry(), msg.first)); + m_expiryQueue.insert(make_pair(msg.second.expiry(), msg.first)); } catch(Exception const& ex) { diff --git a/libwhisper/WhisperHost.h b/libwhisper/WhisperHost.h index 20b2d6e7a..d9a71b6b2 100644 --- a/libwhisper/WhisperHost.h +++ b/libwhisper/WhisperHost.h @@ -67,6 +67,7 @@ public: protected: virtual void doWork() override; void noteAdvertiseTopicsOfInterest(); + bool isWatched(Envelope const& _e) const; private: virtual void onStarting() override { startWorking(); } From 3bd1aecd2dd1a16aa63f61c642bdd49c47a96b3f Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 09:57:27 +0200 Subject: [PATCH 04/12] performance optimizations --- libethereum/BlockChain.cpp | 25 ++++---- libethereum/BlockChain.h | 14 +++-- libethereum/BlockDetails.h | 2 +- libethereum/BlockQueue.cpp | 2 +- libethereum/BlockQueue.h | 2 +- libethereum/DownloadMan.cpp | 56 ++--------------- libethereum/DownloadMan.h | 104 ------------------------------- libethereum/TransactionQueue.cpp | 1 + 8 files changed, 33 insertions(+), 173 deletions(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index a992c5851..00117e679 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -84,17 +84,22 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) ldb::Slice dev::eth::toSlice(h256 const& _h, unsigned _sub) { -#if ALL_COMPILERS_ARE_CPP11_COMPLIANT - static thread_local h256 h = _h ^ sha3(h256(u256(_sub))); - return ldb::Slice((char const*)&h, 32); -#else static boost::thread_specific_ptr> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); *t_h = FixedHash<33>(_h); (*t_h)[32] = (uint8_t)_sub; return (ldb::Slice)t_h->ref();//(char const*)t_h.get(), 32); -#endif +} + +ldb::Slice dev::eth::toSlice(uint64_t _n, unsigned _sub) +{ + static boost::thread_specific_ptr> t_h; + if (!t_h.get()) + t_h.reset(new FixedHash<33>); + toBigEndian(_n, bytesRef(t_h->data() + 24, 8)); + (*t_h)[32] = (uint8_t)_sub; + return (ldb::Slice)t_h->ref(); } namespace dev @@ -289,7 +294,7 @@ void BlockChain::rebuild(std::string const& _path, std::function(h256(u256(d)), m_blockHashes, x_blockHashes, NullBlockHash, oldExtrasDB).value); + bytes b = block(queryExtras(d, m_blockHashes, x_blockHashes, NullBlockHash, oldExtrasDB).value); BlockInfo bi(&b); if (_prepPoW) @@ -359,7 +364,8 @@ tuple BlockChain::sync(BlockQueue& _bq, OverlayDB c r = import(block.verified, _stateDB, ImportRequirements::Everything & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles); fresh += r.liveBlocks; dead += r.deadBlocks; - goodTransactions += r.goodTranactions; + goodTransactions.reserve(goodTransactions.size() + r.goodTranactions.size()); + std::move(std::begin(r.goodTranactions), std::end(r.goodTranactions), std::back_inserter(goodTransactions)); ++count; } catch (dev::eth::UnknownParent) @@ -947,7 +953,7 @@ void BlockChain::noteUsed(h256 const& _h, unsigned _extra) const m_inUse.insert(id); } -template static unsigned getHashSize(unordered_map const& _map) +template static unsigned getHashSize(unordered_map const& _map) { unsigned ret = 0; for (auto const& i: _map) @@ -1005,9 +1011,6 @@ void BlockChain::garbageCollect(bool _force) case ExtraDetails: m_details.erase(id.first); break; - case ExtraBlockHash: - m_blockHashes.erase(id.first); - break; case ExtraReceipts: m_receipts.erase(id.first); break; diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index d60be548a..415581f29 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -72,6 +72,7 @@ struct BlockChainDebug: public LogChannel { static const char* name(); static co std::unordered_map const& genesisState(); ldb::Slice toSlice(h256 const& _h, unsigned _sub = 0); +ldb::Slice toSlice(uint64_t _n, unsigned _sub = 0); using BlocksHash = std::unordered_map; using TransactionHashes = h256s; @@ -168,7 +169,7 @@ public: UncleHashes uncleHashes() const { return uncleHashes(currentHash()); } /// Get the hash for a given block's number. - h256 numberHash(unsigned _i) const { if (!_i) return genesisHash(); return queryExtras(h256(_i), m_blockHashes, x_blockHashes, NullBlockHash).value; } + h256 numberHash(unsigned _i) const { if (!_i) return genesisHash(); return queryExtras(_i, m_blockHashes, x_blockHashes, NullBlockHash).value; } /// Get the last N hashes for a given block. (N is determined by the LastHashes type.) LastHashes lastHashes() const { return lastHashes(number()); } @@ -293,7 +294,7 @@ protected: unsigned open(std::string const& _path, WithExisting _we = WithExisting::Trust); void close(); - template T queryExtras(h256 const& _h, std::unordered_map& _m, boost::shared_mutex& _x, T const& _n, ldb::DB* _extrasDB = nullptr) const + template T queryExtras(K const& _h, std::unordered_map& _m, boost::shared_mutex& _x, T const& _n, ldb::DB* _extrasDB = nullptr) const { { ReadGuard l(_x); @@ -305,10 +306,7 @@ protected: std::string s; (_extrasDB ? _extrasDB : m_extrasDB)->Get(m_readOptions, toSlice(_h, N), &s); if (s.empty()) - { -// cout << "Not found in DB: " << _h << endl; return _n; - } noteUsed(_h, N); @@ -317,6 +315,11 @@ protected: return ret.first->second; } + template T queryExtras(h256 const& _h, std::unordered_map& _m, boost::shared_mutex& _x, T const& _n, ldb::DB* _extrasDB = nullptr) const + { + return queryExtras(_h, _m, _x, _n, _extrasDB); + } + void checkConsistency(); /// The caches of the disk DB and their locks. @@ -340,6 +343,7 @@ protected: mutable std::deque> m_cacheUsage; mutable std::unordered_set m_inUse; void noteUsed(h256 const& _h, unsigned _extra = (unsigned)-1) const; + void noteUsed(uint64_t const& _h, unsigned _extra = (unsigned)-1) const { (void)_h; (void)_extra; } // don't note non-hash types std::chrono::system_clock::time_point m_lastCollection; void noteCanonChanged() const { Guard l(x_lastLastHashes); m_lastLastHashes.clear(); } diff --git a/libethereum/BlockDetails.h b/libethereum/BlockDetails.h index 73026834e..81f3cecdb 100644 --- a/libethereum/BlockDetails.h +++ b/libethereum/BlockDetails.h @@ -114,7 +114,7 @@ using BlockDetailsHash = std::unordered_map; using BlockLogBloomsHash = std::unordered_map; using BlockReceiptsHash = std::unordered_map; using TransactionAddressHash = std::unordered_map; -using BlockHashHash = std::unordered_map; +using BlockHashHash = std::unordered_map; using BlocksBloomsHash = std::unordered_map; static const BlockDetails NullBlockDetails; diff --git a/libethereum/BlockQueue.cpp b/libethereum/BlockQueue.cpp index d0ca34b1c..97352fbf1 100644 --- a/libethereum/BlockQueue.cpp +++ b/libethereum/BlockQueue.cpp @@ -292,7 +292,7 @@ void BlockQueue::updateBad_WITH_LOCK(h256 const& _bad) while (moreBad) { moreBad = false; - std::vector oldVerified; + std::deque oldVerified; swap(m_verified, oldVerified); for (auto& b: oldVerified) if (m_knownBad.count(b.verified.info.parentHash()) || m_knownBad.count(b.verified.info.hash())) diff --git a/libethereum/BlockQueue.h b/libethereum/BlockQueue.h index 97fca7c72..0d90aac21 100644 --- a/libethereum/BlockQueue.h +++ b/libethereum/BlockQueue.h @@ -154,7 +154,7 @@ private: mutable Mutex m_verification; ///< Mutex that allows writing to m_verified, m_verifying and m_unverified. std::condition_variable m_moreToVerify; ///< Signaled when m_unverified has a new entry. - std::vector m_verified; ///< List of blocks, in correct order, verified and ready for chain-import. + std::deque m_verified; ///< List of blocks, in correct order, verified and ready for chain-import. std::deque m_verifying; ///< List of blocks being verified; as long as the block component (bytes) is empty, it's not finished. std::deque m_unverified; ///< List of in correct order, ready for verification. diff --git a/libethereum/DownloadMan.cpp b/libethereum/DownloadMan.cpp index a9d353292..84931def2 100644 --- a/libethereum/DownloadMan.cpp +++ b/libethereum/DownloadMan.cpp @@ -24,6 +24,8 @@ using namespace std; using namespace dev; using namespace dev::eth; +size_t const c_maxDownloadAhead = 50000; // Must not be higher than BlockQueue::c_maxUnknownCount + DownloadMan::Overview DownloadMan::overview() const { ReadGuard l(m_lock); @@ -63,9 +65,10 @@ h256Hash DownloadSub::nextFetch(unsigned _n) if (!m_man || m_man->chainEmpty()) return h256Hash(); - m_asked = (~(m_man->taken() + m_attempted)).lowest(_n); - if (m_asked.empty()) - m_asked = (~(m_man->taken(true) + m_attempted)).lowest(_n); + RangeMask downloaded = m_man->taken(true); + m_asked = (~(m_man->taken(false) + m_attempted)).lowest(_n); + if (m_asked.empty() || m_asked.lastIn() - downloaded.firstOut() >= c_maxDownloadAhead) + m_asked = (~(downloaded + m_attempted)).lowest(_n); m_attempted += m_asked; for (auto i: m_asked) { @@ -85,50 +88,3 @@ bool DownloadSub::noteBlock(h256 _hash) m_remaining.erase(_hash); return ret; } - -HashDownloadSub::HashDownloadSub(HashDownloadMan& _man): m_man(&_man) -{ - WriteGuard l(m_man->x_subs); - m_asked = RangeMask(m_man->m_chainStart, m_man->m_chainStart + m_man->m_chainCount); - m_man->m_subs.insert(this); -} - -HashDownloadSub::~HashDownloadSub() -{ - if (m_man) - { - WriteGuard l(m_man->x_subs); - m_man->m_subs.erase(this); - } -} - -void HashDownloadSub::resetFetch() -{ - Guard l(m_fetch); - m_remaining = 0; - m_asked = RangeMask(m_man->m_chainStart, m_man->m_chainStart + m_man->m_chainCount); -} - -unsigned HashDownloadSub::nextFetch(unsigned _n) -{ - Guard l(m_fetch); - - m_asked = RangeMask(m_man->m_chainStart, m_man->m_chainStart + m_man->m_chainCount); - - if (!m_man || m_man->chainEmpty()) - return 0; - - m_asked = (~(m_man->taken())).lowest(_n); - if (m_asked.empty()) - m_asked = (~(m_man->taken(true))).lowest(_n); - return *m_asked.begin(); -} - -void HashDownloadSub::noteHash(unsigned _index, unsigned _size) -{ - Guard l(m_fetch); - if (m_man) - for(unsigned i = _index; i < _index + _size; ++i) - if (i >= m_man->m_got.all().first && i < m_man->m_got.all().second) - m_man->m_got += i; -} diff --git a/libethereum/DownloadMan.h b/libethereum/DownloadMan.h index b697d87ae..b6ca58845 100644 --- a/libethereum/DownloadMan.h +++ b/libethereum/DownloadMan.h @@ -170,110 +170,6 @@ private: std::unordered_set m_subs; }; - -class HashDownloadMan; - -class HashDownloadSub -{ - friend class HashDownloadMan; - -public: - HashDownloadSub(HashDownloadMan& _man); - ~HashDownloadSub(); - - /// Finished last fetch - grab the next hash index to download - unsigned nextFetch(unsigned _n); - - /// Note that we've received a particular hash range. - void noteHash(unsigned _index, unsigned count); - - /// Nothing doing here. - void doneFetch() { resetFetch(); } - - bool askedContains(unsigned _i) const { Guard l(m_fetch); return m_asked.contains(_i); } - RangeMask const& asked() const { return m_asked; } - -private: - void resetFetch(); // Called by DownloadMan when we need to reset the download. - - HashDownloadMan* m_man = nullptr; - mutable Mutex m_fetch; - unsigned m_remaining; - RangeMask m_asked; -}; - -class HashDownloadMan -{ - friend class HashDownloadSub; - -public: - ~HashDownloadMan() - { - for (auto i: m_subs) - i->m_man = nullptr; - } - - void resetToRange(unsigned _start, unsigned _count) - { - { - ReadGuard l(x_subs); - for (auto i: m_subs) - i->resetFetch(); - } - WriteGuard l(m_lock); - m_chainStart = _start; - m_chainCount = _count; - m_got += RangeMask(_start, _start + _count); - { - ReadGuard l(x_subs); - for (auto i: m_subs) - i->resetFetch(); - } - } - - void reset(unsigned _start) - { - WriteGuard l(m_lock); - m_chainStart = _start; - m_chainCount = 0; - m_got = RangeMask(_start, _start); - } - - RangeMask taken(bool _desperate = false) const - { - ReadGuard l(m_lock); - auto ret = m_got; - if (!_desperate) - { - ReadGuard l(x_subs); - for (auto i: m_subs) - ret += i->m_asked; - } - return ret; - } - - bool isComplete() const - { - ReadGuard l(m_lock); - return m_got.full(); - } - - size_t chainSize() const { ReadGuard l(m_lock); return m_chainCount; } - size_t chainEmpty() const { ReadGuard l(m_lock); return m_chainCount == 0; } - void foreachSub(std::function const& _f) const { ReadGuard l(x_subs); for(auto i: m_subs) _f(*i); } - unsigned subCount() const { ReadGuard l(x_subs); return m_subs.size(); } - RangeMask hashesGot() const { ReadGuard l(m_lock); return m_got; } - -private: - mutable SharedMutex m_lock; - unsigned m_chainStart = 0; - unsigned m_chainCount = 0; - RangeMask m_got; - - mutable SharedMutex x_subs; - std::unordered_set m_subs; -}; - } } diff --git a/libethereum/TransactionQueue.cpp b/libethereum/TransactionQueue.cpp index f461cae87..5de86c818 100644 --- a/libethereum/TransactionQueue.cpp +++ b/libethereum/TransactionQueue.cpp @@ -107,6 +107,7 @@ ImportResult TransactionQueue::import(Transaction const& _transaction, IfDropped return ir; { + _transaction.safeSender(); // Perform EC recovery outside of the write lock UpgradeGuard ul(l); ret = manageImport_WITH_LOCK(h, _transaction); } From 26ff87a0bfc58078027f4d2b245c492d444019ff Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 09:52:04 +0200 Subject: [PATCH 05/12] enabled libsecp256k1 on windows --- libdevcrypto/CMakeLists.txt | 6 ++---- test/CMakeLists.txt | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libdevcrypto/CMakeLists.txt b/libdevcrypto/CMakeLists.txt index 4244d95ca..4eb06485f 100644 --- a/libdevcrypto/CMakeLists.txt +++ b/libdevcrypto/CMakeLists.txt @@ -24,10 +24,8 @@ target_link_libraries(${EXECUTABLE} ${DB_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES}) target_link_libraries(${EXECUTABLE} scrypt) target_link_libraries(${EXECUTABLE} devcore) -if (NOT WIN32) - add_definitions(-DETH_HAVE_SECP256K1) - target_link_libraries(${EXECUTABLE} secp256k1) -endif () +add_definitions(-DETH_HAVE_SECP256K1) +target_link_libraries(${EXECUTABLE} secp256k1) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cbf184808..6bdefd65e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -75,9 +75,7 @@ target_link_libraries(testeth ${CURL_LIBRARIES}) target_link_libraries(testeth ${CRYPTOPP_LIBRARIES}) target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) -if (NOT WIN32) - target_link_libraries(testeth secp256k1) -endif() +target_link_libraries(testeth secp256k1) if (JSCONSOLE) target_link_libraries(testeth jsengine) From df6898538fcc2e8209a1fdd9cb2da2bf7659d911 Mon Sep 17 00:00:00 2001 From: arkpar Date: Mon, 20 Jul 2015 08:58:44 +0200 Subject: [PATCH 06/12] restored toSlice code for c++11, fixed build --- CMakeLists.txt | 6 ++---- libethereum/BlockChain.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e686422..0d92ee90a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -405,10 +405,8 @@ if (JSCONSOLE) add_subdirectory(ethconsole) endif () -if (NOT WIN32) - add_definitions(-DETH_HAVE_SECP256K1) - add_subdirectory(secp256k1) -endif () +add_definitions(-DETH_HAVE_SECP256K1) +add_subdirectory(secp256k1) add_subdirectory(libscrypt) add_subdirectory(libdevcrypto) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 00117e679..99e52d92e 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -84,22 +84,35 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) ldb::Slice dev::eth::toSlice(h256 const& _h, unsigned _sub) { +#if TRUE //ALL_COMPILERS_ARE_CPP11_COMPLIANT + static thread_local FixedHash<33> h = _h; + h[32] = (uint8_t)_sub; + return (ldb::Slice)h.ref(); +#else static boost::thread_specific_ptr> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); *t_h = FixedHash<33>(_h); (*t_h)[32] = (uint8_t)_sub; - return (ldb::Slice)t_h->ref();//(char const*)t_h.get(), 32); + return (ldb::Slice)t_h->ref(); +#endif //ALL_COMPILERS_ARE_CPP11_COMPLIANT } ldb::Slice dev::eth::toSlice(uint64_t _n, unsigned _sub) { +#if TRUE //ALL_COMPILERS_ARE_CPP11_COMPLIANT + static thread_local FixedHash<33> h; + toBigEndian(_n, bytesRef(h.data() + 24, 8)); + h[32] = (uint8_t)_sub; + return (ldb::Slice)h.ref(); +#else static boost::thread_specific_ptr> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); toBigEndian(_n, bytesRef(t_h->data() + 24, 8)); (*t_h)[32] = (uint8_t)_sub; return (ldb::Slice)t_h->ref(); +#endif } namespace dev @@ -613,7 +626,7 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const& unsigned n = number(route.front()); DEV_WRITE_GUARDED(x_blockHashes) for (auto i = route.begin(); i != route.end() && *i != common; ++i, --n) - m_blockHashes.erase(h256(u256(n))); + m_blockHashes.erase(n); DEV_WRITE_GUARDED(x_transactionAddresses) m_transactionAddresses.clear(); // TODO: could perhaps delete them individually? From 89d9a18485c24476772baa755558c8ef369a2d27 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 16 Jul 2015 09:52:04 +0200 Subject: [PATCH 07/12] enabled libsecp256k1 on windows --- libethereum/BlockChain.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 99e52d92e..bf2c1cc7c 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -84,10 +84,10 @@ std::ostream& dev::eth::operator<<(std::ostream& _out, BlockChain const& _bc) ldb::Slice dev::eth::toSlice(h256 const& _h, unsigned _sub) { -#if TRUE //ALL_COMPILERS_ARE_CPP11_COMPLIANT - static thread_local FixedHash<33> h = _h; - h[32] = (uint8_t)_sub; - return (ldb::Slice)h.ref(); +#if ALL_COMPILERS_ARE_CPP11_COMPLIANT + static thread_local FixedHash<33> h = _h; + h[32] = (uint8_t)_sub; + return (ldb::Slice)h.ref(); #else static boost::thread_specific_ptr> t_h; if (!t_h.get()) @@ -100,16 +100,17 @@ ldb::Slice dev::eth::toSlice(h256 const& _h, unsigned _sub) ldb::Slice dev::eth::toSlice(uint64_t _n, unsigned _sub) { -#if TRUE //ALL_COMPILERS_ARE_CPP11_COMPLIANT - static thread_local FixedHash<33> h; - toBigEndian(_n, bytesRef(h.data() + 24, 8)); - h[32] = (uint8_t)_sub; - return (ldb::Slice)h.ref(); +#if ALL_COMPILERS_ARE_CPP11_COMPLIANT + static thread_local FixedHash<33> h; + toBigEndian(_n, bytesRef(h.data() + 24, 8)); + h[32] = (uint8_t)_sub; + return (ldb::Slice)h.ref(); #else static boost::thread_specific_ptr> t_h; if (!t_h.get()) t_h.reset(new FixedHash<33>); - toBigEndian(_n, bytesRef(t_h->data() + 24, 8)); + bytesRef ref(t_h->data() + 24, 8); + toBigEndian(_n, ref); (*t_h)[32] = (uint8_t)_sub; return (ldb::Slice)t_h->ref(); #endif @@ -377,7 +378,7 @@ tuple BlockChain::sync(BlockQueue& _bq, OverlayDB c r = import(block.verified, _stateDB, ImportRequirements::Everything & ~ImportRequirements::ValidSeal & ~ImportRequirements::CheckUncles); fresh += r.liveBlocks; dead += r.deadBlocks; - goodTransactions.reserve(goodTransactions.size() + r.goodTranactions.size()); + goodTransactions.reserve(goodTransactions.size() + r.goodTranactions.size()); std::move(std::begin(r.goodTranactions), std::end(r.goodTranactions), std::back_inserter(goodTransactions)); ++count; } From b60018713f6d17f019a1d962b6bf43bb8867cb1e Mon Sep 17 00:00:00 2001 From: arkpar Date: Mon, 20 Jul 2015 21:58:07 +0200 Subject: [PATCH 08/12] fixed build wo libcpuid --- libethcore/EthashCPUMiner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libethcore/EthashCPUMiner.cpp b/libethcore/EthashCPUMiner.cpp index 2e8a05018..f14c7b625 100644 --- a/libethcore/EthashCPUMiner.cpp +++ b/libethcore/EthashCPUMiner.cpp @@ -35,6 +35,7 @@ using namespace eth; unsigned EthashCPUMiner::s_numInstances = 0; +#if ETH_CPUID || !ETH_TRUE static string jsonEncode(map const& _m) { string ret = "{"; @@ -50,6 +51,7 @@ static string jsonEncode(map const& _m) return ret + "}"; } +#endif void EthashCPUMiner::workLoop() { From a978d4e56b55ee7d134501c7e9e8b46b6639c550 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 20 Jul 2015 14:08:40 +0200 Subject: [PATCH 09/12] Fix QT 5.5 Build In QT 5.5 Mono is a reserved preprocessor define and as such building with it fails. Switching the macros in alethzero/Context.h to follow Coding Standards fixes this discrepancy and allows us to build with QT 5.5. --- alethzero/Context.h | 8 ++++---- alethzero/MainWin.cpp | 18 +++++++++--------- alethzero/Transact.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/alethzero/Context.h b/alethzero/Context.h index a49d2be12..7dc2d5bc7 100644 --- a/alethzero/Context.h +++ b/alethzero/Context.h @@ -32,10 +32,10 @@ class QSpinBox; namespace dev { namespace eth { struct StateDiff; class KeyManager; } } -#define Small "font-size: small; " -#define Mono "font-family: Ubuntu Mono, Monospace, Lucida Console, Courier New; font-weight: bold; " -#define Div(S) "
" -#define Span(S) "" +#define ETH_HTML_SMALL "font-size: small; " +#define ETH_HTML_MONO "font-family: Ubuntu Mono, Monospace, Lucida Console, Courier New; font-weight: bold; " +#define ETH_HTML_DIV(S) "
" +#define ETH_HTML_SPAN(S) "" void initUnits(QComboBox* _b); void setValueUnits(QComboBox* _units, QSpinBox* _value, dev::u256 _v); diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 181772ddb..a22653362 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -594,7 +594,7 @@ void Main::eval(QString const& _js) void Main::addConsoleMessage(QString const& _js, QString const& _s) { m_consoleHistory.push_back(qMakePair(_js, _s)); - QString r = "" Div(Mono "position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%"); + QString r = "" ETH_HTML_DIV(ETH_HTML_MONO "position: absolute; bottom: 0; border: 0px; margin: 0px; width: 100%"); for (auto const& i: m_consoleHistory) r += "
>" + i.first.toHtmlEscaped() + "
" "
 " + i.second + "
"; @@ -1623,7 +1623,7 @@ void Main::on_transactionQueue_currentItemChanged() if (tx.data().size()) s << dev::memDump(tx.data(), 16, true); } - s << "
Hex: " Span(Mono) << toHex(tx.rlp()) << "
"; + s << "
Hex: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(tx.rlp()) << "
"; s << "
"; if (!!receipt.bloom()) s << "
Log Bloom: " << receipt.bloom() << "
"; @@ -1633,7 +1633,7 @@ void Main::on_transactionQueue_currentItemChanged() s << "
End State: " << receipt.stateRoot().abridged() << "
"; auto r = receipt.rlp(); s << "
Receipt: " << toString(RLP(r)) << "
"; - s << "
Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "
"; + s << "
Receipt-Hex: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(receipt.rlp()) << "
"; s << renderDiff(ethereum()->diff(i, PendingBlock)); // s << "Pre: " << fs.rootHash() << "
"; // s << "Post: " << ts.rootHash() << ""; @@ -1768,9 +1768,9 @@ void Main::on_blocks_currentItemChanged() s << "
" << sha3(i.data()).abridged() << ": " << receipts.receipts[ii].stateRoot() << " [" << receipts.receipts[ii].gasUsed() << " used]" << "
"; ++ii; } - s << "
Post: " << info.stateRoot() << "" << "
"; - s << "
Dump: " Span(Mono) << toHex(block[0].data()) << "" << "
"; - s << "
Receipts-Hex: " Span(Mono) << toHex(receipts.rlp()) << "
"; + s << "
Post: " << info.stateRoot << "" << "
"; + s << "
Dump: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(block[0].data()) << "" << "
"; + s << "
Receipts-Hex: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(receipts.rlp()) << "
"; } else { @@ -1801,7 +1801,7 @@ void Main::on_blocks_currentItemChanged() else s << "

Data

" << dev::memDump(tx.data(), 16, true); } - s << "
Hex: " Span(Mono) << toHex(block[1][txi].data()) << "
"; + s << "
Hex: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(block[1][txi].data()) << "
"; s << "
"; if (!!receipt.bloom()) s << "
Log Bloom: " << receipt.bloom() << "
"; @@ -1811,7 +1811,7 @@ void Main::on_blocks_currentItemChanged() s << "
End State: " << receipt.stateRoot().abridged() << "
"; auto r = receipt.rlp(); s << "
Receipt: " << toString(RLP(r)) << "
"; - s << "
Receipt-Hex: " Span(Mono) << toHex(receipt.rlp()) << "
"; + s << "
Receipt-Hex: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(receipt.rlp()) << "
"; s << "

Diff

" << renderDiff(ethereum()->diff(txi, h)); ui->debugCurrent->setEnabled(true); ui->debugDumpState->setEnabled(true); @@ -1881,7 +1881,7 @@ void Main::on_accounts_currentItemChanged() for (auto const& i: storage) s << "@" << showbase << hex << prettyU256(i.first) << "    " << showbase << hex << prettyU256(i.second) << "
"; s << "

Body Code (" << sha3(ethereum()->codeAt(address)).abridged() << ")

" << disassemble(ethereum()->codeAt(address)); - s << Div(Mono) << toHex(ethereum()->codeAt(address)) << "
"; + s << ETH_HTML_DIV(ETH_HTML_MONO) << toHex(ethereum()->codeAt(address)) << "
"; ui->accountInfo->appendHtml(QString::fromStdString(s.str())); } catch (dev::InvalidTrie) diff --git a/alethzero/Transact.cpp b/alethzero/Transact.cpp index 594133ba4..80ac7fe91 100644 --- a/alethzero/Transact.cpp +++ b/alethzero/Transact.cpp @@ -346,7 +346,7 @@ void Transact::rejigData() htmlInfo = "

Dump

" + QString::fromStdString(dev::memDump(m_data, 8, true)); } - htmlInfo += "

Hex

" + QString(Div(Mono)) + QString::fromStdString(toHex(m_data)) + ""; + htmlInfo += "

Hex

" + QString(ETH_HTML_DIV(ETH_HTML_MONO)) + QString::fromStdString(toHex(m_data)) + ""; // Determine the minimum amount of gas we need to play... qint64 baseGas = (qint64)Transaction::gasRequired(m_data, 0); From 193b505967d73cc4351e90fa886afa139cb83bbb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 21 Jul 2015 10:08:33 +0200 Subject: [PATCH 10/12] Remove cpuid from GPU miner. --- libethcore/EthashGPUMiner.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libethcore/EthashGPUMiner.cpp b/libethcore/EthashGPUMiner.cpp index 58e46c263..5baeec5f0 100644 --- a/libethcore/EthashGPUMiner.cpp +++ b/libethcore/EthashGPUMiner.cpp @@ -26,7 +26,6 @@ #include "EthashGPUMiner.h" #include #include -#include #include using namespace std; using namespace dev; From 7eaf40a4c1fa7d3dc640f855026d9b3d01c34a17 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 21 Jul 2015 10:11:26 +0200 Subject: [PATCH 11/12] Fix clang warnings, my version. Closes #2525 --- libethcore/EthashCPUMiner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libethcore/EthashCPUMiner.cpp b/libethcore/EthashCPUMiner.cpp index 2e8a05018..f14c7b625 100644 --- a/libethcore/EthashCPUMiner.cpp +++ b/libethcore/EthashCPUMiner.cpp @@ -35,6 +35,7 @@ using namespace eth; unsigned EthashCPUMiner::s_numInstances = 0; +#if ETH_CPUID || !ETH_TRUE static string jsonEncode(map const& _m) { string ret = "{"; @@ -50,6 +51,7 @@ static string jsonEncode(map const& _m) return ret + "}"; } +#endif void EthashCPUMiner::workLoop() { From b4ab42277aaa8e3cb192e06ffcebd58409a12440 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 21 Jul 2015 10:20:41 +0200 Subject: [PATCH 12/12] Build fix for Qt 5.5 fix. --- alethzero/MainWin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index a22653362..cdde0f147 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1768,7 +1768,7 @@ void Main::on_blocks_currentItemChanged() s << "
" << sha3(i.data()).abridged() << ": " << receipts.receipts[ii].stateRoot() << " [" << receipts.receipts[ii].gasUsed() << " used]" << "
"; ++ii; } - s << "
Post: " << info.stateRoot << "" << "
"; + s << "
Post: " << info.stateRoot() << "" << "
"; s << "
Dump: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(block[0].data()) << "" << "
"; s << "
Receipts-Hex: " ETH_HTML_SPAN(ETH_HTML_MONO) << toHex(receipts.rlp()) << "
"; }