@@ -394,6 +394,7 @@ LedgerManagerImpl::loadLastKnownLedger(bool restoreBucketlist)
394
394
// configs right away
395
395
LedgerTxn ltx (mApp .getLedgerTxnRoot ());
396
396
updateNetworkConfig (ltx);
397
+ mSorobanNetworkConfigReadOnly = mSorobanNetworkConfigForApply ;
397
398
}
398
399
}
399
400
@@ -452,7 +453,7 @@ LedgerManagerImpl::maxLedgerResources(bool isSoroban)
452
453
453
454
if (isSoroban)
454
455
{
455
- auto conf = getSorobanNetworkConfig ();
456
+ auto conf = getSorobanNetworkConfigReadOnly ();
456
457
std::vector<int64_t > limits = {conf.ledgerMaxTxCount (),
457
458
conf.ledgerMaxInstructions (),
458
459
conf.ledgerMaxTransactionSizesBytes (),
@@ -474,7 +475,8 @@ LedgerManagerImpl::maxSorobanTransactionResources()
474
475
{
475
476
ZoneScoped;
476
477
477
- auto const & conf = mApp .getLedgerManager ().getSorobanNetworkConfig ();
478
+ auto const & conf =
479
+ mApp .getLedgerManager ().getSorobanNetworkConfigReadOnly ();
478
480
int64_t const opCount = 1 ;
479
481
std::vector<int64_t > limits = {opCount,
480
482
conf.txMaxInstructions (),
@@ -538,35 +540,37 @@ LedgerManagerImpl::getLastClosedLedgerNum() const
538
540
return mLastClosedLedger .header .ledgerSeq ;
539
541
}
540
542
541
- SorobanNetworkConfig&
542
- LedgerManagerImpl::getSorobanNetworkConfigInternal ()
543
+ SorobanNetworkConfig const &
544
+ LedgerManagerImpl::getSorobanNetworkConfigReadOnly ()
543
545
{
544
546
releaseAssert (threadIsMain ());
545
- releaseAssert (mSorobanNetworkConfig );
546
- return *mSorobanNetworkConfig ;
547
+ releaseAssert (hasSorobanNetworkConfig () );
548
+ return *mSorobanNetworkConfigReadOnly ;
547
549
}
548
550
549
551
SorobanNetworkConfig const &
550
- LedgerManagerImpl::getSorobanNetworkConfig ()
552
+ LedgerManagerImpl::getSorobanNetworkConfigForApply ()
551
553
{
552
- releaseAssert (threadIsMain ());
553
- return getSorobanNetworkConfigInternal ();
554
+ // Must be called from ledger close thread only
555
+ releaseAssert (mSorobanNetworkConfigForApply );
556
+ return *mSorobanNetworkConfigForApply ;
554
557
}
555
558
556
559
bool
557
560
LedgerManagerImpl::hasSorobanNetworkConfig () const
558
561
{
559
562
releaseAssert (threadIsMain ());
560
- return mSorobanNetworkConfig . has_value ( );
563
+ return static_cast < bool >( mSorobanNetworkConfigReadOnly );
561
564
}
562
565
563
566
#ifdef BUILD_TESTS
564
567
SorobanNetworkConfig&
565
568
LedgerManagerImpl::getMutableSorobanNetworkConfig ()
566
569
{
567
570
releaseAssert (threadIsMain ());
568
- return getSorobanNetworkConfigInternal () ;
571
+ return * mSorobanNetworkConfigForApply ;
569
572
}
573
+
570
574
std::vector<TransactionMetaFrame> const &
571
575
LedgerManagerImpl::getLastClosedLedgerTxMeta ()
572
576
{
@@ -589,48 +593,41 @@ LedgerManagerImpl::getSorobanMetrics()
589
593
void
590
594
LedgerManagerImpl::publishSorobanMetrics ()
591
595
{
592
- releaseAssert ( mSorobanNetworkConfig );
596
+ auto const & conf = getSorobanNetworkConfigForApply ( );
593
597
// first publish the network config limits
594
598
mSorobanMetrics .mConfigContractDataKeySizeBytes .set_count (
595
- mSorobanNetworkConfig -> maxContractDataKeySizeBytes ());
599
+ conf. maxContractDataKeySizeBytes ());
596
600
mSorobanMetrics .mConfigMaxContractDataEntrySizeBytes .set_count (
597
- mSorobanNetworkConfig -> maxContractDataEntrySizeBytes ());
601
+ conf. maxContractDataEntrySizeBytes ());
598
602
mSorobanMetrics .mConfigMaxContractSizeBytes .set_count (
599
- mSorobanNetworkConfig ->maxContractSizeBytes ());
600
- mSorobanMetrics .mConfigTxMaxSizeByte .set_count (
601
- mSorobanNetworkConfig ->txMaxSizeBytes ());
602
- mSorobanMetrics .mConfigTxMaxCpuInsn .set_count (
603
- mSorobanNetworkConfig ->txMaxInstructions ());
604
- mSorobanMetrics .mConfigTxMemoryLimitBytes .set_count (
605
- mSorobanNetworkConfig ->txMemoryLimit ());
603
+ conf.maxContractSizeBytes ());
604
+ mSorobanMetrics .mConfigTxMaxSizeByte .set_count (conf.txMaxSizeBytes ());
605
+ mSorobanMetrics .mConfigTxMaxCpuInsn .set_count (conf.txMaxInstructions ());
606
+ mSorobanMetrics .mConfigTxMemoryLimitBytes .set_count (conf.txMemoryLimit ());
606
607
mSorobanMetrics .mConfigTxMaxReadLedgerEntries .set_count (
607
- mSorobanNetworkConfig ->txMaxReadLedgerEntries ());
608
- mSorobanMetrics .mConfigTxMaxReadBytes .set_count (
609
- mSorobanNetworkConfig ->txMaxReadBytes ());
608
+ conf.txMaxReadLedgerEntries ());
609
+ mSorobanMetrics .mConfigTxMaxReadBytes .set_count (conf.txMaxReadBytes ());
610
610
mSorobanMetrics .mConfigTxMaxWriteLedgerEntries .set_count (
611
- mSorobanNetworkConfig ->txMaxWriteLedgerEntries ());
612
- mSorobanMetrics .mConfigTxMaxWriteBytes .set_count (
613
- mSorobanNetworkConfig ->txMaxWriteBytes ());
611
+ conf.txMaxWriteLedgerEntries ());
612
+ mSorobanMetrics .mConfigTxMaxWriteBytes .set_count (conf.txMaxWriteBytes ());
614
613
mSorobanMetrics .mConfigMaxContractEventsSizeBytes .set_count (
615
- mSorobanNetworkConfig ->txMaxContractEventsSizeBytes ());
616
- mSorobanMetrics .mConfigLedgerMaxTxCount .set_count (
617
- mSorobanNetworkConfig ->ledgerMaxTxCount ());
614
+ conf.txMaxContractEventsSizeBytes ());
615
+ mSorobanMetrics .mConfigLedgerMaxTxCount .set_count (conf.ledgerMaxTxCount ());
618
616
mSorobanMetrics .mConfigLedgerMaxInstructions .set_count (
619
- mSorobanNetworkConfig -> ledgerMaxInstructions ());
617
+ conf. ledgerMaxInstructions ());
620
618
mSorobanMetrics .mConfigLedgerMaxTxsSizeByte .set_count (
621
- mSorobanNetworkConfig -> ledgerMaxTransactionSizesBytes ());
619
+ conf. ledgerMaxTransactionSizesBytes ());
622
620
mSorobanMetrics .mConfigLedgerMaxReadLedgerEntries .set_count (
623
- mSorobanNetworkConfig -> ledgerMaxReadLedgerEntries ());
621
+ conf. ledgerMaxReadLedgerEntries ());
624
622
mSorobanMetrics .mConfigLedgerMaxReadBytes .set_count (
625
- mSorobanNetworkConfig -> ledgerMaxReadBytes ());
623
+ conf. ledgerMaxReadBytes ());
626
624
mSorobanMetrics .mConfigLedgerMaxWriteEntries .set_count (
627
- mSorobanNetworkConfig -> ledgerMaxWriteLedgerEntries ());
625
+ conf. ledgerMaxWriteLedgerEntries ());
628
626
mSorobanMetrics .mConfigLedgerMaxWriteBytes .set_count (
629
- mSorobanNetworkConfig -> ledgerMaxWriteBytes ());
627
+ conf. ledgerMaxWriteBytes ());
630
628
mSorobanMetrics .mConfigBucketListTargetSizeByte .set_count (
631
- mSorobanNetworkConfig ->bucketListTargetSizeBytes ());
632
- mSorobanMetrics .mConfigFeeWrite1KB .set_count (
633
- mSorobanNetworkConfig ->feeWrite1KB ());
629
+ conf.bucketListTargetSizeBytes ());
630
+ mSorobanMetrics .mConfigFeeWrite1KB .set_count (conf.feeWrite1KB ());
634
631
635
632
// then publish the actual ledger usage
636
633
mSorobanMetrics .publishAndResetLedgerWideMetrics ();
@@ -1265,7 +1262,7 @@ LedgerManagerImpl::maybeResetLedgerCloseMetaDebugStream(uint32_t ledgerSeq)
1265
1262
}
1266
1263
}
1267
1264
1268
- std::shared_ptr<SearchableLiveBucketListSnapshot const >
1265
+ SearchableSnapshotConstPtr
1269
1266
LedgerManagerImpl::getCurrentLedgerStateSnaphot ()
1270
1267
{
1271
1268
if (!mReadOnlyLedgerStateSnapshot )
@@ -1293,9 +1290,9 @@ LedgerManagerImpl::advanceLedgerPointers(LedgerHeader const& header,
1293
1290
1294
1291
// NB: with parallel ledger close, this will have to be called strictly from
1295
1292
// the main thread,
1296
- auto prevLedgerSeq = mLastClosedLedger .header .ledgerSeq ;
1297
1293
mLastClosedLedger .hash = ledgerHash;
1298
1294
mLastClosedLedger .header = header;
1295
+ mSorobanNetworkConfigReadOnly = mSorobanNetworkConfigForApply ;
1299
1296
1300
1297
auto & bm = mApp .getBucketManager ();
1301
1298
auto liveSnapshot = std::make_unique<BucketListSnapshot<LiveBucket>>(
@@ -1322,11 +1319,12 @@ LedgerManagerImpl::updateNetworkConfig(AbstractLedgerTxn& rootLtx)
1322
1319
1323
1320
if (protocolVersionStartsFrom (ledgerVersion, SOROBAN_PROTOCOL_VERSION))
1324
1321
{
1325
- if (!mSorobanNetworkConfig )
1322
+ if (!mSorobanNetworkConfigForApply )
1326
1323
{
1327
- mSorobanNetworkConfig = std::make_optional<SorobanNetworkConfig>();
1324
+ mSorobanNetworkConfigForApply =
1325
+ std::make_shared<SorobanNetworkConfig>();
1328
1326
}
1329
- mSorobanNetworkConfig ->loadFromLedger (
1327
+ mSorobanNetworkConfigForApply ->loadFromLedger (
1330
1328
rootLtx, mApp .getConfig ().CURRENT_LEDGER_PROTOCOL_VERSION ,
1331
1329
ledgerVersion);
1332
1330
publishSorobanMetrics ();
@@ -1712,8 +1710,8 @@ LedgerManagerImpl::transferLedgerEntriesToBucketList(
1712
1710
ltxEvictions.commit ();
1713
1711
}
1714
1712
1715
- getSorobanNetworkConfigInternal (). maybeSnapshotBucketListSize (
1716
- lh. ledgerSeq , ltx, mApp );
1713
+ mSorobanNetworkConfigForApply -> maybeSnapshotBucketListSize (lh. ledgerSeq ,
1714
+ ltx, mApp );
1717
1715
}
1718
1716
1719
1717
ltx.getAllEntries (initEntries, liveEntries, deadEntries);
@@ -1762,7 +1760,7 @@ LedgerManagerImpl::ledgerClosed(
1762
1760
protocolVersionStartsFrom (initialLedgerVers, SOROBAN_PROTOCOL_VERSION))
1763
1761
{
1764
1762
ledgerCloseMeta->setNetworkConfiguration (
1765
- getSorobanNetworkConfig (),
1763
+ getSorobanNetworkConfigReadOnly (),
1766
1764
mApp .getConfig ().EMIT_LEDGER_CLOSE_META_EXT_V1 );
1767
1765
}
1768
1766
0 commit comments