150
150
CatchupWork::downloadVerifyLedgerChain (CatchupRange const & catchupRange,
151
151
LedgerNumHashPair rangeEnd)
152
152
{
153
- releaseAssert (!mCatchupConfiguration .localBucketsOnly ());
154
-
155
153
ZoneScoped;
156
154
auto verifyRange = catchupRange.getFullRangeIncludingBucketApply ();
157
155
releaseAssert (verifyRange.mCount != 0 );
@@ -194,9 +192,8 @@ CatchupWork::downloadVerifyTxResults(CatchupRange const& catchupRange)
194
192
bool
195
193
CatchupWork::alreadyHaveBucketsHistoryArchiveState (uint32_t atCheckpoint) const
196
194
{
197
- return mCatchupConfiguration .localBucketsOnly () ||
198
- atCheckpoint == mGetHistoryArchiveStateWork ->getHistoryArchiveState ()
199
- .currentLedger ;
195
+ return atCheckpoint ==
196
+ mGetHistoryArchiveStateWork ->getHistoryArchiveState ().currentLedger ;
200
197
}
201
198
202
199
WorkSeqPtr
@@ -213,28 +210,23 @@ CatchupWork::downloadApplyBuckets()
213
210
std::vector<std::shared_ptr<BasicWork>> seq;
214
211
auto version = mApp .getConfig ().LEDGER_PROTOCOL_VERSION ;
215
212
216
- // Download buckets, or skip if catchup is local
217
- if (!mCatchupConfiguration .localBucketsOnly ())
218
- {
219
- std::vector<std::string> hashes =
220
- mBucketHAS ->differingBuckets (mLocalState );
221
- auto getBuckets = std::make_shared<DownloadBucketsWork>(
222
- mApp , mBuckets , hashes, *mDownloadDir , mArchive );
223
- seq.push_back (getBuckets);
224
-
225
- auto verifyHASCallback = [has = *mBucketHAS ](Application& app) {
226
- if (!has.containsValidBuckets (app))
227
- {
228
- CLOG_ERROR (History, " Malformed HAS: invalid buckets" );
229
- return false ;
230
- }
231
- return true ;
232
- };
233
- auto verifyHAS = std::make_shared<WorkWithCallback>(mApp , " verify-has" ,
234
- verifyHASCallback);
235
- seq.push_back (verifyHAS);
236
- version = mVerifiedLedgerRangeStart .header .ledgerVersion ;
237
- }
213
+ std::vector<std::string> hashes = mBucketHAS ->differingBuckets (mLocalState );
214
+ auto getBuckets = std::make_shared<DownloadBucketsWork>(
215
+ mApp , mBuckets , hashes, *mDownloadDir , mArchive );
216
+ seq.push_back (getBuckets);
217
+
218
+ auto verifyHASCallback = [has = *mBucketHAS ](Application& app) {
219
+ if (!has.containsValidBuckets (app))
220
+ {
221
+ CLOG_ERROR (History, " Malformed HAS: invalid buckets" );
222
+ return false ;
223
+ }
224
+ return true ;
225
+ };
226
+ auto verifyHAS = std::make_shared<WorkWithCallback>(mApp , " verify-has" ,
227
+ verifyHASCallback);
228
+ seq.push_back (verifyHAS);
229
+ version = mVerifiedLedgerRangeStart .header .ledgerVersion ;
238
230
239
231
auto applyBuckets = std::make_shared<ApplyBucketsWork>(
240
232
mApp , mBuckets , *mBucketHAS , version);
@@ -291,52 +283,37 @@ BasicWork::State
291
283
CatchupWork::getAndMaybeSetHistoryArchiveState ()
292
284
{
293
285
// First, retrieve the HAS
294
-
295
- // If we're just doing local catchup, set HAS right away
296
- if (mCatchupConfiguration .localBucketsOnly ())
286
+ if (!mGetHistoryArchiveStateWork )
287
+ {
288
+ auto toLedger = mCatchupConfiguration .toLedger () == 0
289
+ ? " CURRENT"
290
+ : std::to_string (mCatchupConfiguration .toLedger ());
291
+ CLOG_INFO (History,
292
+ " Starting catchup with configuration:\n lastClosedLedger: "
293
+ " {}\n toLedger: {}\n count: {}" ,
294
+ mApp .getLedgerManager ().getLastClosedLedgerNum (), toLedger,
295
+ mCatchupConfiguration .count ());
296
+
297
+ auto toCheckpoint =
298
+ mCatchupConfiguration .toLedger () == CatchupConfiguration::CURRENT
299
+ ? CatchupConfiguration::CURRENT
300
+ : HistoryManager::checkpointContainingLedger (
301
+ mCatchupConfiguration .toLedger (), mApp .getConfig ());
302
+ // Set retries to 10 to ensure we retry enough in case current
303
+ // checkpoint isn't published yet
304
+ mGetHistoryArchiveStateWork = addWork<GetHistoryArchiveStateWork>(
305
+ toCheckpoint, mArchive , true , 10 );
306
+ mCurrentWork = mGetHistoryArchiveStateWork ;
307
+ return State::WORK_RUNNING;
308
+ }
309
+ else if (mGetHistoryArchiveStateWork ->getState () != State::WORK_SUCCESS)
297
310
{
298
- mHAS = getCatchupConfiguration ().getHAS ();
299
- releaseAssert (mHAS .has_value ());
311
+ return mGetHistoryArchiveStateWork ->getState ();
300
312
}
301
313
else
302
314
{
303
- // Otherwise, continue with the normal catchup flow: download and verify
304
- // HAS from history archive
305
- if (!mGetHistoryArchiveStateWork )
306
- {
307
- auto toLedger =
308
- mCatchupConfiguration .toLedger () == 0
309
- ? " CURRENT"
310
- : std::to_string (mCatchupConfiguration .toLedger ());
311
- CLOG_INFO (
312
- History,
313
- " Starting catchup with configuration:\n lastClosedLedger: "
314
- " {}\n toLedger: {}\n count: {}" ,
315
- mApp .getLedgerManager ().getLastClosedLedgerNum (), toLedger,
316
- mCatchupConfiguration .count ());
317
-
318
- auto toCheckpoint =
319
- mCatchupConfiguration .toLedger () ==
320
- CatchupConfiguration::CURRENT
321
- ? CatchupConfiguration::CURRENT
322
- : HistoryManager::checkpointContainingLedger (
323
- mCatchupConfiguration .toLedger (), mApp .getConfig ());
324
- // Set retries to 10 to ensure we retry enough in case current
325
- // checkpoint isn't published yet
326
- mGetHistoryArchiveStateWork = addWork<GetHistoryArchiveStateWork>(
327
- toCheckpoint, mArchive , true , 10 );
328
- mCurrentWork = mGetHistoryArchiveStateWork ;
329
- return State::WORK_RUNNING;
330
- }
331
- else if (mGetHistoryArchiveStateWork ->getState () != State::WORK_SUCCESS)
332
- {
333
- return mGetHistoryArchiveStateWork ->getState ();
334
- }
335
- else
336
- {
337
- mHAS = std::make_optional<HistoryArchiveState>(
338
- mGetHistoryArchiveStateWork ->getHistoryArchiveState ());
339
- }
315
+ mHAS = std::make_optional<HistoryArchiveState>(
316
+ mGetHistoryArchiveStateWork ->getHistoryArchiveState ());
340
317
}
341
318
342
319
// Second, perform some validation
@@ -448,8 +425,7 @@ CatchupWork::runCatchupStep()
448
425
// Bucket and transaction processing has started
449
426
if (mCatchupSeq )
450
427
{
451
- releaseAssert (mDownloadVerifyLedgersSeq ||
452
- mCatchupConfiguration .localBucketsOnly ());
428
+ releaseAssert (mDownloadVerifyLedgersSeq );
453
429
releaseAssert (mTransactionsVerifyApplySeq ||
454
430
!catchupRange.replayLedgers ());
455
431
@@ -494,8 +470,7 @@ CatchupWork::runCatchupStep()
494
470
// the node will have to catch up again and it will clear the
495
471
// ledger because clearRebuildForType has not been called yet.
496
472
mApp .getLedgerManager ().setLastClosedLedger (
497
- mVerifiedLedgerRangeStart ,
498
- !mCatchupConfiguration .localBucketsOnly ());
473
+ mVerifiedLedgerRangeStart );
499
474
mBucketsAppliedEmitted = true ;
500
475
mBuckets .clear ();
501
476
mLastApplied =
@@ -534,22 +509,6 @@ CatchupWork::runCatchupStep()
534
509
return mCatchupSeq ->getState ();
535
510
}
536
511
537
- // If we're just doing local catchup, setup bucket application and exit
538
- if (mCatchupConfiguration .localBucketsOnly ())
539
- {
540
- releaseAssert (catchupRange.applyBuckets ());
541
- auto lhhe = mCatchupConfiguration .getHistoryEntry ();
542
- releaseAssert (lhhe);
543
- mVerifiedLedgerRangeStart = *lhhe;
544
-
545
- mBucketVerifyApplySeq = downloadApplyBuckets ();
546
- std::vector<std::shared_ptr<BasicWork>> seq{mBucketVerifyApplySeq };
547
-
548
- mCatchupSeq = addWork<WorkSequence>(" catchup-seq" , seq, RETRY_NEVER);
549
- mCurrentWork = mCatchupSeq ;
550
- return State::WORK_RUNNING;
551
- }
552
-
553
512
// Otherwise, proceed with normal flow. Still waiting for ledger headers
554
513
if (mDownloadVerifyLedgersSeq )
555
514
{
@@ -649,10 +608,6 @@ CatchupWork::onFailureRaise()
649
608
{
650
609
CLOG_WARNING (History, " Catchup failed" );
651
610
Work::onFailureRaise ();
652
- if (mCatchupConfiguration .localBucketsOnly ())
653
- {
654
- throw std::runtime_error (" Unable to rebuild local state" );
655
- }
656
611
}
657
612
658
613
void
0 commit comments