Skip to content

Commit d14e7b6

Browse files
Use re-calibrated costs for loadgen. (#4601)
# Description Use re-calibrated costs for loadgen. Also update the `generate soroban load` test to not use the config for genesis and go through the protocol upgrade instead, so that it resembles the supercluster missions closer. # Checklist - [ ] Reviewed the [contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes) document - [ ] Rebased on top of master (no merge commits) - [ ] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio extension) - [ ] Compiles - [ ] Ran all tests - [ ] If change impacts performance, include supporting evidence per the [performance document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)
2 parents c8dda05 + 3f8a1ce commit d14e7b6

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/herder/Upgrades.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,16 @@ Upgrades::applyVersionUpgrade(Application& app, AbstractLedgerTxn& ltx,
11991199
if (needUpgradeToVersion(SOROBAN_PROTOCOL_VERSION, prevVersion, newVersion))
12001200
{
12011201
SorobanNetworkConfig::createLedgerEntriesForV20(ltx, app);
1202+
#ifdef BUILD_TESTS
1203+
// Update the costs in case if we're in loadgen mode, so that the costs
1204+
// reflect the most recent calibration on p20. This would break
1205+
// if we tried to replay the ledger, but we shouldn't be combining load
1206+
// generation with the ledger replay.
1207+
if (app.getConfig().ARTIFICIALLY_GENERATE_LOAD_FOR_TESTING)
1208+
{
1209+
SorobanNetworkConfig::updateRecalibratedCostTypesForV20(ltx);
1210+
}
1211+
#endif
12021212
}
12031213
if (needUpgradeToVersion(ProtocolVersion::V_21, prevVersion, newVersion))
12041214
{

src/simulation/test/LoadGeneratorTests.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]")
197197
Simulation::pointer simulation =
198198
Topologies::pair(Simulation::OVER_LOOPBACK, networkID, [&](int i) {
199199
auto cfg = getTestConfig(i);
200-
cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE = 5000;
201-
// Use tight bounds to we can verify storage works properly
200+
cfg.USE_CONFIG_FOR_GENESIS = false;
201+
cfg.ARTIFICIALLY_GENERATE_LOAD_FOR_TESTING = true;
202+
// Use tight bounds to we can verify storage works properly
202203
cfg.LOADGEN_NUM_DATA_ENTRIES_FOR_TESTING = {numDataEntries};
203204
cfg.LOADGEN_NUM_DATA_ENTRIES_DISTRIBUTION_FOR_TESTING = {1};
204205
cfg.LOADGEN_IO_KILOBYTES_FOR_TESTING = {ioKiloBytes};
@@ -220,6 +221,20 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]")
220221
auto nodes = simulation->getNodes();
221222

222223
auto& app = *nodes[0]; // pick a node to generate load
224+
Upgrades::UpgradeParameters scheduledUpgrades;
225+
auto lclCloseTime =
226+
VirtualClock::from_time_t(app.getLedgerManager()
227+
.getLastClosedLedgerHeader()
228+
.header.scpValue.closeTime);
229+
scheduledUpgrades.mUpgradeTime = lclCloseTime;
230+
scheduledUpgrades.mProtocolVersion =
231+
Config::CURRENT_LEDGER_PROTOCOL_VERSION;
232+
for (auto const& node : nodes)
233+
{
234+
node->getHerder().setUpgrades(scheduledUpgrades);
235+
}
236+
simulation->crankForAtLeast(std::chrono::seconds(20), false);
237+
223238
auto& loadGen = app.getLoadGenerator();
224239
auto getSuccessfulTxCount = [&]() {
225240
return nodes[0]

0 commit comments

Comments
 (0)