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

Update soroban settings files and utils #4197

Merged
merged 5 commits into from
Feb 16, 2024
Merged
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
2 changes: 1 addition & 1 deletion docs/software/soroban-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ how the settings upgrade mechanism works internally. **If you are just being ask
to vote for an upgrade, please move on to the [Examine a proposed upgrade](#examine-a-proposed-upgrade) step for details on how to examine a
proposed upgrade.**

1. Using the stellar-xdr rust tool and a JSON file as input, run `stellar-xdr encode --type ConfigUpgradeSet JSON_FILE`. [phase1.json](../../soroban-settings/phase1.json) can be used as a template to propose upgrades.
1. Using the stellar-xdr rust tool and a JSON file as input, run `stellar-xdr encode --type ConfigUpgradeSet JSON_FILE`. [pubnet_phase1.json](../../soroban-settings/pubnet_phase1.json) can be used as a template to propose upgrades.
- Example output - `AAAAAQAAAAsAAAAM` (note that this string can be much larger depending on the settings you're upgrading)
- stellar-xdr can be installed with brew (`brew install stellar/tap/stellar-xdr`) or cargo (``cargo install --locked stellar-xdr --features cli``). You can also download the binary for your system here https://github.com/stellar/rs-stellar-xdr/releases/latest.

Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we also update the target BL size for pubnet (to 13000000000)? We'll need to double-check it, but it seems unlikely that BL size would change significantly before phase 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah good catch. Fixed

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"fee_read_ledger_entry": 6250,
"fee_write_ledger_entry": 10000,
"fee_read1_kb": 1786,
"bucket_list_target_size_bytes": 13958643712,
"bucket_list_target_size_bytes": 13000000000,
"write_fee1_kb_bucket_list_low": -1234673,
"write_fee1_kb_bucket_list_high": 115390,
"bucket_list_write_fee_growth_factor": 1000
Expand Down
315 changes: 315 additions & 0 deletions soroban-settings/testnet_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
{
"updated_entry": [
{
"contract_max_size_bytes": 65536
},
{
"contract_compute_v0": {
"ledger_max_instructions": 100000000,
"tx_max_instructions": 100000000,
"fee_rate_per_instructions_increment": 25,
"tx_memory_limit": 41943040
}
},
{
"contract_ledger_cost_v0": {
"ledger_max_read_ledger_entries": 40,
"ledger_max_read_bytes": 133120,
"ledger_max_write_ledger_entries": 25,
"ledger_max_write_bytes": 66560,
"tx_max_read_ledger_entries": 40,
"tx_max_read_bytes": 133120,
"tx_max_write_ledger_entries": 25,
"tx_max_write_bytes": 66560,
"fee_read_ledger_entry": 6250,
"fee_write_ledger_entry": 10000,
"fee_read1_kb": 1786,
"bucket_list_target_size_bytes": 200000000,
"write_fee1_kb_bucket_list_low": -12034,
"write_fee1_kb_bucket_list_high": 115390,
"bucket_list_write_fee_growth_factor": 1000
}
},
{
"contract_historical_data_v0": {
"fee_historical1_kb": 16235
}
},
{
"contract_events_v0": {
"tx_max_contract_events_size_bytes": 8198,
"fee_contract_events1_kb": 10000
}
},
{
"contract_bandwidth_v0": {
"ledger_max_txs_size_bytes": 71680,
"tx_max_size_bytes": 71680,
"fee_tx_size1_kb": 1624
}
},
{
"contract_cost_params_cpu_instructions": [
{
"ext": "v0",
"const_term": 4,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 434,
"linear_term": 16
},
{
"ext": "v0",
"const_term": 42,
"linear_term": 16
},
{
"ext": "v0",
"const_term": 44,
"linear_term": 16
},
{
"ext": "v0",
"const_term": 295,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 60,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 221,
"linear_term": 26
},
{
"ext": "v0",
"const_term": 331,
"linear_term": 4369
},
{
"ext": "v0",
"const_term": 3636,
"linear_term": 7013
},
{
"ext": "v0",
"const_term": 40256,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 377551,
"linear_term": 4059
},
{
"ext": "v0",
"const_term": 417482,
"linear_term": 45712
},
{
"ext": "v0",
"const_term": 417482,
"linear_term": 45712
},
{
"ext": "v0",
"const_term": 1945,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 6481,
"linear_term": 5943
},
{
"ext": "v0",
"const_term": 711,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 2314804,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 4176,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 4716,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 4680,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 4256,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 884,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 1059,
"linear_term": 502
}
]
},
{
"contract_cost_params_memory_bytes": [
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 16,
"linear_term": 128
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 242,
"linear_term": 384
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 384
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 132773,
"linear_term": 4903
},
{
"ext": "v0",
"const_term": 132773,
"linear_term": 4903
},
{
"ext": "v0",
"const_term": 14,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 181,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 99,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 99,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 99,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 99,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 99,
"linear_term": 0
},
{
"ext": "v0",
"const_term": 0,
"linear_term": 0
}
]
},
{
"contract_data_key_size_bytes": 300
},
{
"contract_data_entry_size_bytes": 65536
},
{
"state_archival": {
"max_entry_ttl": 3110400,
"min_temporary_ttl": 17280,
"min_persistent_ttl": 2073600,
"persistent_rent_rate_denominator": 535680,
"temp_rent_rate_denominator": 5356800,
"max_entries_to_archive": 100,
"bucket_list_size_window_sample_size": 30,
"bucket_list_window_sample_period": 64,
"eviction_scan_size": 100000,
"starting_eviction_scan_level": 7
}
},
{
"contract_execution_lanes": {
"ledger_max_tx_count": 100
}
}
]
}
13 changes: 2 additions & 11 deletions src/main/SettingsUpgradeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,12 @@ getCreateTx(PublicKey const& publicKey, LedgerKey const& contractCodeLedgerKey,
void
validateConfigUpgradeSet(ConfigUpgradeSet const& upgradeSet)
{
// As of 12/22/2023, this is roughly the size of the buckets. This is used
// in a safety check to prevent us from accidentally reducing the target
// size to a point where upgrade becomes prohibitively expensive. We also
// make sure the growth factor has an upper bound here. This file is just
// used by our command line tooling, so we can update this value whenever we
// want.
static const uint64_t CURRENT_LEDGER_SIZE = 12'500'000'000;
for (auto const& entry : upgradeSet.updatedEntry)
{
if (entry.configSettingID() == CONFIG_SETTING_CONTRACT_LEDGER_COST_V0)
{
if (entry.contractLedgerCost().bucketListTargetSizeBytes <
CURRENT_LEDGER_SIZE * .95 ||
entry.contractLedgerCost().bucketListWriteFeeGrowthFactor >
50'000)
if (entry.contractLedgerCost().bucketListWriteFeeGrowthFactor >
50'000)
{
throw std::runtime_error("Invalid contractLedgerCost");
}
Expand Down
15 changes: 2 additions & 13 deletions src/transactions/test/InvokeHostFunctionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,8 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]")

// We're writing the latest cpu and mem settings below to makes sure
// they don't brick the settings upgrade process. We would ideally pull
// this from phase1.json, but core doesn't know how to parse JSON XDR.
// this from pubnet_phase1.json, but core doesn't know how to parse JSON
// XDR.
auto const& vals = xdr::xdr_traits<ContractCostType>::enum_values();
if (entry.current().data.configSetting().configSettingID() ==
CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS)
Expand Down Expand Up @@ -3139,18 +3140,6 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]")
CONFIG_SETTING_CONTRACT_LEDGER_COST_V0;
});

SECTION("Invalid bucketListTargetSizeBytes")
{
// 10GB is too low due to the check in validateConfigUpgradeSet
costEntryIter->contractLedgerCost().bucketListTargetSizeBytes =
10'000'000'000;
REQUIRE_THROWS_AS(
getInvokeTx(a1.getPublicKey(), contractCodeLedgerKey,
contractSourceRefLedgerKey, contractID, upgradeSet,
a1.getLastSequenceNumber() + 3),
std::runtime_error);
}

SECTION("Invalid bucketListWriteFeeGrowthFactor")
{
// Value is too high due to the check in validateConfigUpgradeSet
Expand Down
1 change: 0 additions & 1 deletion test-tx-meta-baseline-current/InvokeHostFunctionTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,6 @@
"TByXElZpITE=",
"TByXElZpITE=",
"TByXElZpITE=",
"TByXElZpITE=",
"TByXElZpITE="
],
"state archival" :
Expand Down
Loading
Loading