From 5bbfe16520cd5edc768c12a16b1ce6b4cebf4c77 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 10 Jul 2013 17:01:53 -0700 Subject: [PATCH] Add validators sources --- Builds/VisualStudio2012/RippleD.vcxproj | 14 ++++ .../VisualStudio2012/RippleD.vcxproj.filters | 15 ++++ TODO.txt | 84 +++++++++++++++++++ modules/ripple_core/ripple_core.cpp | 5 +- modules/ripple_core/ripple_core.h | 3 + .../validator/ripple_Validator.cpp | 9 ++ .../ripple_core/validator/ripple_Validator.h | 25 ++++++ .../validator/ripple_Validators.cpp | 46 ++++++++++ .../ripple_core/validator/ripple_Validators.h | 36 ++++++++ 9 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 modules/ripple_core/validator/ripple_Validator.cpp create mode 100644 modules/ripple_core/validator/ripple_Validator.h create mode 100644 modules/ripple_core/validator/ripple_Validators.cpp create mode 100644 modules/ripple_core/validator/ripple_Validators.h diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj index 773a8f280..e05ac2cb0 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj +++ b/Builds/VisualStudio2012/RippleD.vcxproj @@ -355,6 +355,18 @@ true + + true + true + true + true + + + true + true + true + true + true true @@ -1416,6 +1428,8 @@ + + diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters index 57af2fa0a..4f60dee99 100644 --- a/Builds/VisualStudio2012/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters @@ -154,6 +154,9 @@ {571acd5b-065c-4202-8de3-8692735171dc} + + {efccddf1-024d-41c4-b7f5-26ce2dd79f21} + @@ -837,6 +840,12 @@ [1] Ripple\ripple_app\data + + [1] Ripple\ripple_core\validator + + + [1] Ripple\ripple_core\validator + [1] Ripple\ripple_app\ledger @@ -1596,6 +1605,12 @@ [1] Ripple\ripple_app\data + + [1] Ripple\ripple_core\validator + + + [1] Ripple\ripple_core\validator + [1] Ripple\ripple_app\ledger diff --git a/TODO.txt b/TODO.txt index 6cac78f23..e3b1e1ffb 100644 --- a/TODO.txt +++ b/TODO.txt @@ -294,3 +294,87 @@ What we want from the unique node list: * Malicious intent * Or, just hardware problems (faulty drive or memory) + + + + + +-------------------------------------------------------------------------------- + +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. + +Nouns + + Validator + - Signs ledgers and participate in consensus + - Fields + * Public key + * Friendly name + * Jurisdiction + * Org type: profit, nonprofit, "profit/gateway" + - Metadata + * Visible on the network? + * On the consensus ledger? + * Percentage of recent participation in consensus + * Frequency of stalling the consensus process + + ValidatorSource + - Abstract + - Provides a list of Validator + + ValidatorList + - Essentially an array of Validator + + TrustedUriValidatorSource + - ValidatorSource which uses HTTPS and a predefined URI + - Domain owner is responsible for removing bad validators + + TrustedUriValidatorSource::List + - Essentially an array of TrustedUriValidatorSource + - Can be read from a file + + LocalFileValidatorSource + - ValidatorSource which reads information from a local file. + +TrustedUriList // A copy of this ships with the app +* has a KnownValidators + +KnownValidators +* A series of KnownValidator that comes from a TrustedUri +* Persistent storage has a timestamp + +RankedValidators +* Created as the union of all KnownValidators with "weight" being the +number of appearances. + +ChosenValidators +* Result of the algorithm that chooses a random subset of RankedKnownValidators +* "local health" percentage is the percent of validations from this list that +you've seen recently. And have they been behaving. + +Process: + +For each TrustedUri: +Perform HTTPS request to retrieve a KnownValidators list + +Create the union of all unique KnownValidator, keyed by public key +- Calculate the number of appearances to determine the "weight" + +Algorithm: + +ChosenValidators chooseRandomSubset (RankedKnownValidators) diff --git a/modules/ripple_core/ripple_core.cpp b/modules/ripple_core/ripple_core.cpp index 96b4a79e1..421fff750 100644 --- a/modules/ripple_core/ripple_core.cpp +++ b/modules/ripple_core/ripple_core.cpp @@ -24,13 +24,16 @@ namespace ripple { #include "functional/ripple_Config.cpp" -#include "functional/ripple_LoadFeeTrack.h" // private + #include "functional/ripple_LoadFeeTrack.h" // private #include "functional/ripple_LoadFeeTrack.cpp" #include "functional/ripple_Job.cpp" #include "functional/ripple_JobQueue.cpp" #include "functional/ripple_LoadEvent.cpp" #include "functional/ripple_LoadMonitor.cpp" +#include "validator/ripple_Validator.cpp" +#include "validator/ripple_Validators.cpp" + } // These must be outside the namespace diff --git a/modules/ripple_core/ripple_core.h b/modules/ripple_core/ripple_core.h index 0535edad3..91575ec8c 100644 --- a/modules/ripple_core/ripple_core.h +++ b/modules/ripple_core/ripple_core.h @@ -37,6 +37,9 @@ namespace ripple /*.*/#include "functional/ripple_Job.h" /**/#include "functional/ripple_JobQueue.h" +#include "validator/ripple_Validator.h" +#include "validator/ripple_Validators.h" + } #endif diff --git a/modules/ripple_core/validator/ripple_Validator.cpp b/modules/ripple_core/validator/ripple_Validator.cpp new file mode 100644 index 000000000..a4cd57cff --- /dev/null +++ b/modules/ripple_core/validator/ripple_Validator.cpp @@ -0,0 +1,9 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. +*/ +//============================================================================== + +Validator::Validator () +{ +} diff --git a/modules/ripple_core/validator/ripple_Validator.h b/modules/ripple_core/validator/ripple_Validator.h new file mode 100644 index 000000000..310b2c655 --- /dev/null +++ b/modules/ripple_core/validator/ripple_Validator.h @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. +*/ +//============================================================================== + +#ifndef RIPPLE_VALIDATOR_H_INCLUDED +#define RIPPLE_VALIDATOR_H_INCLUDED + +/** Identifies a validator. + + A validator signs ledgers and participates in the consensus process. +*/ +class Validator +{ +public: + typedef RippleAddress PublicKey; + + Validator (); + +private: + PublicKey m_publicKey; +}; + +#endif diff --git a/modules/ripple_core/validator/ripple_Validators.cpp b/modules/ripple_core/validator/ripple_Validators.cpp new file mode 100644 index 000000000..360d8fba0 --- /dev/null +++ b/modules/ripple_core/validator/ripple_Validators.cpp @@ -0,0 +1,46 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. +*/ +//============================================================================== + +class ValidatorsImp + : public Validators + , private InterruptibleThread::EntryPoint +{ +public: + explicit ValidatorsImp (Listener* listener) + : m_thread ("Validators") + , m_listener (listener) + { + } + + ~ValidatorsImp () + { + } + + void addTrustedUri (String uri) + { + m_trustedUris.add (uri); + } + + void start () + { + m_thread.start (this); + } + + void threadRun () + { + // process the trustedUri list and blah blah + } + +private: + InterruptibleThread m_thread; + Listener* const m_listener; + StringArray m_trustedUris; +}; + +Validators* Validators::New (Listener* listener) +{ + return new ValidatorsImp (listener); +} diff --git a/modules/ripple_core/validator/ripple_Validators.h b/modules/ripple_core/validator/ripple_Validators.h new file mode 100644 index 000000000..a02584015 --- /dev/null +++ b/modules/ripple_core/validator/ripple_Validators.h @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. +*/ +//============================================================================== + +#ifndef RIPPLE_VALIDATORS_H_INCLUDED +#define RIPPLE_VALIDATORS_H_INCLUDED + +/** 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 Validators : Uncopyable +{ +public: + class Listener + { + public: + //virtual void onValidatorsChosen (ValidatorList validators) { } + }; + +public: + static Validators* New (Listener* listener); + + virtual ~Validators () { } + + virtual void addTrustedUri (String uri) = 0; + + virtual void start () = 0; +}; + +#endif