Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sorobaninfo basic more consistent with underlying network settings #4216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 20 additions & 105 deletions src/main/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,124 +752,39 @@ CommandHandler::sorobanInfo(std::string const& params, std::string& retStr)
return;
}

std::set<uint32_t> excluded;
auto format =
parseOptionalParamOrDefault<std::string>(retMap, "format", "basic");
if (format == "basic")
{
Json::Value res;
auto const& conf = lm.getSorobanNetworkConfig();

// Contract size
res["max_contract_size"] = conf.maxContractSizeBytes();

// Contract data
res["max_contract_data_key_size"] =
conf.maxContractDataKeySizeBytes();
res["max_contract_data_entry_size"] =
conf.maxContractDataEntrySizeBytes();

// Compute settings
res["tx"]["max_instructions"] =
static_cast<Json::Int64>(conf.txMaxInstructions());
res["ledger"]["max_instructions"] =
static_cast<Json::Int64>(conf.ledgerMaxInstructions());
res["fee_rate_per_instructions_increment"] =
static_cast<Json::Int64>(
conf.feeRatePerInstructionsIncrement());
res["tx"]["memory_limit"] = conf.txMemoryLimit();

// Ledger access settings
res["ledger"]["max_read_ledger_entries"] =
conf.ledgerMaxReadLedgerEntries();
res["ledger"]["max_read_bytes"] = conf.ledgerMaxReadBytes();
res["ledger"]["max_write_ledger_entries"] =
conf.ledgerMaxWriteLedgerEntries();
res["ledger"]["max_write_bytes"] = conf.ledgerMaxWriteBytes();
res["tx"]["max_read_ledger_entries"] =
conf.txMaxReadLedgerEntries();
res["tx"]["max_read_bytes"] = conf.txMaxReadBytes();
res["tx"]["max_write_ledger_entries"] =
conf.txMaxWriteLedgerEntries();
res["tx"]["max_write_bytes"] = conf.txMaxWriteBytes();

// Fees
res["fee_read_ledger_entry"] =
static_cast<Json::Int64>(conf.feeReadLedgerEntry());
res["fee_write_ledger_entry"] =
static_cast<Json::Int64>(conf.feeWriteLedgerEntry());
res["fee_read_1kb"] = static_cast<Json::Int64>(conf.feeRead1KB());
res["fee_write_1kb"] = static_cast<Json::Int64>(conf.feeWrite1KB());
res["fee_historical_1kb"] =
static_cast<Json::Int64>(conf.feeHistorical1KB());

// Contract events settings
res["tx"]["max_contract_events_size_bytes"] =
conf.txMaxContractEventsSizeBytes();
res["fee_contract_events_size_1kb"] =
static_cast<Json::Int64>(conf.feeContractEventsSize1KB());

// Bandwidth related data settings
res["ledger"]["max_tx_size_bytes"] =
conf.ledgerMaxTransactionSizesBytes();
res["tx"]["max_size_bytes"] = conf.txMaxSizeBytes();
res["fee_transaction_size_1kb"] =
static_cast<Json::Int64>(conf.feeTransactionSize1KB());

// General execution ledger settings
res["ledger"]["max_tx_count"] = conf.ledgerMaxTxCount();

// State archival settings
auto& archivalInfo = res["state_archival"];
auto const& stateArchivalSettings = conf.stateArchivalSettings();
archivalInfo["max_entry_ttl"] = stateArchivalSettings.maxEntryTTL;
archivalInfo["min_temporary_ttl"] =
stateArchivalSettings.minTemporaryTTL;
archivalInfo["min_persistent_ttl"] =
stateArchivalSettings.minPersistentTTL;

archivalInfo["persistent_rent_rate_denominator"] =
static_cast<Json::Int64>(
stateArchivalSettings.persistentRentRateDenominator);
archivalInfo["temp_rent_rate_denominator"] =
static_cast<Json::Int64>(
stateArchivalSettings.tempRentRateDenominator);

archivalInfo["max_entries_to_archive"] =
stateArchivalSettings.maxEntriesToArchive;
archivalInfo["bucketlist_size_window_sample_size"] =
stateArchivalSettings.bucketListSizeWindowSampleSize;

archivalInfo["eviction_scan_size"] = static_cast<Json::UInt64>(
stateArchivalSettings.evictionScanSize);
archivalInfo["starting_eviction_scan_level"] =
stateArchivalSettings.startingEvictionScanLevel;
archivalInfo["bucket_list_size_snapshot_period"] =
stateArchivalSettings.bucketListSizeWindowSampleSize;

// non-configurable settings
archivalInfo["average_bucket_list_size"] =
static_cast<Json::UInt64>(conf.getAverageBucketListSize());
retStr = res.toStyledString();
excluded.insert(
{CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS,
CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES,
CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW,
CONFIG_SETTING_EVICTION_ITERATOR});
}
else if (format == "detailed")
{
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
xdr::xvector<ConfigSettingEntry> entries;
for (auto c : xdr::xdr_traits<ConfigSettingID>::enum_values())
}
else
{
retStr = "Invalid format option";
return;
}
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
xdr::xvector<ConfigSettingEntry> entries;
for (auto c : xdr::xdr_traits<ConfigSettingID>::enum_values())
{
if (excluded.find(c) == excluded.end())
{
auto entry =
ltx.load(configSettingKey(static_cast<ConfigSettingID>(c)));
entries.emplace_back(entry.current().data.configSetting());
}

retStr = xdr_to_string(entries, "ConfigSettingsEntries");
}
else
{
retStr = "Invalid format option";
}
retStr = xdr_to_string(entries, "ConfigSettingsEntries");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ runCheckQuorumIntersection(CommandLineArgs const& args)
return 1;
}
}
catch (KeyUtils::InvalidStrKey const& e)
catch (KeyUtils::InvalidStrKey const&)
{
CLOG_FATAL(
SCP,
Expand Down
Loading