Skip to content

Commit 1ca680d

Browse files
committed
Initial support for parallel Soroban phase XDR.
I've tried to minimize the scope of the changes; specifically this doesn't contain any actual logic for the parallel execution (such as data dependency validation and building parallel stages). However, there is still some refactoring that needed to happen in order to support new, more complex tx sets. I've also removed some legacy surge pricing logic and the corresponding tests - we should no longer need the surge pricing logic that covers more than one source account per tx set.
1 parent b3aeb14 commit 1ca680d

32 files changed

+3107
-2341
lines changed

Builds/VisualStudio/stellar-core.vcxproj

+2
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ exit /b 0
602602
<ClCompile Include="..\..\src\overlay\Floodgate.cpp" />
603603
<ClCompile Include="..\..\src\overlay\FlowControl.cpp" />
604604
<ClCompile Include="..\..\src\overlay\FlowControlCapacity.cpp" />
605+
<ClCompile Include="..\..\src\overlay\Hmac.cpp" />
605606
<ClCompile Include="..\..\src\overlay\ItemFetcher.cpp" />
606607
<ClCompile Include="..\..\src\overlay\OverlayAppConnector.cpp" />
607608
<ClCompile Include="..\..\src\overlay\OverlayManagerImpl.cpp" />
@@ -1019,6 +1020,7 @@ exit /b 0
10191020
<ClInclude Include="..\..\src\overlay\Floodgate.h" />
10201021
<ClInclude Include="..\..\src\overlay\FlowControl.h" />
10211022
<ClInclude Include="..\..\src\overlay\FlowControlCapacity.h" />
1023+
<ClInclude Include="..\..\src\overlay\Hmac.h" />
10221024
<ClInclude Include="..\..\src\overlay\ItemFetcher.h" />
10231025
<ClInclude Include="..\..\src\overlay\OverlayAppConnector.h" />
10241026
<ClInclude Include="..\..\src\overlay\OverlayManager.h" />

Builds/VisualStudio/stellar-core.vcxproj.filters

+6
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,9 @@
13441344
<ClCompile Include="..\..\src\overlay\TxDemandsManager.cpp">
13451345
<Filter>overlay</Filter>
13461346
</ClCompile>
1347+
<ClCompile Include="..\..\src\overlay\Hmac.cpp">
1348+
<Filter>overlay</Filter>
1349+
</ClCompile>
13471350
</ItemGroup>
13481351
<ItemGroup>
13491352
<ClInclude Include="..\..\lib\util\cpptoml.h">
@@ -2339,6 +2342,9 @@
23392342
<ClInclude Include="..\..\src\overlay\TxDemandsManager.h">
23402343
<Filter>overlay</Filter>
23412344
</ClInclude>
2345+
<ClInclude Include="..\..\src\overlay\Hmac.h">
2346+
<Filter>overlay</Filter>
2347+
</ClInclude>
23422348
</ItemGroup>
23432349
<ItemGroup>
23442350
<None Include="..\..\AUTHORS" />

deny.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ exclude = [
5151
# Somehow the tracking machinery of two different dev-dep tracing
5252
# subsystems also winds up pulling in conflicts, but again, just
5353
# dev-deps or non-produciton configs.
54-
"tracking-allocator"
54+
"tracking-allocator",
55+
# Temporary exclusion due to signing-related vulnerability (this doesn't
56+
# affect Core as Core doesn't use this for signing)
57+
"curve25519-dalek"
5558
]
5659

5760
# If true, metadata will be collected with `--all-features`. Note that this can't

