Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
503 changes: 503 additions & 0 deletions src/ledger/LedgerEntryScope.cpp

Large diffs are not rendered by default.

451 changes: 451 additions & 0 deletions src/ledger/LedgerEntryScope.h

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "invariant/InvariantDoesNotHold.h"
#include "invariant/InvariantManager.h"
#include "ledger/FlushAndRotateMetaDebugWork.h"
#include "ledger/LedgerEntryScope.h"
#include "ledger/LedgerHeaderUtils.h"
#include "ledger/LedgerManager.h"
#include "ledger/LedgerTxn.h"
Expand Down Expand Up @@ -2274,7 +2275,7 @@ LedgerManagerImpl::applyThread(

if (res.getSuccess())
{
threadState->commitChangesFromSuccessfulOp(res, txBundle);
threadState->commitChangesFromSuccessfulTx(res, txBundle);
}
else
{
Expand Down Expand Up @@ -2309,11 +2310,13 @@ LedgerManagerImpl::applySorobanStageClustersInParallel(

auto liveSnapshot = app.copySearchableLiveBucketListSnapshot();

DeactivateScopeGuard globalStateDeactivateGuard(globalState);

for (size_t i = 0; i < stage.numClusters(); ++i)
{
auto const& cluster = stage.getCluster(i);
auto threadStatePtr = std::make_unique<ThreadParallelApplyLedgerState>(
app, globalState, cluster);
app, globalState, cluster, i);
threadFutures.emplace_back(std::async(
std::launch::async, &LedgerManagerImpl::applyThread, this,
std::ref(app), std::move(threadStatePtr), std::cref(cluster),
Expand Down
17 changes: 12 additions & 5 deletions src/transactions/ExtendFootprintTTLOpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "transactions/ExtendFootprintTTLOpFrame.h"
#include "TransactionUtils.h"
#include "ledger/LedgerEntryScope.h"
#include "ledger/LedgerManagerImpl.h"
#include "ledger/LedgerTypeUtils.h"
#include "medida/meter.h"
Expand Down Expand Up @@ -252,10 +253,16 @@ class ExtendFootprintTTLParallelApplyHelper
return true;
}

OpModifiedEntryMap
takeOpEntryMap()
ParallelTxReturnVal
takeSuccess()
{
return std::move(mOpState.takeSuccess().getModifiedEntryMap());
return mTxState.takeSuccess();
}

ParallelTxReturnVal
takeFailure()
{
return mTxState.takeFailure();
}
};

Expand All @@ -276,11 +283,11 @@ ExtendFootprintTTLOpFrame::doParallelApply(
app, threadState, ledgerInfo, res, refundableFeeTracker, opMeta, *this);
if (helper.apply())
{
return {true, helper.takeOpEntryMap()};
return helper.takeSuccess();
}
else
{
return {false, {}};
return helper.takeFailure();
}
}

Expand Down
29 changes: 15 additions & 14 deletions src/transactions/InvokeHostFunctionOpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ class InvokeHostFunctionApplyHelper : virtual LedgerAccessHelper
// handleArchivedEntry may need to load the TTL key to write the
// restored TTL, so make sure any TTL ltxe destructs before
// calling handleArchivedEntry
auto ttlEntryOp = getLedgerEntryOpt(ttlKey);
auto ttlEntryOpt = getLedgerEntryOpt(ttlKey);

if (ttlEntryOp)
if (ttlEntryOpt)
{
if (!isLive(ttlEntryOp.value(), ledgerSeq))
if (!isLive(ttlEntryOpt.value(), ledgerSeq))
{
// For temporary entries, treat the expired entry as
// if the key did not exist
Expand All @@ -406,7 +406,7 @@ class InvokeHostFunctionApplyHelper : virtual LedgerAccessHelper
else
{
sorobanEntryLive = true;
ttlEntry = ttlEntryOp->data.ttl();
ttlEntry = ttlEntryOpt->data.ttl();
}
}
// Starting from protocol 23, check the hot archive for this
Expand Down Expand Up @@ -1054,24 +1054,25 @@ class InvokeHostFunctionParallelApplyHelper
LedgerEntry ttlEntry;
if (isHotArchiveEntry)
{
mOpState.upsertEntry(lk, le, mLedgerInfo.getLedgerSeq());
mTxState.upsertEntry(lk, le, mLedgerInfo.getLedgerSeq());
ttlEntry =
getTTLEntryForTTLKey(ttlKey, restoredLiveUntilLedger);
mOpState.upsertEntry(ttlKey, ttlEntry,
mTxState.upsertEntry(ttlKey, ttlEntry,
mLedgerInfo.getLedgerSeq());
mOpState.addHotArchiveRestore(lk, le, ttlKey, ttlEntry);
mTxState.addHotArchiveRestore(lk, le, ttlKey, ttlEntry);
}
else
{
// Entry exists in the live BucketList if we get to this point
auto ttlLeOpt = mOpState.getLiveEntryOpt(ttlKey);
auto scopedTtlLeOpt = mTxState.getLiveEntryOpt(ttlKey);
auto ttlLeOpt = scopedTtlLeOpt.readInScope(mTxState);
releaseAssertOrThrow(ttlLeOpt);
ttlEntry = *ttlLeOpt;
ttlEntry = ttlLeOpt.value();
ttlEntry.data.ttl().liveUntilLedgerSeq =
restoredLiveUntilLedger;
mOpState.upsertEntry(ttlKey, ttlEntry,
mTxState.upsertEntry(ttlKey, ttlEntry,
mLedgerInfo.getLedgerSeq());
mOpState.addLiveBucketlistRestore(lk, le, ttlKey, ttlEntry);
mTxState.addLiveBucketlistRestore(lk, le, ttlKey, ttlEntry);
}

// Finally, add the entries to the Cxx buffer as if they were live.
Expand Down Expand Up @@ -1130,7 +1131,7 @@ class InvokeHostFunctionParallelApplyHelper
bool
previouslyRestoredFromHotArchive(LedgerKey const& lk) override
{
return mOpState.entryWasRestored(lk);
return mTxState.entryWasRestored(lk);
}

// Returns true if the given key is marked for
Expand Down Expand Up @@ -1201,11 +1202,11 @@ class InvokeHostFunctionParallelApplyHelper
{
if (applySucceeded)
{
return mOpState.takeSuccess();
return mTxState.takeSuccess();
}
else
{
return mOpState.takeFailure();
return mTxState.takeFailure();
}
}
};
Expand Down
Loading
Loading