diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 951245e29..b14790c2e 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -270,8 +270,6 @@ True - - True @@ -3896,36 +3894,6 @@ ..\..\src\websocketpp;%(AdditionalIncludeDirectories) ..\..\src\websocketpp;%(AdditionalIncludeDirectories) - - - - True - True - - - - - True - True - - - - - - - True - True - - - - - - - True - True - - - @@ -3936,8 +3904,6 @@ True True - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index f41e58e76..0bf6cffea 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -427,9 +427,6 @@ {843C622F-AA52-E6C5-D3EB-D4B6D564B395} - - {416459B4-BDA4-31D6-834A-88932E767F37} - {2C910562-8D0A-B115-B829-556779436F2F} @@ -708,9 +705,6 @@ beast\asio\tests - - beast\asio - beast\boost @@ -4548,39 +4542,6 @@ ripple\unity - - ripple\unl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl\impl - - - ripple\unl - ripple\unl\tests @@ -4590,9 +4551,6 @@ ripple\unl\tests - - ripple\unl - ripple\websocket diff --git a/src/BeastConfig.h b/src/BeastConfig.h index 4bd22f61a..485130755 100644 --- a/src/BeastConfig.h +++ b/src/BeastConfig.h @@ -164,13 +164,6 @@ #define RIPPLE_SINGLE_IO_SERVICE_THREAD 0 #endif -/** Config: RIPPLE_HOOK_VALIDATORS - Activates code for handling validations and validators (work in progress). -*/ -#ifndef RIPPLE_HOOK_VALIDATORS -#define RIPPLE_HOOK_VALIDATORS 0 -#endif - /** Config: RIPPLE_ENABLE_TICKETS Enables processing of ticket transactions */ diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index 7866d9fcb..530ea2d47 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include // @@ -276,11 +275,6 @@ public: getApp().getSHAMapStore().onLedgerClosed (getValidatedLedger()); mLedgerHistory.validatedLedger (l); getApp().getAmendmentTable().doValidatedLedger (l); - - #if RIPPLE_HOOK_VALIDATORS - getApp().getValidators().onLedgerClosed (l->info().seq, - l->getHash(), l->info().parentHash); - #endif } void setPubLedger(Ledger::ref l) diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 98417e6ce..bbcafa53d 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -64,7 +64,6 @@ #include #include #include -#include #include #include #include @@ -291,7 +290,6 @@ public: std::unique_ptr m_networkOPs; std::unique_ptr m_deprecatedUNL; std::unique_ptr serverHandler_; - std::unique_ptr m_validators; std::unique_ptr m_amendmentTable; std::unique_ptr mFeeTrack; std::unique_ptr mHashRouter; @@ -407,9 +405,6 @@ public: , serverHandler_ (make_ServerHandler (*m_networkOPs, get_io_service (), *m_jobQueue, *m_networkOPs, *m_resourceManager, *m_collectorManager)) - , m_validators (unl::make_Manager(*this, get_io_service(), - m_logs.journal("UNL"), getConfig ())) - , m_amendmentTable (make_AmendmentTable (weeks(2), MAJORITY_FRACTION, m_logs.journal("AmendmentTable"))) @@ -453,7 +448,6 @@ public: // VFALCO HACK m_nodeStoreScheduler.setJobQueue (*m_jobQueue); - add (*m_validators); add (m_ledgerMaster->getPropertySource ()); add (*serverHandler_); } @@ -570,11 +564,6 @@ public: return cachedSLEs_; } - unl::Manager& getValidators () - { - return *m_validators; - } - AmendmentTable& getAmendmentTable() { return *m_amendmentTable; diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h index c169867a7..9d6d4f44f 100644 --- a/src/ripple/app/main/Application.h +++ b/src/ripple/app/main/Application.h @@ -98,7 +98,6 @@ public: virtual JobQueue& getJobQueue () = 0; virtual NodeCache& getTempNodeCache () = 0; virtual CachedSLEs& cachedSLEs() = 0; - virtual unl::Manager& getValidators () = 0; virtual AmendmentTable& getAmendmentTable() = 0; virtual IHashRouter& getHashRouter () = 0; virtual LoadFeeTrack& getFeeTrack () = 0; diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index b6a914b1c..9b00fe2e0 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -111,18 +111,6 @@ OverlayImpl::Timer::on_timer (error_code ec) overlay_.sendEndpoints(); overlay_.autoConnect(); - { - std::lock_guard< - std::recursive_mutex> lock (overlay_.mutex_); - for (auto const& e : overlay_.m_publicKeyMap) - { - auto const sp = e.second.lock(); - if (sp) - if (sp->unlHorizon_->shouldDrop()) - sp->fail("Poor UNL horizon"); - } - } - if ((++overlay_.timer_count_ % Tuning::checkSeconds) == 0) overlay_.check(); diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index 609c649e8..01c274aad 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -81,8 +81,6 @@ PeerImp::PeerImp (id_t id, endpoint_type remote_endpoint, , fee_ (Resource::feeLightPeer) , slot_ (slot) , http_message_(std::move(request)) - , unlHorizon_(getApp().getValidators().insert(id, - slotToHorizonKind(*slot_))) { } @@ -1806,11 +1804,6 @@ PeerImp::checkValidation (Job&, STValidation::pointer val, return; } - #if RIPPLE_HOOK_VALIDATORS - getApp().getValidators().onMessage( - unlHorizon_, *packet, *val); - #endif - if (getApp().getOPs ().recvValidation( val, std::to_string(id()))) overlay_.relay(*packet, signingHash); diff --git a/src/ripple/overlay/impl/PeerImp.h b/src/ripple/overlay/impl/PeerImp.h index 27f9cad2c..68cfe3e0f 100644 --- a/src/ripple/overlay/impl/PeerImp.h +++ b/src/ripple/overlay/impl/PeerImp.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -160,7 +160,6 @@ private: int large_sendq_ = 0; int no_ping_ = 0; std::unique_ptr load_event_; - std::unique_ptr unlHorizon_; bool hopsAware_ = false; friend class OverlayImpl; @@ -436,16 +435,6 @@ private: state_ = new_state; } - unl::Horizon::Kind - slotToHorizonKind (PeerFinder::Slot const& slot) - { - if(slot.fixed()) - return unl::Horizon::kindTrusted; - if(slot.inbound()) - return unl::Horizon::kindUntrusted; - return unl::Horizon::kindManaged; - } - //-------------------------------------------------------------------------- void @@ -521,8 +510,6 @@ PeerImp::PeerImp (std::unique_ptr&& ssl_bundle, , fee_ (Resource::feeLightPeer) , slot_ (std::move(slot)) , http_message_(std::move(response)) - , unlHorizon_(getApp().getValidators().insert(id, - slotToHorizonKind(*slot_))) { read_buffer_.commit (boost::asio::buffer_copy(read_buffer_.prepare( boost::asio::buffer_size(buffers)), buffers)); diff --git a/src/ripple/unity/unl.cpp b/src/ripple/unity/unl.cpp index 71929aa10..107b1eb20 100644 --- a/src/ripple/unity/unl.cpp +++ b/src/ripple/unity/unl.cpp @@ -19,10 +19,5 @@ #include -#include -#include -#include -#include - #include #include diff --git a/src/ripple/unl/Horizon.h b/src/ripple/unl/Horizon.h deleted file mode 100644 index 7e9b4fe11..000000000 --- a/src/ripple/unl/Horizon.h +++ /dev/null @@ -1,54 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_HORIZON_H_INCLUDED -#define RIPPLE_UNL_HORIZON_H_INCLUDED - -namespace ripple { -namespace unl { - -/** Maintains validator horizon statistics on a connection. */ -class Horizon -{ -public: - enum Kind - { - /* Outbound made by autoconnect. - Can be dropped. - */ - kindManaged, - - /* Inbound. */ - kindUntrusted, - - /* Fixed or cluster peer. - Can't be dropped. - */ - kindTrusted - }; - - virtual ~Horizon() = default; - - virtual bool shouldDrop() = 0; -}; - -} -} - -#endif diff --git a/src/ripple/unl/UNLManager.h b/src/ripple/unl/UNLManager.h deleted file mode 100644 index 2dd9acd64..000000000 --- a/src/ripple/unl/UNLManager.h +++ /dev/null @@ -1,83 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_MANAGER_H_INCLUDED -#define RIPPLE_UNL_MANAGER_H_INCLUDED - -#include "ripple.pb.h" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ripple { -namespace unl { - -/** Maintains the list of chosen validators. - The algorithm for acquiring, building, and calculating metadata on - the list of chosen validators is critical to the health of the network. - All operations are performed asynchronously on an internal thread. -*/ -class Manager : public beast::PropertyStream::Source -{ -protected: - Manager(); - -public: - /** Destroy the object. - Any pending source fetch operations are aborted. This will block - until any pending database I/O has completed and the thread has - stopped. - */ - virtual ~Manager() = default; - - virtual - std::unique_ptr - insert (int id, Horizon::Kind kind) = 0; - - virtual - void - erase (std::unique_ptr c) = 0; - - /** Called when a signed validation is received - Preconditions: - Signature check passed - Effects: - */ - virtual - void - onMessage (std::unique_ptr const& h, - protocol::TMValidation const& m, - STValidation const& v) = 0; - - /** Called when a ledger is built. */ - virtual - void - onLedgerClosed (LedgerIndex index, - LedgerHash const& hash, LedgerHash const& parent) = 0; -}; - -} -} - -#endif diff --git a/src/ripple/unl/impl/BasicHorizon.cpp b/src/ripple/unl/impl/BasicHorizon.cpp deleted file mode 100644 index da958c71b..000000000 --- a/src/ripple/unl/impl/BasicHorizon.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include - -namespace ripple { -namespace unl { - -} -} diff --git a/src/ripple/unl/impl/BasicHorizon.h b/src/ripple/unl/impl/BasicHorizon.h deleted file mode 100644 index 7fce1e09a..000000000 --- a/src/ripple/unl/impl/BasicHorizon.h +++ /dev/null @@ -1,254 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_BASICHORIZON_H_INCLUDED -#define RIPPLE_UNL_BASICHORIZON_H_INCLUDED - -#include "ripple.pb.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace ripple { -namespace unl { - -class BasicHorizon - : public Horizon -{ -private: - using clock_type = beast::abstract_clock< - std::chrono::steady_clock>; - - // Metadata on a validation source - struct Source - { - // New sources are just at the threshold - double score = 0.8; - - // returns `true` if the score is high - // enough to count as available - bool - available() const - { - return score >= 0.8; - } - - // returns `true` if the score is so low we - // have no expectation of seeing the validator again - bool - gone() const - { - return score <= 0.2; - } - - // returns `true` if became unavailable - bool - onHit() - { - bool const prev = available(); - score = 0.90 * score + 0.10; - if (! prev && available()) - return true; - return false; - } - - // returns `true` if became available - bool - onMiss() - { - bool const prev = available(); - score = 0.90 * score; - if (prev && ! available()) - return true; - return false; - } - }; - - using Item = std::pair; - - clock_type& clock_; - clock_type::time_point const start_; - beast::WrappedSink sink_; - beast::Journal journal_; - Kind const kind_; - std::mutex mutex_; - boost::optional ledger_; - boost::container::flat_set items_; - boost::container::flat_map sources_; - boost::container::flat_set good_; - std::set view_; - - boost::optional< - clock_type::time_point> lastHops1_; - - static - std::string - makePrefix (int id) - { - std::stringstream ss; - ss << "[" << std::setfill('0') << std::setw(3) << id << "] "; - return ss.str(); - } - -public: - BasicHorizon (int id, Kind kind, - beast::Journal journal, clock_type& clock) - : clock_ (clock) - , start_ (clock_.now()) - , sink_ (journal, makePrefix(id)) - , journal_ (sink_) - , kind_ (kind) - { - } - - ~BasicHorizon() - { - } - - bool - shouldDrop() override - { - std::lock_guard lock(mutex_); - auto const now = clock_.now(); - if ((now - start_) < std::chrono::minutes{1}) - return false; - if (! lastHops1_) - return true; - return (*lastHops1_ - now) >= - std::chrono::minutes{1}; - } - - Kind kind() const - { - return kind_; - } - - // Returns the current set of synchronized - // validators seen on this horizon. - // - std::set - view() const - { - return view_; - } - - void - onMessage (protocol::TMValidation const& m, - STValidation const& v) - { - //if (m.hops() == 1) - if (m.has_hops()) - { - // directly connected - lastHops1_ = clock_.now(); - } - - auto const key = v.getSignerPublic(); - auto const ledger = v.getLedgerHash(); - - { - std::lock_guard lock(mutex_); - if (! items_.emplace(ledger, key).second) - return; - if (journal_.debug) journal_.debug << - "onMessage: hops=" << m.hops() << - ", ledger=" << ledger; -#if 0 - auto const result = sources_.emplace( - std::piecewise_construct, std::make_tuple(key), - std::make_tuple()); -#else - // Work-around for boost::container - auto const result = sources_.emplace(key, Source{}); -#endif - if (result.second) - good_.insert(key); - // register a hit for slightly late validations - if (ledger_ && ledger == ledger_) - if (result.first->second.onHit()) - good_.insert(key); - } - } - - // Called when a supermajority of - // validations are received for the next ledger. - void - onLedger (LedgerHash const& ledger) - { - std::lock_guard lock(mutex_); - if (journal_.trace) journal_.trace << - "onLedger: " << ledger; - assert(ledger != ledger_); - ledger_ = ledger; - auto item = items_.lower_bound( - std::make_pair(ledger, RippleAddress())); - auto source = sources_.begin(); - while (item != items_.end() && - source != sources_.end() && - item->first == ledger) - { - if (item->second < source->first) - { - ++item; - } - else if (item->second == source->first) - { - if (source->second.onHit()) - good_.insert(source->first); - ++item; - ++source; - } - else - { - if (source->second.onMiss()) - good_.erase(source->first); - ++source; - } - } - while (source != sources_.end()) - { - if (source->second.onMiss()) - good_.erase(source->first); - ++source; - } - // VFALCO What if there are validations - // for the ledger AFTER this one in the map? - items_.clear(); - } -}; - -} -} - -#endif diff --git a/src/ripple/unl/impl/Logic.cpp b/src/ripple/unl/impl/Logic.cpp deleted file mode 100644 index 344fe0da8..000000000 --- a/src/ripple/unl/impl/Logic.cpp +++ /dev/null @@ -1,150 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include - -/* - -Questions the code should answer: - -Most important thing that we do: - Determine the new last fully validated ledger - - - -- Are we robustly connected to the Ripple network? - -- Given a new recent validation for a ledger with a sequence number higher - than the last fully validated ledger, do we have a new last fully validated - ledger? - -- What's the latest fully validated ledger? - - Sequence number must always be known to set a fully validated ledger - - Accumulate validations from nodes you trust at least a little bit, - and that aren't stale. - - If you have a last fully validated ledger then validations for ledgers - with lower sequence numbers can be ignored. - - Flow of validations recent in time for sequence numbers greater or equal than - the last fully validated ledger. - -- What ledger is the current consenus round built on? - -- Determine when the current consensus round is over? - Criteria: Number of validations for a ledger that comes after. - -*/ - -namespace ripple { -namespace unl { - -Logic::Logic (Store& store, beast::Journal journal) - : /*store_ (store) - , */journal_ (journal) - , ledgers_(stopwatch()) -{ -} - -void -Logic::stop() -{ -} - -void -Logic::load() -{ -} - -void -Logic::insert (BasicHorizon& c) -{ - std::lock_guard lock(mutex_); - connections_.insert(&c); -} - -void -Logic::erase (BasicHorizon& c) -{ - std::lock_guard lock(mutex_); - connections_.erase(&c); -} - -bool -Logic::isStale (STValidation const& v) -{ - return false; -} - -void -Logic::onTimer() -{ - std::lock_guard lock(mutex_); - beast::expire(ledgers_, std::chrono::minutes(5)); -} - -void -Logic::onMessage (protocol::TMValidation const& m, - STValidation const& v) -{ - assert(v.isFieldPresent (sfLedgerSequence)); - auto const seq_no = - v.getFieldU32 (sfLedgerSequence); - auto const key = v.getSignerPublic(); - auto const ledger = v.getLedgerHash(); - - std::lock_guard lock(mutex_); - if (journal_.trace) journal_.trace << - "onValidation: " << ledger; - auto const result = ledgers_.emplace (std::piecewise_construct, - std::make_tuple(ledger), std::make_tuple()); - auto& meta = result.first->second; - assert(result.second || seq_no == meta.seq_no); - if (result.second) - meta.seq_no = seq_no; - meta.keys.insert (v.getSignerPublic()); - if (meta.seq_no > latest_.second.seq_no) - { - if (policy_.acceptLedgerMeta (*result.first)) - { - //ledgers_.clear(); - latest_ = *result.first; - if (journal_.trace) journal_.trace << - "Accepted " << latest_.second.seq_no << - " (" << ledger << ")"; - for (auto& _ : connections_) - _->onLedger(latest_.first); - } - } -} - -void -Logic::onLedgerClosed (LedgerIndex index, - LedgerHash const& hash, LedgerHash const& parent) -{ - if (journal_.trace) journal_.trace << - "onLedgerClosed: " << index << " " << hash << " (parent " << parent << ")"; -} - -} -} diff --git a/src/ripple/unl/impl/Logic.h b/src/ripple/unl/impl/Logic.h deleted file mode 100644 index d1f046785..000000000 --- a/src/ripple/unl/impl/Logic.h +++ /dev/null @@ -1,113 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_LOGIC_H_INCLUDED -#define RIPPLE_UNL_LOGIC_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ripple { -namespace unl { - -class BasicHorizon; - -class Logic -{ -private: - struct LedgerMeta - { - std::uint32_t seq_no = 0; - std::unordered_set> keys; - }; - - class Policy - { - public: - /** Returns `true` if we should accept this as the last validated. */ - bool - acceptLedgerMeta (std::pair const& value) - { - return value.second.keys.size() >= 3; // quorum - } - }; - - std::mutex mutex_; - //Store& store_; - beast::Journal journal_; - - Policy policy_; - beast::aged_unordered_map > ledgers_; - std::pair latest_; // last fully validated - boost::container::flat_set connections_; - -public: - explicit - Logic (Store& store, beast::Journal journal); - - beast::Journal const& - journal() const - { - return journal_; - } - - void stop(); - - void load(); - - void - insert (BasicHorizon& c); - - void - erase (BasicHorizon& c); - - bool - isStale (STValidation const& v); - - void - onTimer(); - - void - onMessage (protocol::TMValidation const& m, - STValidation const& v); - - void - onLedgerClosed (LedgerIndex index, - LedgerHash const& hash, LedgerHash const& parent); -}; - -} -} - -#endif diff --git a/src/ripple/unl/impl/Store.h b/src/ripple/unl/impl/Store.h deleted file mode 100644 index 6d3ee1aa4..000000000 --- a/src/ripple/unl/impl/Store.h +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_STORE_H_INCLUDED -#define RIPPLE_UNL_STORE_H_INCLUDED - -namespace ripple { -namespace unl { - -/** Abstract persistence for Validators data. */ -class Store -{ -public: - virtual ~Store() = default; -}; - -} -} - -#endif diff --git a/src/ripple/unl/impl/StoreSqdb.cpp b/src/ripple/unl/impl/StoreSqdb.cpp deleted file mode 100644 index d319838ea..000000000 --- a/src/ripple/unl/impl/StoreSqdb.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include - -namespace ripple { -namespace unl { - -StoreSqdb::StoreSqdb (beast::Journal journal) - : m_journal (journal) -{ -} - -StoreSqdb::~StoreSqdb () -{ -} - -void -StoreSqdb::open (SociConfig const& sociConfig) -{ - m_journal.info << "Opening " << sociConfig.connectionString (); - sociConfig.open (m_session); -} - -} -} diff --git a/src/ripple/unl/impl/StoreSqdb.h b/src/ripple/unl/impl/StoreSqdb.h deleted file mode 100644 index 4a56b3761..000000000 --- a/src/ripple/unl/impl/StoreSqdb.h +++ /dev/null @@ -1,57 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_STORESQDB_H_INCLUDED -#define RIPPLE_UNL_STORESQDB_H_INCLUDED - -#include -#include -#include -#include - -namespace ripple { -namespace unl { - -/** Database persistence for Validators using SQLite */ -class StoreSqdb : public Store -{ -private: - beast::Journal m_journal; - soci::session m_session; - -public: - enum - { - // This affects the format of the data! - currentSchemaVersion = 1 - }; - - explicit - StoreSqdb (beast::Journal journal); - - ~StoreSqdb(); - - void - open (SociConfig const& sociConfig); -}; - -} -} - -#endif diff --git a/src/ripple/unl/impl/Tuning.h b/src/ripple/unl/impl/Tuning.h deleted file mode 100644 index a8a1ee735..000000000 --- a/src/ripple/unl/impl/Tuning.h +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_TUNING_H_INCLUDED -#define RIPPLE_UNL_TUNING_H_INCLUDED - -namespace ripple { -namespace unl { - -} -} - -#endif diff --git a/src/ripple/unl/impl/UNLManager.cpp b/src/ripple/unl/impl/UNLManager.cpp deleted file mode 100644 index 7cf0d7bd4..000000000 --- a/src/ripple/unl/impl/UNLManager.cpp +++ /dev/null @@ -1,354 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include // - -/** ChosenValidators (formerly known as UNL) - - Motivation: - - To protect the integrity of the shared ledger data structure, Validators - independently sign LedgerHash objects with their RipplePublicKey. These - signed Validations are propagated through the peer to peer network so - that other nodes may inspect them. Every peer and client on the network - gains confidence in a ledger and its associated chain of previous ledgers - by maintaining a suitably sized list of Validator public keys that it - trusts. - - The most important factors in choosing Validators for a ChosenValidators - list (the name we will use to designate such a list) are the following: - - - That different Validators are not controlled by one entity - - That each Validator participates in a majority of ledgers - - That a Validator does not sign ledgers which fail consensus - - This module maintains ChosenValidators list. The list is built from a set - of independent Source objects, which may come from the configuration file, - a separate file, a URL from some trusted domain, or from the network itself. - - In order that rippled administrators may publish their ChosenValidators - list at a URL on a trusted domain that they own, this module compiles - statistics on ledgers signed by validators and stores them in a database. - From this database reports and alerts may be generated so that up-to-date - information about the health of the set of ChosenValidators is always - availabile. - - In addition to the automated statistics provided by the module, it is - expected that organizations and meta-organizations will form from - stakeholders such as gateways who publish their own lists and provide - "best practices" to further refine the quality of validators placed into - ChosenValidators list. - - - ---------------------------------------------------------------------------- - - Unorganized Notes: - - David: - Maybe RL should have a URL that you can query to get the latest list of URI's - for RL-approved organzations that publish lists of validators. The server and - client can ship with that master trust URL and also the list of URI's at the - time it's released, in case for some reason it can't pull from RL. That would - make the default installation safe even against major changes in the - organizations that publish validator lists. - - The difference is that if an organization that provides lists of validators - goes rogue, administrators don't have to act. - - TODO: - Write up from end-user perspective on the deployment and administration - of this feature, on the wiki. "DRAFT" or "PROPOSE" to mark it as provisional. - Template: https://ripple.com/wiki/Federation_protocol - - What to do if you're a publisher of ValidatorList - - What to do if you're a rippled administrator - - Overview of how ChosenValidators works - - Goals: - Make default configuration of rippled secure. - * Ship with TrustedUriList - * Also have a preset RankedValidators - Eliminate administrative burden of maintaining - Produce the ChosenValidators list. - Allow quantitative analysis of network health. - - What determines that a validator is good? - - Are they present (i.e. sending validations) - - Are they on the consensus ledger - - What percentage of consensus rounds do they participate in - - Are they stalling consensus - * Measurements of constructive/destructive behavior is - calculated in units of percentage of ledgers for which - the behavior is measured. - - What we want from the unique node list: - - Some number of trusted roots (known by domain) - probably organizations whose job is to provide a list of validators - - We imagine the IRGA for example would establish some group whose job is to - maintain a list of validators. There would be a public list of criteria - that they would use to vet the validator. Things like: - * Not anonymous - * registered business - * Physical location - * Agree not to cease operations without notice / arbitrarily - * Responsive to complaints - - Identifiable jurisdiction - * Homogeneity in the jurisdiction is a business risk - * If all validators are in the same jurisdiction this is a business risk - - OpenCoin sets criteria for the organizations - - Rippled will ship with a list of trusted root "certificates" - In other words this is a list of trusted domains from which the software - can contact each trusted root and retrieve a list of "good" validators - and then do something with that information - - All the validation information would be public, including the broadcast - messages. - - The goal is to easily identify bad actors and assess network health - * Malicious intent - * Or, just hardware problems (faulty drive or memory) - - -*/ - -#include -#include - -namespace ripple { - -/** Executor which dispatches to JobQueue threads at a given JobType. */ -class job_executor -{ -private: - struct impl - { - impl (JobQueue& ex_, JobType type_, std::string const& name_) - : ex(ex_), type(type_), name(name_) - { - } - - JobQueue& ex; - JobType type; - std::string name; - }; - - std::shared_ptr impl_; - -public: - job_executor (JobType type, std::string const& name, - JobQueue& ex) - : impl_(std::make_shared(ex, type, name)) - { - } - - template - void - post (Handler&& handler) - { - impl_->ex.addJob(impl_->type, impl_->name, - std::forward(handler)); - } - - template - void - dispatch (Handler&& handler) - { - impl_->ex.addJob(impl_->type, impl_->name, - std::forward(handler)); - } - - template - void - defer (Handler&& handler) - { - impl_->ex.addJob(impl_->type, impl_->name, - std::forward(handler)); - } -}; - -//------------------------------------------------------------------------------ - -namespace unl { - -// template -class ManagerImp - : public Manager - , public beast::Stoppable -{ -public: - boost::asio::io_service& io_service_; - boost::asio::io_service::strand strand_; - beast::asio::waitable_executor exec_; - boost::asio::basic_waitable_timer< - std::chrono::steady_clock> timer_; - beast::Journal journal_; - StoreSqdb store_; - Logic logic_; - SociConfig sociConfig_; - - ManagerImp (Stoppable& parent, boost::asio::io_service& io_service, - beast::Journal journal, BasicConfig const& config) - : Stoppable ("Validators::Manager", parent) - , io_service_(io_service) - , strand_(io_service_) - , timer_(io_service_) - , journal_ (journal) - , store_ (journal_) - , logic_ (store_, journal_) - , sociConfig_ (config, "validators") - { - } - - ~ManagerImp() - { - } - - //-------------------------------------------------------------------------- - // - // Manager - // - //-------------------------------------------------------------------------- - - std::unique_ptr - insert (int id, Horizon::Kind kind) override - { - auto c = std::make_unique( - id, kind, logic_.journal(), stopwatch()); - logic_.insert(*c); - return std::move(c); - } - - void - erase (std::unique_ptr c) override - { - logic_.erase(dynamic_cast(*c)); - } - - void - onMessage (std::unique_ptr const& h, - protocol::TMValidation const& m, - STValidation const& v) override - { - if (! m.has_hops()) - return; - auto& hi = dynamic_cast(*h); - hi.onMessage(m, v); - logic_.onMessage(m, v); - } - - void - onLedgerClosed (LedgerIndex index, - LedgerHash const& hash, LedgerHash const& parent) override - { - logic_.onLedgerClosed (index, hash, parent); - } - - //-------------------------------------------------------------------------- - // - // Stoppable - // - //-------------------------------------------------------------------------- - - void onPrepare() - { - init(); - } - - void onStart() - { - } - - void onStop() - { - boost::system::error_code ec; - timer_.cancel(ec); - - logic_.stop(); - - exec_.async_wait([this]() { stopped(); }); - } - - //-------------------------------------------------------------------------- - // - // PropertyStream - // - //-------------------------------------------------------------------------- - - void onWrite (beast::PropertyStream::Map& map) - { - } - - //-------------------------------------------------------------------------- - // - // ManagerImp - // - //-------------------------------------------------------------------------- - - void init() - { - store_.open (sociConfig_); - logic_.load (); - } - - void - onTimer (boost::system::error_code ec) - { - if (ec) - { - if (ec != boost::asio::error::operation_aborted) - journal_.error << - "onTimer: " << ec.message(); - return; - } - - logic_.onTimer(); - - timer_.expires_from_now(std::chrono::seconds(1), ec); - timer_.async_wait(strand_.wrap(exec_.wrap( - std::bind(&ManagerImp::onTimer, this, - beast::asio::placeholders::error)))); - } -}; - -//------------------------------------------------------------------------------ - -Manager::Manager () - : beast::PropertyStream::Source ("validators") -{ -} - -std::unique_ptr -make_Manager(beast::Stoppable& parent, - boost::asio::io_service& io_service, - beast::Journal journal, - BasicConfig const& config) -{ - return std::make_unique(parent, - io_service, journal, config); -} -} -} diff --git a/src/ripple/unl/make_Manager.h b/src/ripple/unl/make_Manager.h deleted file mode 100644 index eab96aa43..000000000 --- a/src/ripple/unl/make_Manager.h +++ /dev/null @@ -1,43 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_UNL_MAKE_MANAGER_H_INCLUDED -#define RIPPLE_UNL_MAKE_MANAGER_H_INCLUDED - -#include -#include -#include -#include -#include -#include - -namespace ripple { -class BasicConfig; -namespace unl { - -std::unique_ptr -make_Manager (beast::Stoppable& stoppableParent, - boost::asio::io_service& io_service, - beast::Journal journal, - BasicConfig const& config); - -} -} - -#endif