Skip to content

Commit

Permalink
Add TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Aug 29, 2023
1 parent a4d6230 commit 245d0ef
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 18 deletions.
91 changes: 73 additions & 18 deletions src/ledger/NetworkConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,53 @@ createConfigSettingEntry(ConfigSettingEntry const& configSetting,
}

ConfigSettingEntry
initialMaxContractSizeEntry()
initialMaxContractSizeEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES);

entry.contractMaxSizeBytes() =
InitialSorobanNetworkConfig::MAX_CONTRACT_SIZE;

if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
entry.contractMaxSizeBytes() *= 32;
}

return entry;
}

ConfigSettingEntry
initialMaxContractDataKeySizeEntry()
initialMaxContractDataKeySizeEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES);

entry.contractDataKeySizeBytes() =
InitialSorobanNetworkConfig::MAX_CONTRACT_DATA_KEY_SIZE_BYTES;
if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
entry.contractDataKeySizeBytes() *= 10;
}

return entry;
}

ConfigSettingEntry
initialMaxContractDataEntrySizeEntry()
initialMaxContractDataEntrySizeEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES);

entry.contractDataEntrySizeBytes() =
InitialSorobanNetworkConfig::MAX_CONTRACT_DATA_ENTRY_SIZE_BYTES;
if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
entry.contractDataEntrySizeBytes() *= 10;
}

return entry;
}

ConfigSettingEntry
initialContractComputeSettingsEntry()
initialContractComputeSettingsEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_COMPUTE_V0);
auto& e = entry.contractCompute();
Expand All @@ -77,11 +90,18 @@ initialContractComputeSettingsEntry()
InitialSorobanNetworkConfig::FEE_RATE_PER_INSTRUCTIONS_INCREMENT;
e.txMemoryLimit = InitialSorobanNetworkConfig::MEMORY_LIMIT;

if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
e.ledgerMaxInstructions *= 50;
e.txMaxInstructions *= 50;
e.txMemoryLimit *= 10;
}

return entry;
}

ConfigSettingEntry
initialContractLedgerAccessSettingsEntry()
initialContractLedgerAccessSettingsEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_LEDGER_COST_V0);
auto& e = entry.contractLedgerCost();
Expand Down Expand Up @@ -114,6 +134,18 @@ initialContractLedgerAccessSettingsEntry()
e.bucketListWriteFeeGrowthFactor =
InitialSorobanNetworkConfig::BUCKET_LIST_WRITE_FEE_GROWTH_FACTOR;

if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
e.ledgerMaxReadLedgerEntries *= 10;
e.ledgerMaxReadBytes *= 10;
e.ledgerMaxWriteLedgerEntries *= 10;
e.ledgerMaxWriteBytes *= 10;
e.txMaxReadLedgerEntries *= 10;
e.txMaxReadBytes *= 10;
e.txMaxWriteLedgerEntries *= 10;
e.txMaxWriteBytes *= 10;
}

return entry;
}

Expand All @@ -129,7 +161,7 @@ initialContractHistoricalDataSettingsEntry()
}

ConfigSettingEntry
initialContractEventsSettingsEntry()
initialContractEventsSettingsEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_EVENTS_V0);
auto& e = entry.contractEvents();
Expand All @@ -139,11 +171,15 @@ initialContractEventsSettingsEntry()
e.feeContractEvents1KB =
InitialSorobanNetworkConfig::FEE_CONTRACT_EVENTS_SIZE_1KB;

if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
e.txMaxContractEventsSizeBytes *= 20;
}
return entry;
}

ConfigSettingEntry
initialContractBandwidthSettingsEntry()
initialContractBandwidthSettingsEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_BANDWIDTH_V0);
auto& e = entry.contractBandwidth();
Expand All @@ -154,15 +190,27 @@ initialContractBandwidthSettingsEntry()

e.feeTxSize1KB = InitialSorobanNetworkConfig::FEE_TRANSACTION_SIZE_1KB;

if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
e.ledgerMaxTxsSizeBytes *= 5;
e.txMaxSizeBytes *= 5;
}

return entry;
}

ConfigSettingEntry
initialContractExecutionLanesSettingsEntry()
initialContractExecutionLanesSettingsEntry(Config const& cfg)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_EXECUTION_LANES);
auto& e = entry.contractExecutionLanes();
e.ledgerMaxTxCount = InitialSorobanNetworkConfig::LEDGER_MAX_TX_COUNT;