src/herder/HerderImpl.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ HerderImpl::triggerNextLedger(uint32_t ledgerSeqToTrigger,
13051305
// our first choice for this round's set is all the tx we have collected
13061306
// during last few ledger closes
13071307
auto const& lcl = mLedgerManager.getLastClosedLedgerHeader();
1308-
TxSetPhaseTransactions txPhases;
1308+
PerPhaseTransactionList txPhases;
13091309
txPhases.emplace_back(mTransactionQueue.getTransactions(lcl.header));
13101310

13111311
if (protocolVersionStartsFrom(lcl.header.ledgerVersion,
@@ -1347,7 +1347,7 @@ HerderImpl::triggerNextLedger(uint32_t ledgerSeqToTrigger,
13471347
upperBoundCloseTimeOffset = nextCloseTime - lcl.header.scpValue.closeTime;
13481348
lowerBoundCloseTimeOffset = upperBoundCloseTimeOffset;
13491349

1350-
TxSetPhaseTransactions invalidTxPhases;
1350+
PerPhaseTransactionList invalidTxPhases;
13511351
invalidTxPhases.resize(txPhases.size());
13521352

13531353
auto [proposedSet, applicableProposedSet] =
@@ -2230,8 +2230,7 @@ HerderImpl::updateTransactionQueue(TxSetXDRFrameConstPtr externalizedTxSet)
22302230

22312231
auto invalidTxs = TxSetUtils::getInvalidTxList(
22322232
txs, mApp, 0,
2233-
getUpperBoundCloseTimeOffset(mApp, lhhe.header.scpValue.closeTime),
2234-
false);
2233+
getUpperBoundCloseTimeOffset(mApp, lhhe.header.scpValue.closeTime));
22352234
queue.ban(invalidTxs);
22362235

22372236
queue.rebroadcast();

src/herder/SurgePricingUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ SurgePricingPriorityQueue::getMostTopTxsWithinLimits(
162162
SurgePricingPriorityQueue queue(
163163
/* isHighestPriority */ true, laneConfig,
164164
stellar::rand_uniform<size_t>(0, std::numeric_limits<size_t>::max()));
165-
for (auto txStack : txStacks)
165+
for (auto const& txStack : txStacks)
166166
{
167167
queue.add(txStack);
168168
}
@@ -185,7 +185,7 @@ SurgePricingPriorityQueue::visitTopTxs(
185185
{
186186
ZoneScoped;
187187

188-
for (auto txStack : txStacks)
188+
for (auto const& txStack : txStacks)
189189
{
190190
add(txStack);
191191
}

src/herder/SurgePricingUtils.h

+42
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,48 @@ class TxStack
4343
virtual ~TxStack() = default;
4444
};
4545

46+
// A simple stack that holds a single transaction.
47+
class SingleTxStack : public TxStack
48+
{
49+
public:
50+
SingleTxStack(TransactionFrameBasePtr tx,
51+
bool useByteLimitInClassic = false)
52+
: mTx(tx), mUseByteLimitInClassic(useByteLimitInClassic)
53+
{
54+
}
55+
56+
TransactionFrameBasePtr
57+
getTopTx() const override
58+
{
59+
releaseAssert(mTx);
60+
return mTx;
61+
}
62+
63+
void
64+
popTopTx() override
65+
{
66+
releaseAssert(mTx);
67+
mTx = nullptr;
68+
}
69+
70+
bool
71+
empty() const override
72+
{
73+
return mTx == nullptr;
74+
}
75+
76+
Resource
77+
getResources() const override
78+
{
79+
releaseAssert(mTx);
80+
return Resource(mTx->getResources(mUseByteLimitInClassic));
81+
}
82+
83+
private:
84+
TransactionFrameBasePtr mTx;
85+
bool mUseByteLimitInClassic = false;
86+
};
87+
4688
using TxStackPtr = std::shared_ptr<TxStack>;
4789

4890
// Configuration for multi-lane transaction limiting and surge pricing.

src/herder/TransactionQueue.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -814,11 +814,11 @@ TransactionQueue::isBanned(Hash const& hash) const
814814
});
815815
}
816816

817-
TxSetTransactions
817+
TxFrameList
818818
TransactionQueue::getTransactions(LedgerHeader const& lcl) const
819819
{
820820
ZoneScoped;
821-
TxSetTransactions txs;
821+
TxFrameList txs;
822822

823823
uint32_t const nextLedgerSeq = lcl.ledgerSeq + 1;
824824
int64_t const startingSeq = getStartingSequenceNumber(nextLedgerSeq);

src/herder/TransactionQueue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class TransactionQueue
125125

126126
bool isBanned(Hash const& hash) const;
127127
TransactionFrameBaseConstPtr getTx(Hash const& hash) const;
128-
TxSetTransactions getTransactions(LedgerHeader const& lcl) const;
128+
TxFrameList getTransactions(LedgerHeader const& lcl) const;
129129
bool sourceAccountPending(AccountID const& accountID) const;
130130

131131
virtual size_t getMaxQueueSizeOps() const = 0;

src/herder/TxQueueLimiter.h

-38
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,6 @@
1313
namespace stellar
1414
{
1515

16-
class SingleTxStack : public TxStack
17-
{
18-
public:
19-
SingleTxStack(TransactionFrameBasePtr tx) : mTx(tx)
20-
{
21-
}
22-
23-
TransactionFrameBasePtr
24-
getTopTx() const override
25-
{
26-
releaseAssert(mTx);
27-
return mTx;
28-
}
29-
30-
void
31-
popTopTx() override
32-
{
33-
releaseAssert(mTx);
34-
mTx = nullptr;
35-
}
36-
37-
bool
38-
empty() const override
39-
{
40-
return mTx == nullptr;
41-
}
42-
43-
Resource
44-
getResources() const override
45-
{
46-
releaseAssert(mTx);
47-
return Resource(mTx->getResources(/* useByteLimitInClassic */ false));
48-
}
49-
50-
private:
51-
TransactionFrameBasePtr mTx;
52-
};
53-
5416
class TxQueueLimiter
5517
{
5618
// number of ledgers we can pool in memory

0 commit comments

Comments
 (0)