Skip to content

Commit a32a391

Browse files
committed
Bump XDR and rename thread->cluster in code base
1 parent 9db6b00 commit a32a391

File tree

5 files changed

+53
-53
lines changed

5 files changed

+53
-53
lines changed

src/herder/TxSetFrame.cpp

+36-37
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ validateParallelComponent(ParallelTxsComponent const& component)
112112
CLOG_DEBUG(Herder, "Got bad txSet: empty stage");
113113
return false;
114114
}
115-
for (auto const& thread : stage)
115+
for (auto const& cluster : stage)
116116
{
117-
if (thread.empty())
117+
if (cluster.empty())
118118
{
119-
CLOG_DEBUG(Herder, "Got bad txSet: empty thread");
119+
CLOG_DEBUG(Herder, "Got bad txSet: empty cluster");
120120
return false;
121121
}
122122
}
@@ -315,13 +315,13 @@ parallelPhaseToXdr(TxStageFrameList const& txs,
315315
{
316316
auto& xdrStage = component.executionStages.emplace_back();
317317
xdrStage.reserve(stage.size());
318-
for (auto const& thread : stage)
318+
for (auto const& cluster : stage)
319319
{
320-
auto& xdrThread = xdrStage.emplace_back();
321-
xdrThread.reserve(thread.size());
322-
for (auto const& tx : thread)
320+
auto& xdrCluster = xdrStage.emplace_back();
321+
xdrCluster.reserve(cluster.size());
322+
for (auto const& tx : cluster)
323323
{
324-
xdrThread.push_back(tx->getEnvelope());
324+
xdrCluster.push_back(tx->getEnvelope());
325325
}
326326
}
327327
}
@@ -404,13 +404,12 @@ sortedForApplyParallel(TxStageFrameList const& stages, Hash const& txSetHash)
404404
ApplyTxSorter sorter(txSetHash);
405405
for (auto& stage : sortedStages)
406406
{
407-
for (auto& thread : stage)
407+
for (auto& cluster : stage)
408408
{
409-
std::sort(thread.begin(), thread.end(), sorter);
409+
std::sort(cluster.begin(), cluster.end(), sorter);
410410
}
411-
// There is no need to shuffle threads in the stage, as they are
412-
// independent, so the apply order doesn't matter even if the threads
413-
// are being applied sequentially.
411+
// There is no need to shuffle clusters in the stage, as they are
412+
// independent, so the apply order between clusters doesn't matter.
414413
}
415414
std::sort(sortedStages.begin(), sortedStages.end(),
416415
[&sorter](auto const& a, auto const& b) {
@@ -1046,9 +1045,9 @@ TxSetXDRFrame::sizeTxTotal() const
10461045
for (auto const& stage :
10471046
phase.parallelTxsComponent().executionStages)
10481047
{
1049-
for (auto const& thread : stage)
1048+
for (auto const& cluster : stage)
10501049
{
1051-
totalSize += thread.size();
1050+
totalSize += cluster.size();
10521051
}
10531052
}
10541053
break;
@@ -1109,11 +1108,11 @@ TxSetXDRFrame::sizeOpTotalForLogging() const
11091108
for (auto const& stage :
11101109
phase.parallelTxsComponent().executionStages)
11111110
{
1112-
for (auto const& thread : stage)
1111+
for (auto const& cluster : stage)
11131112
{
11141113
totalSize +=
1115-
std::accumulate(thread.begin(), thread.end(), 0ull,
1116-
accumulateTxsFn);
1114+
std::accumulate(cluster.begin(), cluster.end(),
1115+
0ull, accumulateTxsFn);
11171116
}
11181117
}
11191118
break;
@@ -1160,9 +1159,9 @@ TxSetXDRFrame::createTransactionFrames(Hash const& networkID) const
11601159
for (auto const& stage :
11611160
phase.parallelTxsComponent().executionStages)
11621161
{
1163-
for (auto const& thread : stage)
1162+
for (auto const& cluster : stage)
11641163
{
1165-
for (auto const& tx : thread)
1164+
for (auto const& tx : cluster)
11661165
{
11671166
txs.emplace_back(
11681167
TransactionFrameBase::makeTransactionFromWire(
@@ -1237,12 +1236,12 @@ TxSetPhaseFrame::Iterator::operator*() const
12371236
{
12381237

12391238
if (mStageIndex >= mStages.size() ||
1240-
mThreadIndex >= mStages[mStageIndex].size() ||
1241-
mTxIndex >= mStages[mStageIndex][mThreadIndex].size())
1239+
mClusterIndex >= mStages[mStageIndex].size() ||
1240+
mTxIndex >= mStages[mStageIndex][mClusterIndex].size())
12421241
{
12431242
throw std::runtime_error("TxPhase iterator out of bounds");
12441243
}
1245-
return mStages[mStageIndex][mThreadIndex][mTxIndex];
1244+
return mStages[mStageIndex][mClusterIndex][mTxIndex];
12461245
}
12471246

12481247
TxSetPhaseFrame::Iterator&
@@ -1253,13 +1252,13 @@ TxSetPhaseFrame::Iterator::operator++()
12531252
throw std::runtime_error("TxPhase iterator out of bounds");
12541253
}
12551254
++mTxIndex;
1256-
if (mTxIndex >= mStages[mStageIndex][mThreadIndex].size())
1255+
if (mTxIndex >= mStages[mStageIndex][mClusterIndex].size())
12571256
{
12581257
mTxIndex = 0;
1259-
++mThreadIndex;
1260-
if (mThreadIndex >= mStages[mStageIndex].size())
1258+
++mClusterIndex;
1259+
if (mClusterIndex >= mStages[mStageIndex].size())
12611260
{
1262-
mThreadIndex = 0;
1261+
mClusterIndex = 0;
12631262
++mStageIndex;
12641263
}
12651264
}
@@ -1278,7 +1277,7 @@ bool
12781277
TxSetPhaseFrame::Iterator::operator==(Iterator const& other) const
12791278
{
12801279
return mStageIndex == other.mStageIndex &&
1281-
mThreadIndex == other.mThreadIndex && mTxIndex == other.mTxIndex &&
1280+
mClusterIndex == other.mClusterIndex && mTxIndex == other.mTxIndex &&
12821281
// Make sure to compare the pointers, not the contents, both for
12831282
// correctness and optimization.
12841283
&mStages == &other.mStages;
@@ -1348,11 +1347,11 @@ TxSetPhaseFrame::makeFromWire(Hash const& networkID,
13481347
{
13491348
auto& stage = stages.emplace_back();
13501349
stage.reserve(xdrStage.size());
1351-
for (auto const& xdrThread : xdrStage)
1350+
for (auto const& xdrCluster : xdrStage)
13521351
{
1353-
auto& thread = stage.emplace_back();
1354-
thread.reserve(xdrThread.size());
1355-
for (auto const& env : xdrThread)
1352+
auto& cluster = stage.emplace_back();
1353+
cluster.reserve(xdrCluster.size());
1354+
for (auto const& env : xdrCluster)
13561355
{
13571356
auto tx = TransactionFrameBase::makeTransactionFromWire(
13581357
networkID, env);
@@ -1362,14 +1361,14 @@ TxSetPhaseFrame::makeFromWire(Hash const& networkID,
13621361
"transaction has invalid XDR");
13631362
return std::nullopt;
13641363
}
1365-
thread.push_back(tx);
1364+
cluster.push_back(tx);
13661365
inclusionFeeMap[tx] = baseFee;
13671366
}
1368-
if (!std::is_sorted(thread.begin(), thread.end(),
1367+
if (!std::is_sorted(cluster.begin(), cluster.end(),
13691368
&TxSetUtils::hashTxSorter))
13701369
{
13711370
CLOG_DEBUG(Herder, "Got bad generalized txSet: "
1372-
"thread is not sorted");
1371+
"cluster is not sorted");
13731372
return std::nullopt;
13741373
}
13751374
}
@@ -1474,9 +1473,9 @@ TxSetPhaseFrame::size() const
14741473
size_t size = 0;
14751474
for (auto const& stage : mStages)
14761475
{
1477-
for (auto const& thread : stage)
1476+
for (auto const& cluster : stage)
14781477
{
1479-
size += thread.size();
1478+
size += cluster.size();
14801479
}
14811480
}
14821481
return size;

src/herder/TxSetFrame.h

+12-11
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,19 @@ class TxSetXDRFrame : public NonMovableOrCopyable
196196
// - The whole phase (`TxStageFrameList`) consists of several sequential
197197
// 'stages' (`TxStageFrame`). A stage has to be executed after every
198198
// transaction in the previous stage has been applied.
199-
// - A 'stage' (`TxStageFrame`) consists of several parallel 'threads'
200-
// (`TxThreadFrame`). Transactions in different 'threads' are independent of
201-
// each other and can be applied in parallel.
202-
// - A 'thread' (`TxThreadFrame`) consists of transactions that should
203-
// generally be applied sequentially. However, not all the transactions in
204-
// the thread are necessarily conflicting with each other; it is possible
205-
// that some, or even all transactions in the thread structure can be applied
206-
// in parallel with each other (depending on their footprints).
199+
// - A 'stage' (`TxStageFrame`) consists of several 'clusters' of interdependent
200+
// transactions (`DependentTxClusterFrame`). Transactions in different
201+
// clusters are independent of each other and thus can be applied in parallel
202+
// (or in arbitrary order in general).
203+
// - A 'cluster' (`DependentTxClusterFrame`) consists of transactions that
204+
// should generally be applied sequentially. However, not all the
205+
// transactions in the cluster are necessarily conflicting with each other; it
206+
// is possible that some, or even all transactions in the cluster structure
207+
// are independent of each other (depending on their footprints).
207208
//
208209
// This structure mimics the XDR structure of the `ParallelTxsComponent`.
209-
using TxThreadFrame = TxFrameList;
210-
using TxStageFrame = std::vector<TxThreadFrame>;
210+
using DependentTxClusterFrame = TxFrameList;
211+
using TxStageFrame = std::vector<DependentTxClusterFrame>;
211212
using TxStageFrameList = std::vector<TxStageFrame>;
212213

213214
// Alias for the map from transaction to its inclusion fee as defined by the
@@ -276,7 +277,7 @@ class TxSetPhaseFrame
276277
Iterator(TxStageFrameList const& txs, size_t stageIndex);
277278
TxStageFrameList const& mStages;
278279
size_t mStageIndex = 0;
279-
size_t mThreadIndex = 0;
280+
size_t mClusterIndex = 0;
280281
size_t mTxIndex = 0;
281282
};
282283
Iterator begin() const;

src/herder/TxSetUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ TxSetUtils::sortParallelTxsInHashOrder(TxStageFrameList const& stages)
121121
TxStageFrameList sortedStages = stages;
122122
for (auto& stage : sortedStages)
123123
{
124-
for (auto& thread : stage)
124+
for (auto& cluster : stage)
125125
{
126-
std::sort(thread.begin(), thread.end(), TxSetUtils::hashTxSorter);
126+
std::sort(cluster.begin(), cluster.end(), TxSetUtils::hashTxSorter);
127127
}
128128
std::sort(stage.begin(), stage.end(), [](auto const& a, auto const& b) {
129129
releaseAssert(!a.empty() && !b.empty());

src/herder/test/TestTxSetUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ makeGeneralizedTxSetXDR(std::vector<ComponentPhases> const& phases,
7676
}
7777
if (!txs.empty())
7878
{
79-
auto& thread =
79+
auto& cluster =
8080
component.executionStages.emplace_back().emplace_back();
8181
for (auto const& tx : txs)
8282
{
83-
thread.emplace_back(tx->getEnvelope());
83+
cluster.emplace_back(tx->getEnvelope());
8484
}
8585
}
8686
#else

0 commit comments

Comments
 (0)