Skip to content

Commit e417314

Browse files
committed
Some cleanup post-rebase, refresh comments
1 parent f5cde0e commit e417314

19 files changed

+124
-108
lines changed

src/bucket/BucketManager.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "ledger/LedgerManager.h"
1919
#include "ledger/LedgerTxn.h"
2020
#include "ledger/LedgerTypeUtils.h"
21+
#include "ledger/NetworkConfig.h"
2122
#include "main/Application.h"
2223
#include "main/Config.h"
2324
#include "util/Fs.h"
@@ -1080,7 +1081,7 @@ EvictedStateVectors
10801081
BucketManager::resolveBackgroundEvictionScan(
10811082
AbstractLedgerTxn& ltx, uint32_t ledgerSeq,
10821083
LedgerKeySet const& modifiedKeys, uint32_t ledgerVers,
1083-
SorobanNetworkConfig& networkConfig)
1084+
SorobanNetworkConfig const& networkConfig)
10841085
{
10851086
ZoneScoped;
10861087
releaseAssert(mEvictionStatistics);

src/bucket/BucketManager.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class BucketSnapshotManager;
3636
class SearchableLiveBucketListSnapshot;
3737
struct BucketEntryCounters;
3838
enum class LedgerEntryTypeAndDurability : uint32_t;
39+
class SorobanNetworkConfig;
3940

4041
struct HistoryArchiveState;
4142

@@ -307,7 +308,7 @@ class BucketManager : NonMovableOrCopyable
307308
resolveBackgroundEvictionScan(AbstractLedgerTxn& ltx, uint32_t ledgerSeq,
308309
LedgerKeySet const& modifiedKeys,
309310
uint32_t ledgerVers,
310-
SorobanNetworkConfig& networkConfig);
311+
SorobanNetworkConfig const& networkConfig);
311312

312313
medida::Meter& getBloomMissMeter() const;
313314
medida::Meter& getBloomLookupMeter() const;

src/bucket/LiveBucketList.h

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
namespace stellar
1111
{
12-
13-
class SorobanNetworkConfig;
14-
1512
// The LiveBucketList stores the current canonical state of the ledger. It is
1613
// made up of LiveBucket buckets, which in turn store individual entries of type
1714
// BucketEntry. When an entry is "evicted" from the ledger, it is removed from

src/bucket/test/BucketListTests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]")
869869
LedgerManagerForBucketTests& lm = app->getLedgerManager();
870870

871871
auto& networkConfig =
872-
app->getLedgerManager().getMutableSorobanNetworkConfig();
872+
app->getLedgerManager().getSorobanNetworkConfigReadOnly();
873873

874874
uint32_t windowSize = networkConfig.stateArchivalSettings()
875875
.bucketListSizeWindowSampleSize;

src/bucket/test/BucketTestUtils.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ closeLedger(Application& app, std::optional<SecretKey> skToSignValue,
101101
app.getHerder().externalizeValue(TxSetXDRFrame::makeEmpty(lcl), ledgerNum,
102102
lcl.header.scpValue.closeTime, upgrades,
103103
skToSignValue);
104-
testutil::crankUntil(
105-
app,
106-
[&lm, ledgerNum]() { return lm.getLastClosedLedgerNum() == ledgerNum; },
107-
std::chrono::seconds(10));
108104
return lm.getLastClosedLedgerHeader().hash;
109105
}
110106

@@ -238,7 +234,7 @@ LedgerManagerForBucketTests::transferLedgerEntriesToBucketList(
238234
mApp.getBucketManager().resolveBackgroundEvictionScan(
239235
ltxEvictions, lh.ledgerSeq, keys, initialLedgerVers,
240236
mApp.getLedgerManager()
241-
.getMutableSorobanNetworkConfig());
237+
.getSorobanNetworkConfigForApply());
242238

