Skip to content

Commit

Permalink
Cleanup bad usages of READ_ONLY_WITHOUT_SQL_TXN across the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-lokhova committed Oct 16, 2024
1 parent c46ee76 commit d5150fb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/bucket/test/BucketListTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,7 @@ TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]")

uint64_t correctAverage = sum / correctWindow.size();

LedgerTxn ltx(app->getLedgerTxnRoot(), false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
LedgerTxn ltx(app->getLedgerTxnRoot());
REQUIRE(networkConfig.getAverageBucketListSize() == correctAverage);

// Check on-disk sliding window
Expand Down
8 changes: 3 additions & 5 deletions src/herder/HerderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2147,11 +2147,9 @@ HerderImpl::start()
{
mMaxTxSize = mApp.getHerder().getMaxClassicTxSize();
{
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);

uint32_t version = ltx.loadHeader().current().ledgerVersion;
uint32_t version = mApp.getLedgerManager()
.getLastClosedLedgerHeader()
.header.ledgerVersion;
if (protocolVersionStartsFrom(version, SOROBAN_PROTOCOL_VERSION))
{
auto const& conf =
Expand Down
3 changes: 1 addition & 2 deletions src/herder/test/TxSetTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,7 @@ TEST_CASE("generalized tx set XDR conversion", "[txset]")
auto txSetFrame = TxSetXDRFrame::makeFromWire(txSetXdr);
ApplicableTxSetFrameConstPtr applicableFrame;
{
LedgerTxn ltx(app->getLedgerTxnRoot(), false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
LedgerTxn ltx(app->getLedgerTxnRoot());
applicableFrame = txSetFrame->prepareForApply(*app);
}
REQUIRE(applicableFrame->checkValid(*app, 0, 0));
Expand Down
10 changes: 2 additions & 8 deletions src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,8 +1139,7 @@ LedgerManagerImpl::setLastClosedLedger(

mRebuildInMemoryState = false;
advanceLedgerPointers(lastClosed.header);
LedgerTxn ltx2(mApp.getLedgerTxnRoot(), false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
LedgerTxn ltx2(mApp.getLedgerTxnRoot());
if (protocolVersionStartsFrom(ltx2.loadHeader().current().ledgerVersion,
SOROBAN_PROTOCOL_VERSION))
{
Expand Down Expand Up @@ -1322,12 +1321,7 @@ LedgerManagerImpl::updateNetworkConfig(AbstractLedgerTxn& rootLtx)
{
ZoneScoped;

uint32_t ledgerVersion{};
{
LedgerTxn ltx(rootLtx, false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
ledgerVersion = ltx.loadHeader().current().ledgerVersion;
}
uint32_t ledgerVersion = rootLtx.loadHeader().current().ledgerVersion;

if (protocolVersionStartsFrom(ledgerVersion, SOROBAN_PROTOCOL_VERSION))
{
Expand Down
2 changes: 2 additions & 0 deletions src/ledger/LedgerTxn.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ enum class LedgerTxnConsistency
EXTRA_DELETES
};

// NOTE: Remove READ_ONLY_WITHOUT_SQL_TXN mode when BucketListDB is required
// and we stop supporting SQL backend for ledger state.
enum class TransactionMode
{
READ_ONLY_WITHOUT_SQL_TXN,
Expand Down
2 changes: 1 addition & 1 deletion src/ledger/NetworkConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ SorobanNetworkConfig::loadFromLedger(AbstractLedgerTxn& ltxRoot,
{
ZoneScoped;

LedgerTxn ltx(ltxRoot, false, TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
LedgerTxn ltx(ltxRoot);
loadMaxContractSize(ltx);
loadMaxContractDataKeySize(ltx);
loadMaxContractDataEntrySize(ltx);
Expand Down

0 comments on commit d5150fb

Please sign in to comment.