Skip to content

Commit fdbeacc

Browse files
committed
Add testing support for ledgerMaxDependentTxClusters
1 parent 2b0129a commit fdbeacc

10 files changed

+2573
-2501
lines changed

src/ledger/NetworkConfig.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,11 @@ SorobanNetworkConfig::operator==(SorobanNetworkConfig const& other) const
22772277
mCpuCostParams == other.cpuCostParams() &&
22782278
mMemCostParams == other.memCostParams() &&
22792279

2280+
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
2281+
mLedgerMaxDependentTxClusters ==
2282+
other.ledgerMaxDependentTxClusters() &&
2283+
#endif
2284+
22802285
mStateArchivalSettings == other.stateArchivalSettings() &&
22812286
mEvictionIterator == other.evictionIterator();
22822287
}

src/simulation/LoadGenerator.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,11 @@ GeneratedLoadConfig::copySorobanNetworkConfigToUpgradeConfig(
15611561

15621562
upgradeCfg.writeFee1KBBucketListLow = cfg.writeFee1KBBucketListLow();
15631563
upgradeCfg.writeFee1KBBucketListHigh = cfg.writeFee1KBBucketListHigh();
1564+
1565+
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
1566+
upgradeCfg.ledgerMaxDependentTxClusters =
1567+
cfg.ledgerMaxDependentTxClusters();
1568+
#endif
15641569
}
15651570

15661571
GeneratedLoadConfig

src/simulation/TxGenerator.cpp

+27-6
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,26 @@ TxGenerator::getConfigUpgradeSetFromLoadConfig(
713713
xdr::xvector<ConfigSettingEntry> updatedEntries;
714714

715715
LedgerSnapshot lsg(mApp);
716-
for (uint32_t i = 0;
717-
i < static_cast<uint32_t>(CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW); ++i)
716+
for (auto t : xdr::xdr_traits<ConfigSettingID>::enum_values())
718717
{
719-
auto entry = lsg.load(configSettingKey(static_cast<ConfigSettingID>(i)))
720-
.current();
718+
auto type = static_cast<ConfigSettingID>(t);
719+
if (SorobanNetworkConfig::isNonUpgradeableConfigSettingEntry(type))
720+
{
721+
continue;
722+
}
723+
724+
auto entryPtr = lsg.load(configSettingKey(type));
725+
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
726+
// This could happen if we have not yet upgraded
727+
if (t == CONFIG_SETTING_CONTRACT_PARALLEL_COMPUTE_V0 && !entryPtr)
728+
{
729+
continue;
730+
}
731+
#endif
732+
auto entry = entryPtr.current();
733+
721734
auto& setting = entry.data.configSetting();
722-
switch (static_cast<ConfigSettingID>(i))
735+
switch (type)
723736
{
724737
case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES:
725738
if (upgradeCfg.maxContractSizeBytes.has_value())
@@ -949,8 +962,16 @@ TxGenerator::getConfigUpgradeSetFromLoadConfig(
949962
*upgradeCfg.ledgerMaxTxCount;
950963
}
951964
break;
965+
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
966+
case CONFIG_SETTING_CONTRACT_PARALLEL_COMPUTE_V0:
967+
if (upgradeCfg.ledgerMaxDependentTxClusters.has_value())
968+
{
969+
setting.contractParallelCompute().ledgerMaxDependentTxClusters =
970+
*upgradeCfg.ledgerMaxDependentTxClusters;
971+
}
972+
break;
973+
#endif
952974
default:
953-
releaseAssert(false);
954975
break;
955976
}
956977

src/simulation/TxGenerator.h

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ struct SorobanUpgradeConfig
6767

6868
std::optional<int64_t> writeFee1KBBucketListLow{};
6969
std::optional<int64_t> writeFee1KBBucketListHigh{};
70+
71+
// Parallel execution settings
72+
std::optional<uint32_t> ledgerMaxDependentTxClusters{};
7073
};
7174

7275
class TxGenerator

src/simulation/test/LoadGeneratorTests.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]")
355355
rand_uniform<int64_t>(INT64_MAX - 10'000, INT64_MAX);
356356
upgradeCfg.startingEvictionScanLevel = rand_uniform<uint32_t>(4, 8);
357357

358+
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
359+
if (protocolVersionStartsFrom(Config::CURRENT_LEDGER_PROTOCOL_VERSION,
360+
ProtocolVersion::V_23))
361+
{
362+
upgradeCfg.ledgerMaxDependentTxClusters = rand_uniform<uint32_t>(2, 10);
363+
}
364+
#endif
365+
358366
auto upgradeSetKey = loadGen.getConfigUpgradeSetKey(
359367
createUpgradeLoadGenConfig.getSorobanUpgradeConfig());
360368

@@ -398,10 +406,16 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]")
398406
upgrades);
399407
}
400408

401-
// Loadgen doesn't update the cost types.
402-
REQUIRE(upgrades.updatedEntry.size() == 10);
403409
for (auto const& setting : upgrades.updatedEntry)
404410
{
411+
// Loadgen doesn't update the cost types and non-upgradeable settings
412+
REQUIRE(!SorobanNetworkConfig::isNonUpgradeableConfigSettingEntry(
413+
setting.configSettingID()));
414+
REQUIRE(setting.configSettingID() !=
415+
CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS);
416+
REQUIRE(setting.configSettingID() !=
417+
CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES);
418+
405419
switch (setting.configSettingID())
406420
{
407421
case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES:
@@ -471,6 +485,13 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]")
471485
REQUIRE(setting.contractExecutionLanes().ledgerMaxTxCount ==
472486
upgradeCfg.ledgerMaxTxCount);
473487
break;
488+
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
489+
case CONFIG_SETTING_CONTRACT_PARALLEL_COMPUTE_V0:
490+
REQUIRE(setting.contractParallelCompute()
491+
.ledgerMaxDependentTxClusters ==
492+
upgradeCfg.ledgerMaxDependentTxClusters);
493+
break;
494+
#endif
474495
default:
475496
REQUIRE(false);
476497
break;

0 commit comments

Comments
 (0)