if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
e.ledgerMaxTxCount *= 5;
}

return entry;
}

Expand Down Expand Up @@ -309,6 +357,11 @@ initialStateExpirationSettings(Config const& cfg)
InitialSorobanNetworkConfig::PERSISTENT_RENT_RATE_DENOMINATOR;
entry.stateExpirationSettings().tempRentRateDenominator =
InitialSorobanNetworkConfig::TEMP_RENT_RATE_DENOMINATOR;

if (cfg.TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE)
{
entry.stateExpirationSettings().maxEntryExpiration = 6307200; // 1 year
}
return entry;
}

Expand Down Expand Up @@ -590,19 +643,21 @@ SorobanNetworkConfig::createLedgerEntriesForV20(AbstractLedgerTxn& ltx,
Application& app)
{
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
createConfigSettingEntry(initialMaxContractSizeEntry(), ltx);
createConfigSettingEntry(initialMaxContractDataKeySizeEntry(), ltx);
createConfigSettingEntry(initialMaxContractDataEntrySizeEntry(), ltx);
createConfigSettingEntry(initialContractComputeSettingsEntry(), ltx);
createConfigSettingEntry(initialContractLedgerAccessSettingsEntry(), ltx);
auto const& cfg = app.getConfig();
createConfigSettingEntry(initialMaxContractSizeEntry(cfg), ltx);
createConfigSettingEntry(initialMaxContractDataKeySizeEntry(cfg), ltx);
createConfigSettingEntry(initialMaxContractDataEntrySizeEntry(cfg), ltx);
createConfigSettingEntry(initialContractComputeSettingsEntry(cfg), ltx);
createConfigSettingEntry(initialContractLedgerAccessSettingsEntry(cfg),
ltx);
createConfigSettingEntry(initialContractHistoricalDataSettingsEntry(), ltx);
createConfigSettingEntry(initialContractEventsSettingsEntry(), ltx);
createConfigSettingEntry(initialContractBandwidthSettingsEntry(), ltx);
createConfigSettingEntry(initialContractExecutionLanesSettingsEntry(), ltx);
createConfigSettingEntry(initialContractEventsSettingsEntry(cfg), ltx);
createConfigSettingEntry(initialContractBandwidthSettingsEntry(cfg), ltx);
createConfigSettingEntry(initialContractExecutionLanesSettingsEntry(cfg),
ltx);
createConfigSettingEntry(initialCpuCostParamsEntry(), ltx);
createConfigSettingEntry(initialMemCostParamsEntry(), ltx);
createConfigSettingEntry(initialStateExpirationSettings(app.getConfig()),
ltx);
createConfigSettingEntry(initialStateExpirationSettings(cfg), ltx);
createConfigSettingEntry(initialBucketListSizeWindow(app), ltx);
createConfigSettingEntry(initialEvictionIterator(), ltx);
#endif
Expand Down
8 changes: 8 additions & 0 deletions src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ Config::Config() : NODE_SEED(SecretKey::random())
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
ENABLE_SOROBAN_DIAGNOSTIC_EVENTS = false;
TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME = 0;
TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE = false;
#endif

#ifdef BUILD_TESTS
Expand Down Expand Up @@ -1473,6 +1474,13 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
"Overriding MINIMUM_PERSISTENT_ENTRY_LIFETIME to {}",
TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME);
}
else if (item.first == "TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE")
{
TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE = readBool(item);

LOG_WARNING(DEFAULT_LOG, "Overriding Soroban limits with "
"TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE");
}
#endif
else if (item.first == "ARTIFICIALLY_SLEEP_MAIN_THREAD_FOR_TESTING")
{
Expand Down
3 changes: 3 additions & 0 deletions src/main/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ class Config : public std::enable_shared_from_this<Config>
// Override the initial hardcoded MINIMUM_PERSISTENT_ENTRY_LIFETIME
// for testing.
uint32_t TESTING_MINIMUM_PERSISTENT_ENTRY_LIFETIME;

//TODO: add comment
bool TESTING_SOROBAN_HIGH_LIMIT_OVERRIDE;
#endif

#ifdef BUILD_TESTS
Expand Down

0 comments on commit 245d0ef

Please sign in to comment.