Skip to content

Commit

Permalink
Add documentation for updateRecalibratedCostTypesForV20
Browse files Browse the repository at this point in the history
  • Loading branch information
dmkozh committed Nov 5, 2024
1 parent 9359ad3 commit dc19ff2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/ledger/NetworkConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,9 @@ SorobanNetworkConfig::initializeGenesisLedgerForTesting(
ltx.loadHeader().current().ledgerVersion =
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION);
SorobanNetworkConfig::createLedgerEntriesForV20(ltx, app);
// Protocol 20 released with somewhat incorrect costs and has been
// re-calibrated short after the release. We catch up here to the more
// correct costs that exist on the network.
updateRecalibratedCostTypesForV20(ltx);
ltx.loadHeader().current().ledgerVersion = genesisLedgerProtocol;
}
Expand Down
9 changes: 8 additions & 1 deletion src/ledger/NetworkConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,14 @@ class SorobanNetworkConfig
#ifdef BUILD_TESTS
StateArchivalSettings& stateArchivalSettings();
EvictionIterator& evictionIterator();

// Update the protocol 20 cost types to match the real network
// configuration.
// Protocol 20 cost types were imprecise and were re-calibrated shortly
// after the release. This should be called when initializing the test with
// protocol 20+.
// Future recalibrations should be accounted for in a similar way in order
// to have more accurage modelled CPU and memory costs in tests and
// especially the benchmarks.
static void updateRecalibratedCostTypesForV20(AbstractLedgerTxn& ltx);
#endif
bool operator==(SorobanNetworkConfig const& other) const;
Expand Down

0 comments on commit dc19ff2

Please sign in to comment.