@@ -95,8 +95,8 @@ std::string
9595ArchivedStateConsistency::checkOnLedgerCommit (
9696 SearchableSnapshotConstPtr lclLiveState,
9797 SearchableHotArchiveSnapshotConstPtr lclHotArchiveState,
98- std::vector<LedgerEntry> const & evictedFromLive ,
99- std::vector<LedgerKey> const & deletedKeysFromLive ,
98+ std::vector<LedgerEntry> const & persitentEvictedFromLive ,
99+ std::vector<LedgerKey> const & tempAndTTLEvictedFromLive ,
100100 UnorderedMap<LedgerKey, LedgerEntry> const & restoredFromArchive,
101101 UnorderedMap<LedgerKey, LedgerEntry> const & restoredFromLiveState)
102102{
@@ -108,10 +108,6 @@ ArchivedStateConsistency::checkOnLedgerCommit(
108108 lclLiveState->getLedgerHeader ().ledgerVersion ,
109109 LiveBucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
110110 {
111- CLOG_INFO (Invariant,
112- " Skipping ArchivedStateConsistency invariant for "
113- " protocol version {}" ,
114- lclLiveState->getLedgerHeader ().ledgerVersion );
115111 return std::string{};
116112 }
117113 auto ledgerSeq = lclLiveState->getLedgerSeq () + 1 ;
@@ -121,42 +117,28 @@ ArchivedStateConsistency::checkOnLedgerCommit(
121117 LedgerKeySet allKeys;
122118
123119 // Keys for evicted from live entries
124- for (auto const & e : evictedFromLive )
120+ for (auto const & e : persitentEvictedFromLive )
125121 {
126122 auto key = LedgerEntryKey (e);
123+ releaseAssertOrThrow (isPersistentEntry (key));
127124 allKeys.insert (key);
128- if (isPersistentEntry (key))
129- {
130- allKeys.insert (getTTLKey (e));
131- }
132125 }
133126
134127 // Keys for deleted from live (temp and TTLs)
135- for (auto const & k : deletedKeysFromLive )
128+ for (auto const & k : tempAndTTLEvictedFromLive )
136129 {
130+ releaseAssertOrThrow (!isPersistentEntry (k));
137131 allKeys.insert (k);
138- if (isPersistentEntry (k))
139- {
140- allKeys.insert (getTTLKey (k));
141- }
142132 }
143133
144134 // Keys for restored entries
145135 for (auto const & [key, entry] : restoredFromArchive)
146136 {
147137 allKeys.insert (key);
148- if (isPersistentEntry (key))
149- {
150- allKeys.insert (getTTLKey (entry));
151- }
152138 }
153139 for (auto const & [key, entry] : restoredFromLiveState)
154140 {
155141 allKeys.insert (key);
156- if (isPersistentEntry (key))
157- {
158- allKeys.insert (getTTLKey (entry));
159- }
160142 }
161143
162144 // Preload from both live and archived state
@@ -180,14 +162,14 @@ ArchivedStateConsistency::checkOnLedgerCommit(
180162 }
181163
182164 UnorderedSet<LedgerKey> deletedKeys;
183- for (auto const & k : deletedKeysFromLive )
165+ for (auto const & k : tempAndTTLEvictedFromLive )
184166 {
185167 deletedKeys.insert (k);
186168 }
187169
188170 auto evictionRes = checkEvictionInvariants (
189171 preloadedLiveEntries, preloadedArchivedEntries, deletedKeys,
190- evictedFromLive , ledgerSeq, ledgerVers);
172+ persitentEvictedFromLive , ledgerSeq, ledgerVers);
191173
192174 auto restoreRes = checkRestoreInvariants (
193175 preloadedLiveEntries, preloadedArchivedEntries, restoredFromArchive,
@@ -450,20 +432,22 @@ ArchivedStateConsistency::checkRestoreInvariants(
450432 // Skip this check prior to protocol 24, since there was a bug in 23
451433 // Don't check lastModifiedLedgerSeq, since it may have been updated by
452434 // the ltx
453- else if (!(hotArchiveEntry->second .archivedEntry ().data ==
454- entry.data ) ||
455- !(hotArchiveEntry->second .archivedEntry ().ext == entry.ext ) &&
456- protocolVersionStartsFrom (ledgerVer,
457- ProtocolVersion::V_24))
435+ else if (protocolVersionStartsFrom (ledgerVer, ProtocolVersion::V_24))
458436 {
459- return fmt::format (
460- FMT_STRING (
461- " ArchivedStateConsistency invariant failed: "
462- " Restored entry from archive has incorrect value: Entry to "
463- " Restore: {}, Hot Archive Entry: {}" ),
464- xdrToCerealString (entry, " entry_to_restore" ),
465- xdrToCerealString (hotArchiveEntry->second .archivedEntry (),
466- " hot_archive_entry" ));
437+ bool isValid =
438+ hotArchiveEntry->second .archivedEntry ().data == entry.data &&
439+ hotArchiveEntry->second .archivedEntry ().ext == entry.ext ;
440+ if (!isValid)
441+ {
442+ return fmt::format (
443+ FMT_STRING (" ArchivedStateConsistency invariant failed: "
444+ " Restored entry from archive has incorrect "
445+ " value: Entry to "
446+ " Restore: {}, Hot Archive Entry: {}" ),
447+ xdrToCerealString (entry, " entry_to_restore" ),
448+ xdrToCerealString (hotArchiveEntry->second .archivedEntry (),
449+ " hot_archive_entry" ));
450+ }
467451 }
468452 }
469453
0 commit comments