Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ledger stress test [DO NOT MERGE] #393

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
1 change: 1 addition & 0 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ if (tests)
src/test/app/LedgerLoad_test.cpp
src/test/app/LedgerMaster_test.cpp
src/test/app/LedgerReplay_test.cpp
src/test/app/LedgerStress_test.cpp
src/test/app/LoadFeeTrack_test.cpp
src/test/app/Manifest_test.cpp
src/test/app/MultiSign_test.cpp
Expand Down
28 changes: 21 additions & 7 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ class NetworkOPsImp final : public NetworkOPs
void
transactionBatch();

void
forceTransactionBatch();

/**
* Attempt to apply transactions and post-process based on the results.
*
Expand Down Expand Up @@ -1136,6 +1139,7 @@ NetworkOPsImp::strOperatingMode(OperatingMode const mode, bool const admin)
void
NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
{
// Launch async task and return immediately
if (isNeedNetworkLedger())
{
// Nothing we can do if we've never been in sync
Expand All @@ -1147,9 +1151,9 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
// Enforce Network bar for emitted txn
if (view->rules().enabled(featureHooks) && hook::isEmittedTxn(*iTrans))
{
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.
// RH NOTE: Warning removed here due to ConsesusSet using this
// function which continually triggers this bar. Doesn't seem
// dangerous, just annoying.

// JLOG(m_journal.warn())
// << "Submitted transaction invalid: EmitDetails present.";
Expand All @@ -1164,9 +1168,9 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)

if ((flags & SF_BAD) != 0)
{
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.
// RH NOTE: Warning removed here due to ConsesusSet using this
// function which continually triggers this bar. Doesn't seem
// dangerous, just annoying.

// JLOG(m_journal.warn()) << "Submitted transaction cached bad";
return;
Expand Down Expand Up @@ -1364,6 +1368,17 @@ NetworkOPsImp::doTransactionSync(
} while (transaction->getApplying());
}

void
NetworkOPsImp::forceTransactionBatch()
{
std::unique_lock<std::mutex> lock(mMutex);
mDispatchState = DispatchState::scheduled;
while (mTransactions.size())
{
apply(lock);
}
}

void
NetworkOPsImp::transactionBatch()
{
Expand Down Expand Up @@ -1398,7 +1413,6 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
std::unique_lock ledgerLock{
m_ledgerMaster.peekMutex(), std::defer_lock};
std::lock(masterLock, ledgerLock);

app_.openLedger().modify([&](OpenView& view, beast::Journal j) {
for (TransactionStatus& e : transactions)
{
Expand Down
5 changes: 4 additions & 1 deletion src/ripple/app/misc/NetworkOPs.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ class NetworkOPs : public InfoSub::Source
std::shared_ptr<Transaction>& transaction,
bool bUnlimited,
bool bLocal,
FailHard failType) = 0;
FailHard failType = FailHard::no) = 0;

virtual void
forceTransactionBatch() = 0;

//--------------------------------------------------------------------------
//
Expand Down
11 changes: 10 additions & 1 deletion src/ripple/app/misc/impl/TxQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <ripple/app/misc/TxQ.h>
#include <ripple/app/tx/apply.h>
#include <ripple/basics/mulDiv.h>
#include <ripple/protocol/AccountID.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/jss.h>
#include <ripple/protocol/st.h>
Expand Down Expand Up @@ -1897,7 +1898,15 @@ TxQ::tryDirectApply(
// transaction straight into the ledger.
FeeLevel64 const feeLevelPaid = getFeeLevelPaid(view, *tx);

if (feeLevelPaid >= requiredFeeLevel)
static auto const genesisAccountId = calcAccountID(
generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase"))
.first);

// RH NOTE: exempting the genesis account from fee escalation is useful for
// stress testing it also shouldn't require an amendment because it will be
// fought out in consensus.
if (feeLevelPaid >= requiredFeeLevel ||
(*tx)[sfAccount] == genesisAccountId)
{
// Attempt to apply the transaction directly.
auto const transactionID = tx->getTransactionID();
Expand Down
7 changes: 7 additions & 0 deletions src/ripple/ledger/ReadView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <memory>
#include <optional>
#include <unordered_set>
#include <iterator>

namespace ripple {

Expand Down Expand Up @@ -321,6 +322,12 @@ class ReadView

// The range of transactions
txs_type txs;

std::size_t
txCount() const
{
return std::distance(txs.begin(), txs.end());
}
};

//------------------------------------------------------------------------------
Expand Down
Loading
Loading