Skip to content

Commit 28142cd

Browse files
Refresh mainnet() resource limits and fees (#1946)
### What Refresh the `InvocationResourceLimits::mainnet()` limits and the fee-rate snapshot used by `CostEstimate::fee()` to the Stellar Mainnet settings as of 2026-07-10, and update their rustdocs (including the duplicated limits table in the v25 resource-limits migration guide) to point readers to `stellar network settings --network mainnet` and Stellar Lab as the live source of truth. ### Why `InvocationResourceLimits::mainnet()` has been enforced by `Env::default()` on every test invocation since v25 but still carried the values from when resource-limit enforcement was first introduced, which had drifted from Mainnet in both directions: the instruction ceiling was too high (600,000,000 vs 400,000,000), letting a contract pass tests yet exceed Mainnet's per-transaction limit in production and defeating the early-warning purpose of the enforcement, while the entry ceilings were too low (disk read entries 100 vs 200, write entries 50 vs 200, ledger entries 100 vs 400). ### Known limitations The values remain a hardcoded snapshot rather than being pulled dynamically, so they will drift again. On the one hand this is bad, but also, if they kept moving tests could become flakey, so timing this update with new major releases on some cadence is probably a good idea. Follow up to introduce CI to help us keep it updated: - #1948
1 parent 88a8d51 commit 28142cd

2 files changed

Lines changed: 45 additions & 37 deletions

File tree

soroban-sdk/src/tests/cost_estimate.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ fn test_cost_estimate_with_storage() {
3737
.assert_eq(format!("{:#?}", e.cost_estimate().resources()).as_str());
3838
expect![[r#"
3939
FeeEstimate {
40-
total: 29122,
41-
instructions: 607,
42-
disk_read_entries: 6250,
43-
write_entries: 10000,
40+
total: 10004,
41+
instructions: 170,
42+
disk_read_entries: 1563,
43+
write_entries: 2500,
4444
disk_read_bytes: 0,
45-
write_bytes: 274,
45+
write_bytes: 69,
4646
contract_events: 0,
47-
persistent_entry_rent: 11991,
47+
persistent_entry_rent: 5702,
4848
temporary_entry_rent: 0,
4949
}"#]]
5050
.assert_eq(format!("{:#?}", e.cost_estimate().fee()).as_str());
@@ -70,8 +70,8 @@ fn test_cost_estimate_with_storage() {
7070
.assert_eq(format!("{:#?}", e.cost_estimate().resources()).as_str());
7171
expect![[r#"
7272
FeeEstimate {
73-
total: 603,
74-
instructions: 603,
73+
total: 169,
74+
instructions: 169,
7575
disk_read_entries: 0,
7676
write_entries: 0,
7777
disk_read_bytes: 0,
@@ -103,10 +103,10 @@ fn test_cost_estimate_with_storage() {
103103
.assert_eq(format!("{:#?}", e.cost_estimate().resources()).as_str());
104104
expect![[r#"
105105
FeeEstimate {
106-
total: 16847,
107-
instructions: 597,
108-
disk_read_entries: 6250,
109-
write_entries: 10000,
106+
total: 4231,
107+
instructions: 168,
108+
disk_read_entries: 1563,
109+
write_entries: 2500,
110110
disk_read_bytes: 0,
111111
write_bytes: 0,
112112
contract_events: 0,
@@ -136,8 +136,8 @@ fn test_cost_estimate_with_storage() {
136136
.assert_eq(format!("{:#?}", e.cost_estimate().resources()).as_str());
137137
expect![[r#"
138138
FeeEstimate {
139-
total: 598,
140-
instructions: 598,
139+
total: 168,
140+
instructions: 168,
141141
disk_read_entries: 0,
142142
write_entries: 0,
143143
disk_read_bytes: 0,

soroban-sdk/src/testutils/cost_estimate.rs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,38 @@ impl CostEstimate {
3636
/// Estimates the fee for the last invocation's resources, i.e. the
3737
/// resources returned by `resources()`.
3838
///
39-
/// The fees are computed using the snapshot of the Stellar Pubnet fees made
40-
/// on 2024-12-11.
39+
/// The fees are computed using a snapshot of the Stellar Mainnet fees made
40+
/// on 2026-07-10. Because the fees are hardcoded rather than pulled
41+
/// dynamically, they may drift from the live network over time; the current
42+
/// values can be checked via `stellar network settings --network mainnet`
43+
/// or on Stellar Lab: <https://lab.stellar.org/network-limits>. The one
44+
/// exception is the per-1KB storage rent rate, which is a deliberate
45+
/// conservative overestimate rather than the snapshot value, so storage
46+
/// rent estimates may be higher than the live network charges.
4147
///
4248
/// Take the return value with a grain of salt as both the resource estimate
4349
/// and the fee rates may be imprecise.
4450
///
4551
/// The returned value is as useful as the preceding setup, e.g. if a test
4652
/// contract is used instead of a Wasm contract, all the costs related to
4753
/// VM instantiation and execution, as well as Wasm reads/rent bumps will be
48-
/// missed.
54+
/// missed.
4955
pub fn fee(&self) -> FeeEstimate {
50-
// This is a snapshot of the fees as of 2024-12-11 with slight
51-
// adjustments for p23.
52-
// This has to be updated before p23 goes live with the configuration
53-
// used at the network upgrade time.
56+
// This is a snapshot of the Stellar Mainnet fees as of 2026-07-10.
57+
// Refresh it with the values from `stellar network settings --network
58+
// mainnet` (or <https://lab.stellar.org/network-limits>) when it drifts.
5459
let pubnet_fee_config = FeeConfiguration {
55-
fee_per_instruction_increment: 25,
56-
fee_per_disk_read_entry: 6250,
57-
fee_per_write_entry: 10000,
58-
fee_per_disk_read_1kb: 1786,
59-
fee_per_write_1kb: 3500,
60-
fee_per_historical_1kb: 16235,
61-
fee_per_contract_event_1kb: 10000,
62-
fee_per_transaction_size_1kb: 1624,
60+
fee_per_instruction_increment: 7,
61+
fee_per_disk_read_entry: 1563,
62+
fee_per_write_entry: 2500,
63+
fee_per_disk_read_1kb: 447,
64+
fee_per_write_1kb: 875,
65+
fee_per_historical_1kb: 4059,
66+
fee_per_contract_event_1kb: 5000,
67+
fee_per_transaction_size_1kb: 406,
6368
};
64-
let pubnet_persistent_rent_rate_denominator = 2103;
65-
let pubnet_temp_rent_rate_denominator = 4206;
69+
let pubnet_persistent_rent_rate_denominator = 1215;
70+
let pubnet_temp_rent_rate_denominator = 2430;
6671
// This is a bit higher than the current network fee, it's an
6772
// overestimate for the sake of providing a bit more conservative
6873
// results in case if the state grows.
@@ -133,15 +138,18 @@ pub trait NetworkInvocationResourceLimits {
133138
impl NetworkInvocationResourceLimits for InvocationResourceLimits {
134139
/// Returns the invocation resource limits used on Stellar Mainnet.
135140
///
136-
/// This is not pulling the values dynamically, so updating the SDK is
137-
/// necessary to pick up the most recent values.
141+
/// These values are a snapshot of the Mainnet network settings as of
142+
/// 2026-07-10; they are hardcoded rather than pulled dynamically, so
143+
/// updating the SDK is necessary to pick up the most recent values. The
144+
/// current values can be checked via `stellar network settings --network
145+
/// mainnet` or on Stellar Lab: <https://lab.stellar.org/network-limits>.
138146
fn mainnet() -> Self {
139147
InvocationResourceLimits {
140-
instructions: 600_000_000,
148+
instructions: 400_000_000,
141149
mem_bytes: 41943040,
142-
disk_read_entries: 100,
143-
write_entries: 50,
144-
ledger_entries: 100,
150+
disk_read_entries: 200,
151+
write_entries: 200,
152+
ledger_entries: 400,
145153
disk_read_bytes: 200000,
146154
write_bytes: 132096,
147155
contract_events_size_bytes: 16384,

0 commit comments

Comments
 (0)