@@ -150,7 +150,7 @@ std::vector<TransactionFrameBasePtr>
150
150
SurgePricingPriorityQueue::getMostTopTxsWithinLimits (
151
151
std::vector<TransactionFrameBasePtr> const & txs,
152
152
std::shared_ptr<SurgePricingLaneConfig> laneConfig,
153
- std::vector<bool >& hadTxNotFittingLane)
153
+ std::vector<bool >& hadTxNotFittingLane, uint32_t ledgerVersion )
154
154
{
155
155
ZoneScoped;
156
156
@@ -159,7 +159,7 @@ SurgePricingPriorityQueue::getMostTopTxsWithinLimits(
159
159
stellar::rand_uniform<size_t >(0 , std::numeric_limits<size_t >::max ()));
160
160
for (auto const & tx : txs)
161
161
{
162
- queue.add (tx);
162
+ queue.add (tx, ledgerVersion );
163
163
}
164
164
std::vector<TransactionFrameBasePtr> outTxs;
165
165
auto visitor = [&outTxs](TransactionFrameBasePtr const & tx) {
@@ -168,63 +168,67 @@ SurgePricingPriorityQueue::getMostTopTxsWithinLimits(
168
168
};
169
169
std::vector<Resource> laneLeftUntilLimit;
170
170
queue.popTopTxs (/* allowGaps */ true , visitor, laneLeftUntilLimit,
171
- hadTxNotFittingLane);
171
+ hadTxNotFittingLane, ledgerVersion );
172
172
return outTxs;
173
173
}
174
174
175
175
void
176
176
SurgePricingPriorityQueue::visitTopTxs (
177
177
std::vector<TransactionFrameBasePtr> const & txs,
178
178
std::function<VisitTxResult(TransactionFrameBasePtr const &)> const & visitor,
179
- std::vector<Resource>& laneLeftUntilLimit)
179
+ std::vector<Resource>& laneLeftUntilLimit, uint32_t ledgerVersion )
180
180
{
181
181
ZoneScoped;
182
182
183
183
for (auto const & tx : txs)
184
184
{
185
- add (tx);
185
+ add (tx, ledgerVersion );
186
186
}
187
187
std::vector<bool > hadTxNotFittingLane;
188
188
popTopTxs (/* allowGaps */ false , visitor, laneLeftUntilLimit,
189
- hadTxNotFittingLane);
189
+ hadTxNotFittingLane, ledgerVersion );
190
190
}
191
191
192
192
void
193
- SurgePricingPriorityQueue::add (TransactionFrameBasePtr tx)
193
+ SurgePricingPriorityQueue::add (TransactionFrameBasePtr tx,
194
+ uint32_t ledgerVersion)
194
195
{
195
196
releaseAssert (tx != nullptr );
196
197
auto lane = mLaneConfig ->getLane (*tx);
197
198
bool inserted = mTxSortedSets [lane].insert (tx).second ;
198
199
if (inserted)
199
200
{
200
- mLaneCurrentCount [lane] += mLaneConfig ->getTxResources (*tx);
201
+ mLaneCurrentCount [lane] +=
202
+ mLaneConfig ->getTxResources (*tx, ledgerVersion);
201
203
}
202
204
}
203
205
204
206
void
205
- SurgePricingPriorityQueue::erase (TransactionFrameBasePtr tx)
207
+ SurgePricingPriorityQueue::erase (TransactionFrameBasePtr tx,
208
+ uint32_t ledgerVersion)
206
209
{
207
210
releaseAssert (tx != nullptr );
208
211
auto lane = mLaneConfig ->getLane (*tx);
209
212
auto it = mTxSortedSets [lane].find (tx);
210
213
if (it != mTxSortedSets [lane].end ())
211
214
{
212
- erase (lane, it);
215
+ erase (lane, it, ledgerVersion );
213
216
}
214
217
}
215
218
216
219
void
217
- SurgePricingPriorityQueue::erase (Iterator const & it)
220
+ SurgePricingPriorityQueue::erase (Iterator const & it, uint32_t ledgerVersion )
218
221
{
219
222
auto innerIt = it.getInnerIter ();
220
- erase (innerIt.first , innerIt.second );
223
+ erase (innerIt.first , innerIt.second , ledgerVersion );
221
224
}
222
225
223
226
void
224
227
SurgePricingPriorityQueue::erase (
225
- size_t lane, SurgePricingPriorityQueue::TxSortedSet::iterator iter)
228
+ size_t lane, SurgePricingPriorityQueue::TxSortedSet::iterator iter,
229
+ uint32_t ledgerVersion)
226
230
{
227
- auto res = mLaneConfig ->getTxResources (*(*iter));
231
+ auto res = mLaneConfig ->getTxResources (*(*iter), ledgerVersion );
228
232
releaseAssert (res <= mLaneCurrentCount [lane]);
229
233
mLaneCurrentCount [lane] -= res;
230
234
mTxSortedSets [lane].erase (iter);
@@ -235,7 +239,7 @@ SurgePricingPriorityQueue::popTopTxs(
235
239
bool allowGaps,
236
240
std::function<VisitTxResult(TransactionFrameBasePtr const &)> const & visitor,
237
241
std::vector<Resource>& laneLeftUntilLimit,
238
- std::vector<bool>& hadTxNotFittingLane)
242
+ std::vector<bool>& hadTxNotFittingLane, uint32_t ledgerVersion )
239
243
{
240
244
ZoneScoped;
241
245
@@ -251,7 +255,7 @@ SurgePricingPriorityQueue::popTopTxs(
251
255
while (!currIt.isEnd ())
252
256
{
253
257
auto const & currTx = *(*currIt);
254
- auto curr = mLaneConfig ->getTxResources (currTx);
258
+ auto curr = mLaneConfig ->getTxResources (currTx, ledgerVersion );
255
259
auto lane = mLaneConfig ->getLane (currTx);
256
260
if (anyGreater (curr, laneLeftUntilLimit[lane]) ||
257
261
anyGreater (curr, laneLeftUntilLimit[GENERIC_LANE]))
@@ -261,7 +265,7 @@ SurgePricingPriorityQueue::popTopTxs(
261
265
// If gaps are allowed we just erase the iterator and
262
266
// continue in the main loop.
263
267
gapSkipped = true ;
264
- erase (currIt);
268
+ erase (currIt, ledgerVersion );
265
269
if (anyGreater (curr, laneLeftUntilLimit[lane]))
266
270
{
267
271
hadTxNotFittingLane[lane] = true ;
@@ -311,7 +315,7 @@ SurgePricingPriorityQueue::popTopTxs(
311
315
// we can visit it and remove it from the queue.
312
316
auto const & tx = *currIt;
313
317
auto visitRes = visitor (tx);
314
- auto res = mLaneConfig ->getTxResources (*tx);
318
+ auto res = mLaneConfig ->getTxResources (*tx, ledgerVersion );
315
319
auto lane = mLaneConfig ->getLane (*tx);
316
320
// Only account for resource counts when transaction was actually
317
321
// processed by the visitor.
@@ -333,22 +337,23 @@ SurgePricingPriorityQueue::popTopTxs(
333
337
hadTxNotFittingLane[GENERIC_LANE] = true ;
334
338
hadTxNotFittingLane[lane] = true ;
335
339
}
336
- erase (currIt);
340
+ erase (currIt, ledgerVersion );
337
341
}
338
342
}
339
343
340
344
std::pair<bool , int64_t >
341
345
SurgePricingPriorityQueue::canFitWithEviction (
342
346
TransactionFrameBase const & tx, std::optional<Resource> txDiscount,
343
- std::vector<std::pair<TransactionFrameBasePtr, bool >>& txsToEvict) const
347
+ std::vector<std::pair<TransactionFrameBasePtr, bool >>& txsToEvict,
348
+ uint32_t ledgerVersion) const
344
349
{
345
350
ZoneScoped;
346
351
347
352
// This only makes sense when the lowest fee rate tx is on top.
348
353
releaseAssert (!mComparator .isGreater ());
349
354
350
355
auto lane = mLaneConfig ->getLane (tx);
351
- auto txNewResources = mLaneConfig ->getTxResources (tx);
356
+ auto txNewResources = mLaneConfig ->getTxResources (tx, ledgerVersion );
352
357
if (txDiscount)
353
358
{
354
359
txNewResources = subtractNonNegative (txNewResources, *txDiscount);
@@ -442,7 +447,7 @@ SurgePricingPriorityQueue::canFitWithEviction(
442
447
// the transaction by evicting some transactions.
443
448
releaseAssert (!iter.isEnd ());
444
449
auto const & evictTx = *(*iter);
445
- auto evict = mLaneConfig ->getTxResources (evictTx);
450
+ auto evict = mLaneConfig ->getTxResources (evictTx, ledgerVersion );
446
451
auto evictLane = mLaneConfig ->getLane (evictTx);
447
452
448
453
// Evicted tx must have a strictly lower fee than the new tx.
@@ -596,10 +601,11 @@ DexLimitingLaneConfig::updateGenericLaneLimit(Resource const& limit)
596
601
}
597
602
598
603
Resource
599
- DexLimitingLaneConfig::getTxResources (TransactionFrameBase const & tx)
604
+ DexLimitingLaneConfig::getTxResources (TransactionFrameBase const & tx,
605
+ uint32_t ledgerVersion)
600
606
{
601
607
releaseAssert (!tx.isSoroban ());
602
- return tx.getResources (mUseByteLimit );
608
+ return tx.getResources (mUseByteLimit , ledgerVersion );
603
609
}
604
610
605
611
size_t
@@ -645,9 +651,10 @@ SorobanGenericLaneConfig::updateGenericLaneLimit(Resource const& limit)
645
651
}
646
652
647
653
Resource
648
- SorobanGenericLaneConfig::getTxResources (TransactionFrameBase const & tx)
654
+ SorobanGenericLaneConfig::getTxResources (TransactionFrameBase const & tx,
655
+ uint32_t ledgerVersion)
649
656
{
650
657
releaseAssert (tx.isSoroban ());
651
- return tx.getResources (/* useByteLimitInClassic */ false );
658
+ return tx.getResources (/* useByteLimitInClassic */ false , ledgerVersion );
652
659
}
653
660
} // namespace stellar
0 commit comments