This commit is contained in:
Denis Angell
2024-04-16 10:34:53 +02:00
parent 175f436974
commit 7a4e2500bb
9 changed files with 75 additions and 8 deletions

View File

@@ -1218,6 +1218,21 @@ NetworkOPsImp::processTransaction(
return;
}
// This function is called by several different parts of the codebase
// under no circumstances will we ever accept an emitted txn from the
// network. Emitted txns are *always* and *only* inserted by TxQ::accept,
// and only arise from processing ltEMITTED_TXN out of the EMITTED_DIR. This
// isn't always an error because a fetch pack etc might include an emitted
// txn and if this is a deliberate attempt to send an emitted txn over the
// network it was already billed in PeerImp
if (view->rules().enabled(featureBatch) &&
hook::isBatchTxn(*transaction->getSTransaction()))
{
// RH NOTE: cannot set SF_BAD because if the tx will be generated by a
// hook we are about to execute
return;
}
auto const newFlags = app_.getHashRouter().getFlags(transaction->getID());
if ((newFlags & SF_BAD) != 0)
@@ -1280,6 +1295,18 @@ NetworkOPsImp::doTransactionAsync(
return;
}
// Enforce Network bar for batch txn
if (view->rules().enabled(featureBatch) &&
hook::isBatchTxn(*transaction->getSTransaction()))
{
JLOG(m_journal.info())
<< "Transaction received over network has BatchIndex, discarding.";
// RH NOTE: cannot set SF_BAD because if the tx will be generated by a
// hook we are about to execute then this would poison consensus for
// that emitted tx
return;
}
if (transaction->getApplying())
return;
@@ -1318,6 +1345,15 @@ NetworkOPsImp::doTransactionSync(
// that emitted tx
return;
}
// Enforce Network bar for batch txn
if (view->rules().enabled(featureBatch) &&
hook::isBatchTxn(*transaction->getSTransaction()))
{
JLOG(m_journal.info())
<< "Transaction received over network has BatchIndex, discarding.";
return;
}
if (!transaction->getApplying())
{
@@ -1524,8 +1560,10 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
bool const isEmitted =
hook::isEmittedTxn(*(e.transaction->getSTransaction()));
bool const isBatch =
hook::isBatchTxn(*(e.transaction->getSTransaction()));
if (toSkip && !isEmitted)
if (toSkip && !isEmitted || !isBatch)
{
protocol::TMTransaction tx;
Serializer s;
@@ -2754,6 +2792,10 @@ NetworkOPsImp::pubProposedTransaction(
if (hook::isEmittedTxn(*transaction))
return;
// never publish emitted txns
if (hook::isBatchTxn(*transaction))
return;
Json::Value jvObj = transJson(*transaction, result, false, ledger);
{