Skip to content

Commit

Permalink
Merge pull request #3803 from marta-lokhova/ledger_txn_read_only
Browse files Browse the repository at this point in the history
Switch LedgerTxn instances to read-only in overlay

Reviewed-by: dmkozh
  • Loading branch information
latobarita authored Jun 29, 2023
2 parents d8609e1 + 536b111 commit 2109a16
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/herder/TransactionQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,9 @@ TransactionQueue::clearAll()
{
b.clear();
}
LedgerTxn ltx(mApp.getLedgerTxnRoot());
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
mTxQueueLimiter->reset(ltx);
mKnownTxHashes.clear();
}
Expand Down Expand Up @@ -1240,7 +1242,7 @@ SorobanTransactionQueue::getMaxResourcesToFloodThisPeriod() const
auto const& cfg = mApp.getConfig();
double ratePerLedger = cfg.FLOOD_SOROBAN_RATE_PER_LEDGER;

LedgerTxn ltx(mApp.getLedgerTxnRoot(), false,
LedgerTxn ltx(mApp.getLedgerTxnRoot(), /* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
auto sorRes = mApp.getLedgerManager().maxLedgerResources(true, ltx);

Expand Down Expand Up @@ -1312,7 +1314,8 @@ SorobanTransactionQueue::broadcastSome()

{
// get Max soroban tx resources
LedgerTxn ltx(mApp.getLedgerTxnRoot(), false,
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
auto const& conf = mApp.getLedgerManager().getSorobanNetworkConfig(ltx);
int64_t const opCount = 1;
Expand All @@ -1336,7 +1339,9 @@ SorobanTransactionQueue::broadcastSome()
size_t
SorobanTransactionQueue::getMaxQueueSizeOps() const
{
LedgerTxn ltx(mApp.getLedgerTxnRoot());
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
auto res = mTxQueueLimiter->maxScaledLedgerResources(true, ltx);
releaseAssert(res.size() == NUM_SOROBAN_TX_RESOURCES);
return res.getVal(Resource::Type::OPERATIONS);
Expand Down Expand Up @@ -1541,7 +1546,9 @@ TransactionQueue::getInQueueSeqNum(AccountID const& account) const
size_t
ClassicTransactionQueue::getMaxQueueSizeOps() const
{
LedgerTxn ltx(mApp.getLedgerTxnRoot());
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
auto res = mTxQueueLimiter->maxScaledLedgerResources(false, ltx);
releaseAssert(res.size() == NUM_CLASSIC_TX_RESOURCES);
return res.getVal(Resource::Type::OPERATIONS);
Expand Down
4 changes: 3 additions & 1 deletion src/overlay/OverlayManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,9 @@ OverlayManagerImpl::getMaxAdvertSize() const
cfg.FLOOD_OP_RATE_PER_LEDGER);
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
{
LedgerTxn ltx(mApp.getLedgerTxnRoot());
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
auto limits = mApp.getLedgerManager().getSorobanNetworkConfig(ltx);
opsToFloodPerLedger += getOpsFloodLedger(
limits.ledgerMaxTxCount(), cfg.FLOOD_SOROBAN_RATE_PER_LEDGER);
Expand Down

0 comments on commit 2109a16

Please sign in to comment.