@@ -241,7 +241,7 @@ HerderImpl::bootstrap()
241241 setupTriggerNextLedger ();
242242 newSlotExternalized (
243243 mLedgerManager .getLastClosedLedgerHeader ().header .scpValue );
244- purgeOldSlotsAndProcessSCPQueue (true );
244+ processSCPQueue (true );
245245}
246246
247247void
@@ -253,16 +253,18 @@ HerderImpl::newSlotExternalized(StellarValue const& value)
253253 // start timing next externalize from this point
254254 mLastExternalize = mApp .getClock ().now ();
255255
256+ // perform cleanups
257+ purgeOldSlots ();
258+
256259 mPendingEnvelopes .forceRebuildQuorum ();
257260}
258261
259262void
260- HerderImpl::purgeOldSlotsAndProcessSCPQueue ( bool synchronous )
263+ HerderImpl::purgeOldSlots ( )
261264{
262265 ZoneScoped;
263- CLOG_TRACE (Herder, " HerderImpl::purgeOldSlotsAndProcessSCPQueue " );
266+ CLOG_TRACE (Herder, " HerderImpl::purgeOldSlots " );
264267
265- // perform cleanups
266268 // Evict slots that are outside of our ledger validity bracket
267269 std::optional<uint32> minSlotToRemember;
268270 auto minSeq = getMinLedgerSeqToRemember ();
@@ -284,11 +286,6 @@ HerderImpl::purgeOldSlotsAndProcessSCPQueue(bool synchronous)
284286 {
285287 eraseOutsideRange (minSlotToRemember, maxSlotToRemember);
286288 }
287-
288- // Process new ready messages for the next slot when tracking.
289- // When not tracking, Herder's out of sync mechanism processes all future
290- // slots automatically
291- processSCPQueue (synchronous);
292289}
293290
294291void
@@ -504,9 +501,10 @@ HerderImpl::valueExternalized(uint64 slotIndex, StellarValue const& value,
504501 // This call may cause LedgerManager to trigger ledger close
505502 processExternalized (slotIndex, value, isLatestSlot);
506503
507- // Record externalize timing and rebuild quorum now. Purging old slots
508- // and processing the SCP queue for the next slot happens later, in
509- // lastClosedLedgerIncreased, once the ledger has actually closed.
504+ // Record externalize timing, purge slots outside of our validity
505+ // bracket, and rebuild quorum now. Processing the SCP queue for the
506+ // next slot happens later, in lastClosedLedgerIncreased, once the
507+ // ledger has actually closed.
510508 newSlotExternalized (value);
511509
512510 // Check to see if quorums have changed and we need to reanalyze.
@@ -1258,11 +1256,12 @@ HerderImpl::lastClosedLedgerIncreased(bool latest, TxSetXDRFrameConstPtr txSet,
12581256
12591257 setupTriggerNextLedger ();
12601258
1261- // Now that the new ledger is closed, purge SCP slots outside of our
1262- // validity bracket and process any already-buffered SCP envelopes for
1263- // the next slot. Posted to the main thread so control returns to the
1264- // caller first, matching the previous post-externalize behavior.
1265- purgeOldSlotsAndProcessSCPQueue (false );
1259+ // Now that the new ledger is closed, process any already-buffered SCP
1260+ // envelopes for the next slot. Posted to the main thread so control
1261+ // returns to the caller first. Note: slot purging happens earlier, at
1262+ // externalize time, so that SCP state doesn't accumulate while the
1263+ // node is applying or catching up.
1264+ processSCPQueue (false );
12661265 }
12671266}
12681267
0 commit comments