243239
if (protocolVersionStartsFrom(
244240
initialLedgerVers,

src/catchup/CatchupWork.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ CatchupWork::runCatchupStep()
524524
// In this case we should actually have been caught-up during
525525
// the replay process and, if judged successful, our LCL should
526526
// be the one provided as well.
527-
auto lastClosed =
527+
auto& lastClosed =
528528
mApp.getLedgerManager().getLastClosedLedgerHeader();
529529
releaseAssert(mLastApplied.hash == lastClosed.hash);
530530
releaseAssert(mLastApplied.header == lastClosed.header);

src/database/Database.h

+2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ class Database : NonMovableOrCopyable
141141
// Save `vers` as schema version.
142142
void putSchemaVersion(unsigned long vers);
143143

144+
// Prepared statements cache may be accessed by mutliple threads (each using
145+
// a different session), so use a mutex to synchronize access.
144146
std::mutex mutable mStatementsMutex;
145147

146148
public:

src/herder/HerderImpl.cpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,15 @@ HerderImpl::valueExternalized(uint64 slotIndex, StellarValue const& value,
480480

481481
// Check to see if quorums have changed and we need to reanalyze.
482482
checkAndMaybeReanalyzeQuorumMap();
483+
484+
// heart beat *after* doing all the work (ensures that we do not include
485+
// the overhead of externalization in the way we track SCP)
486+
// Note: this only makes sense in the context of synchronous ledger
487+
// application on the main thread.
488+
if (!mApp.getConfig().parallelLedgerClose())
489+
{
490+
trackingHeartBeat();
491+
}
483492
}
484493
else
485494
{
@@ -1156,7 +1165,7 @@ HerderImpl::lastClosedLedgerIncreased(bool latest, TxSetXDRFrameConstPtr txSet)
11561165
{
11571166
// Re-start heartbeat tracking _after_ applying the most up-to-date
11581167
// ledger. This guarantees out-of-sync timer won't fire while we have
1159-
// ledgers to apply.
1168+
// ledgers to apply (applicable during parallel ledger close).
11601169
trackingHeartBeat();
11611170

11621171
// Ensure out of sync recovery did not get triggered while we were
@@ -1369,6 +1378,8 @@ HerderImpl::triggerNextLedger(uint32_t ledgerSeqToTrigger,
13691378
// If applying, the next ledger will trigger voting
13701379
if (mLedgerManager.isApplying())
13711380
{
1381+
// This can only happen when closing ledgers in parallel
1382+
releaseAssert(mApp.getConfig().parallelLedgerClose());
13721383
CLOG_DEBUG(Herder, "triggerNextLedger: skipping (applying) : {}",
13731384
mApp.getStateHuman());
13741385
return;
@@ -1560,7 +1571,7 @@ HerderImpl::getUpgradesJson()
15601571
void
15611572
HerderImpl::forceSCPStateIntoSyncWithLastClosedLedger()
15621573
{
1563-
auto header = mLedgerManager.getLastClosedLedgerHeader().header;
1574+
auto const& header = mLedgerManager.getLastClosedLedgerHeader().header;
15641575
setTrackingSCPState(header.ledgerSeq, header.scpValue,
15651576
/* isTrackingNetwork */ true);
15661577
}
@@ -2360,7 +2371,7 @@ HerderImpl::herderOutOfSync()
23602371
// are no ledgers queued to be applied. If there are ledgers queued, it's
23612372
// possible the rest of the network is waiting for this node to vote. In
23622373
// this case we should _still_ remain in tracking and emit nomination; If
2363-
// the nodes does not hear anything from the network after that, then node
2374+
// the node does not hear anything from the network after that, then node
23642375
// can go into out of sync recovery.
23652376
releaseAssert(threadIsMain());
23662377
releaseAssert(!mLedgerManager.isApplying());

src/herder/HerderPersistenceImpl.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,8 @@ HerderPersistence::copySCPHistoryToStream(Database& db, soci::session& sess,
236236
XDROutputFileStream& scpHistory)
237237
{
238238
ZoneScoped;
239-
// TODO: this may conflict with main thread, as this is done in the
240-
// background (this is the case in master today, so can be fixed
241-
// later).
239+
// Subtle: changing these queries may cause conflicts with main thread
240+
// https://github.com/stellar/stellar-core/issues/4589
242241

243242
uint32_t begin = ledgerSeq, end = ledgerSeq + ledgerCount;
244243
size_t n = 0;

src/herder/HerderSCPDriver.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ HerderSCPDriver::validateValueHelper(uint64_t slotIndex, StellarValue const& b,
221221
}
222222
}
223223

224-
auto lhhe = mLedgerManager.getLastClosedLedgerHeader();
224+
auto const& lcl = mLedgerManager.getLastClosedLedgerHeader();
225225
// when checking close time, start with what we have locally
226-
lastCloseTime = lhhe.header.scpValue.closeTime;
226+
lastCloseTime = lcl.header.scpValue.closeTime;
227227

228228
// if this value is not for our local state,
229229
// perform as many checks as we can
230-
if (slotIndex != (lhhe.header.ledgerSeq + 1))
230+
if (slotIndex != (lcl.header.ledgerSeq + 1))
231231
{
232-
if (slotIndex == lhhe.header.ledgerSeq)
232+
if (slotIndex == lcl.header.ledgerSeq)
233233
{
234234
// previous ledger
235235
if (b.closeTime != lastCloseTime)
@@ -240,7 +240,7 @@ HerderSCPDriver::validateValueHelper(uint64_t slotIndex, StellarValue const& b,
240240
return SCPDriver::kInvalidValue;
241241
}
242242
}
243-
else if (slotIndex < lhhe.header.ledgerSeq)
243+
else if (slotIndex < lcl.header.ledgerSeq)
244244
{
245245
// basic sanity check on older value
246246
if (b.closeTime >= lastCloseTime)
@@ -323,7 +323,7 @@ HerderSCPDriver::validateValueHelper(uint64_t slotIndex, StellarValue const& b,
323323

324324
res = SCPDriver::kInvalidValue;
325325
}
326-
else if (!checkAndCacheTxSetValid(*txSet, lhhe, closeTimeOffset))
326+
else if (!checkAndCacheTxSetValid(*txSet, lcl, closeTimeOffset))
327327
{
328328
CLOG_DEBUG(Herder,
329329
"HerderSCPDriver::validateValue i: {} invalid txSet {}",
@@ -614,6 +614,7 @@ HerderSCPDriver::combineCandidates(uint64_t slotIndex,
614614
std::set<TransactionFramePtr> aggSet;
615615

616616
releaseAssert(!mLedgerManager.isApplying());
617+
releaseAssert(threadIsMain());
617618
auto const& lcl = mLedgerManager.getLastClosedLedgerHeader();
618619

619620
Hash candidatesHash;

src/herder/TxSetFrame.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ applySurgePricing(TxSetPhase phase, TxFrameList const& txs, Application& app)
528528
ZoneScoped;
529529
releaseAssert(threadIsMain());
530530
releaseAssert(!app.getLedgerManager().isApplying());
531-
531+
532532
auto const& lclHeader =
533533
app.getLedgerManager().getLastClosedLedgerHeader().header;
534534
std::vector<bool> hadTxNotFittingLane;

src/history/test/HistoryTestsUtils.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,6 @@ CatchupSimulation::externalizeLedger(HerderImpl& herder, uint32_t ledger)
947947
lcd.getLedgerSeq(), lcd.getTxSet());
948948
herder.getHerderSCPDriver().valueExternalized(
949949
lcd.getLedgerSeq(), xdr::xdr_to_opaque(lcd.getValue()));
950-
951-
// TODO: crank the clock
952950
}
953951

954952
void

src/invariant/BucketListIsConsistentWithDatabase.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "bucket/BucketManager.h"
88
#include "bucket/LiveBucket.h"
99
#include "bucket/LiveBucketList.h"
10-
#include "crypto/Hex.h"
1110
#include "database/Database.h"
1211
#include "history/HistoryArchive.h"
1312
#include "invariant/InvariantManager.h"

0 commit comments

Comments
 (0)