From be1f734845ac763ce51d61507c9ba6cf18fc3cfb Mon Sep 17 00:00:00 2001 From: Mark Travis Date: Sun, 6 Aug 2017 23:28:15 -0700 Subject: [PATCH 1/3] Make amendment blocked state thread-safe & simplify a constructor. --- src/ripple/app/misc/NetworkOPs.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 22dc5512ea8..380559859b0 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -193,8 +193,6 @@ class NetworkOPsImp final , m_journal (journal) , m_localTX (make_LocalTxs ()) , mMode (start_valid ? omFULL : omDISCONNECTED) - , mNeedNetworkLedger (false) - , m_amendmentBlocked (false) , heartbeatTimer_ (io_svc) , clusterTimer_ (io_svc) , mConsensus (app, @@ -210,7 +208,6 @@ class NetworkOPsImp final , m_job_queue (job_queue) , m_standalone (standalone) , m_network_quorum (start_valid ? 0 : network_quorum) - , accounting_ () { } @@ -338,23 +335,23 @@ class NetworkOPsImp final void needNetworkLedger () override { - mNeedNetworkLedger = true; + needNetworkLedger_ = true; } void clearNeedNetworkLedger () override { - mNeedNetworkLedger = false; + needNetworkLedger_ = false; } bool isNeedNetworkLedger () override { - return mNeedNetworkLedger; + return needNetworkLedger_; } bool isFull () override { - return !mNeedNetworkLedger && (mMode == omFULL); + return !needNetworkLedger_ && (mMode == omFULL); } bool isAmendmentBlocked () override { - return m_amendmentBlocked; + return amendmentBlocked_; } void setAmendmentBlocked () override; void consensusViewChange () override; @@ -548,8 +545,8 @@ class NetworkOPsImp final std::atomic mMode; - std::atomic mNeedNetworkLedger; - bool m_amendmentBlocked; + std::atomic needNetworkLedger_ {false}; + std::atomic amendmentBlocked_ {false}; ClosureCounter waitHandlerCounter_; boost::asio::steady_timer heartbeatTimer_; @@ -597,7 +594,7 @@ class NetworkOPsImp final DispatchState mDispatchState = DispatchState::none; std::vector mTransactions; - StateAccounting accounting_; + StateAccounting accounting_ {}; }; //------------------------------------------------------------------------------ @@ -1258,7 +1255,7 @@ Json::Value NetworkOPsImp::getOwnerInfo ( void NetworkOPsImp::setAmendmentBlocked () { - m_amendmentBlocked = true; + amendmentBlocked_ = true; setMode (omTRACKING); } @@ -1585,7 +1582,7 @@ void NetworkOPsImp::endConsensus () // Count number of peers that agree with us and UNL nodes whose // validations we have for LCL. If the ledger is good enough, go to // omTRACKING - TODO - if (!mNeedNetworkLedger) + if (!needNetworkLedger_) setMode (omTRACKING); } @@ -1852,7 +1849,7 @@ void NetworkOPsImp::setMode (OperatingMode om) om = omCONNECTED; } - if ((om > omTRACKING) && m_amendmentBlocked) + if ((om > omTRACKING) && amendmentBlocked_) om = omTRACKING; if (mMode == om) @@ -2151,7 +2148,7 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin) info [jss::server_state] = strOperatingMode (); - if (mNeedNetworkLedger) + if (needNetworkLedger_) info[jss::network_ledger] = "waiting"; info[jss::validation_quorum] = static_cast( @@ -2181,7 +2178,7 @@ Json::Value NetworkOPsImp::getServerInfo (bool human, bool admin) info[jss::complete_ledgers] = app_.getLedgerMaster ().getCompleteLedgers (); - if (m_amendmentBlocked) + if (amendmentBlocked_) info[jss::amendment_blocked] = true; auto const fp = m_ledgerMaster.getFetchPackCacheSize (); From a02a469b20198f921deb4fddc3d1ef928b313aee Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Mon, 14 Aug 2017 16:44:18 -0400 Subject: [PATCH 2/3] Fix unit test compiler warnings --- src/test/app/Flow_test.cpp | 9 +++++---- src/test/app/Offer_test.cpp | 7 +++---- src/test/beast/aged_associative_container_test.cpp | 7 +++++++ src/test/ledger/Invariants_test.cpp | 4 ++-- src/test/ledger/PaymentSandbox_test.cpp | 6 +++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 521addc5c3c..89393dfcc32 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -747,8 +747,9 @@ struct Flow_test : public beast::unit_test::suite auto const timeDelta = Env{*this}.closed ()->info ().closeTimeResolution; - for(auto const& d: {-timeDelta*100, +timeDelta*100}){ - auto const closeTime = fix1141Time () + d; + for (auto const& d : {-100 * timeDelta, +100 * timeDelta}) + { + auto const closeTime = fix1141Time () + d ; Env env (*this, no_features); env.close (closeTime); @@ -1112,7 +1113,7 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; Env env(*this, with_features(featureFlow)); auto const timeDelta = env.closed ()->info ().closeTimeResolution; - auto const d = withFix ? timeDelta*100 : -timeDelta*100; + auto const d = withFix ? 100*timeDelta : -100*timeDelta; auto closeTime = fix1443Time() + d; env.close(closeTime); @@ -1165,7 +1166,7 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; Env env(*this, with_features(featureFlow)); auto const timeDelta = env.closed ()->info ().closeTimeResolution; - auto const d = withFix ? timeDelta*100 : -timeDelta*100; + auto const d = withFix ? 100*timeDelta : -100*timeDelta; auto closeTime = fix1449Time() + d; env.close(closeTime); diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index db668540981..003b4c06e1b 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -253,11 +253,10 @@ class Offer_test : public beast::unit_test::suite for (int i=0;i<101;++i) env (offer (carol, USD (1), EUR (2))); - for (auto timeDelta : { - - env.closed()->info().closeTimeResolution, - env.closed()->info().closeTimeResolution} ) + for (auto d : {-1, 1}) { - auto const closeTime = STAmountSO::soTime + timeDelta; + auto const closeTime = STAmountSO::soTime + + d * env.closed()->info().closeTimeResolution; env.close (closeTime); *stAmountCalcSwitchover = closeTime > STAmountSO::soTime; // Will fail without the underflow fix diff --git a/src/test/beast/aged_associative_container_test.cpp b/src/test/beast/aged_associative_container_test.cpp index 8c2354a2f57..0f6e5fe3323 100644 --- a/src/test/beast/aged_associative_container_test.cpp +++ b/src/test/beast/aged_associative_container_test.cpp @@ -142,6 +142,13 @@ class aged_associative_container_test_base : public unit_test::suite return true; } + template + bool operator!= (AllocT const& o) const + { + return !(*this == o); + } + + T* allocate (std::size_t n, T const* = 0) { return static_cast ( diff --git a/src/test/ledger/Invariants_test.cpp b/src/test/ledger/Invariants_test.cpp index 65f35805ac1..c59d9de0cf4 100644 --- a/src/test/ledger/Invariants_test.cpp +++ b/src/test/ledger/Invariants_test.cpp @@ -250,7 +250,7 @@ class Invariants_test : public beast::unit_test::suite auto const sle = ac.view().peek (keylet::account(A1.id())); if(! sle) return false; - STAmount nonNative {A2["USD"](51)}; + STAmount nonNative (A2["USD"](51)); sle->setFieldAmount (sfBalance, nonNative); ac.view().update (sle); return true; @@ -366,7 +366,7 @@ class Invariants_test : public beast::unit_test::suite return false; auto sleNew = std::make_shared ( keylet::escrow(A1, (*sle)[sfSequence] + 2)); - STAmount nonNative {A2["USD"](51)}; + STAmount nonNative (A2["USD"](51)); sleNew->setFieldAmount (sfAmount, nonNative); ac.view().insert (sleNew); return true; diff --git a/src/test/ledger/PaymentSandbox_test.cpp b/src/test/ledger/PaymentSandbox_test.cpp index 7cee87c662d..0ab0efef292 100644 --- a/src/test/ledger/PaymentSandbox_test.cpp +++ b/src/test/ledger/PaymentSandbox_test.cpp @@ -278,10 +278,10 @@ class PaymentSandbox_test : public beast::unit_test::suite STAmount hugeAmt (issue, STAmount::cMaxValue, STAmount::cMaxOffset - 1, false, false, STAmount::unchecked{}); - for (auto timeDelta : {-env.closed ()->info ().closeTimeResolution, - env.closed ()->info ().closeTimeResolution}) + for (auto d : {-1, 1}) { - auto const closeTime = fix1141Time () + timeDelta; + auto const closeTime = fix1141Time () + + d * env.closed()->info().closeTimeResolution; env.close (closeTime); ApplyViewImpl av (&*env.current (), tapNONE); PaymentSandbox pv (&av); From 589570daa330f80ad8c2b562be7a490d93c65e80 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Thu, 17 Aug 2017 12:42:12 -0700 Subject: [PATCH 3/3] Set version to 0.80.0-rc1 --- src/ripple/protocol/impl/BuildInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple/protocol/impl/BuildInfo.cpp b/src/ripple/protocol/impl/BuildInfo.cpp index a28cb716116..970c94335bf 100644 --- a/src/ripple/protocol/impl/BuildInfo.cpp +++ b/src/ripple/protocol/impl/BuildInfo.cpp @@ -34,7 +34,7 @@ char const* const versionString = // The build version number. You must edit this for each release // and follow the format described at http://semver.org/ // - "0.80.0-b5" + "0.80.0-rc1" #if defined(DEBUG) || defined(SANITIZER) "+"