diff --git a/core/parameters/res/runtime_configs/72.yaml b/core/parameters/res/runtime_configs/72.yaml index faac9c28577..0ea523b8c76 100644 --- a/core/parameters/res/runtime_configs/72.yaml +++ b/core/parameters/res/runtime_configs/72.yaml @@ -1 +1,14 @@ -main_storage_proof_size_soft_limit: {old: 3_000_000, new: 4_000_000} \ No newline at end of file +main_storage_proof_size_soft_limit: {old: 3_000_000, new: 4_000_000} +# See https://github.com/near/nearcore/pull/12044 for why the values are set to these values. +# In addition, `gas` is set to 1 for the large read variants, because we need that in actual code. +# For this to be transparent for smart contracts, the `read_base` and `read_value_byte` values were +# also reduced by 1. This means that at best contracts now pay 1 fewer gas, and at worst the same +# value. +wasm_storage_has_key_base: { old: { gas: 54_039_896_625, compute: 200_000_000_000 }, new: { gas: 54_039_896_625, compute: 158_000_000_000 } } +wasm_storage_has_key_byte: { old: 30_790_845, new: { gas: 30_790_845, compute: 10_000_000 } } +wasm_storage_read_base: { old: { gas: 56_356_845_750, compute: 200_000_000_000 }, new: { gas: 56_356_845_749, compute: 159_000_000_000 } } +wasm_storage_read_key_byte: { old: 30_952_533, new: { gas: 30_952_533, compute: 10_000_000 } } +wasm_storage_read_value_byte: { old: 5_611_005, new: { gas: 5_611_004, compute: 2_500_000 } } +wasm_storage_large_read_overhead_base: { old: 0, new: { gas: 1, compute: 41_000_000_000 } } +wasm_storage_large_read_overhead_byte: { old: 0, new: { gas: 1, compute: 3_111_005 } } +wasm_touching_trie_node: { old: { gas: 16_101_955_926, compute: 110_000_000_000 }, new: { gas: 16_101_955_926, compute: 20_000_000_000 } } diff --git a/core/parameters/res/runtime_configs/parameters.snap b/core/parameters/res/runtime_configs/parameters.snap index 719340de34a..cae30235227 100644 --- a/core/parameters/res/runtime_configs/parameters.snap +++ b/core/parameters/res/runtime_configs/parameters.snap @@ -113,14 +113,16 @@ wasm_storage_write_base 64_196_736_000, compute: 200_ wasm_storage_write_key_byte 70_482_867 wasm_storage_write_value_byte 31_018_539 wasm_storage_write_evicted_byte 32_117_307 -wasm_storage_read_base 56_356_845_750, compute: 200_000_000_000 -wasm_storage_read_key_byte 30_952_533 -wasm_storage_read_value_byte 5_611_005 +wasm_storage_read_base 56_356_845_749, compute: 159_000_000_000 +wasm_storage_read_key_byte 30_952_533, compute: 10_000_000 +wasm_storage_read_value_byte 5_611_004, compute: 2_500_000 +wasm_storage_large_read_overhead_base 1, compute: 41_000_000_000 +wasm_storage_large_read_overhead_byte 1, compute: 3_111_005 wasm_storage_remove_base 53_473_030_500, compute: 200_000_000_000 wasm_storage_remove_key_byte 38_220_384 wasm_storage_remove_ret_value_byte 11_531_556 -wasm_storage_has_key_base 54_039_896_625, compute: 200_000_000_000 -wasm_storage_has_key_byte 30_790_845 +wasm_storage_has_key_base 54_039_896_625, compute: 158_000_000_000 +wasm_storage_has_key_byte 30_790_845, compute: 10_000_000 wasm_storage_iter_create_prefix_base 0 wasm_storage_iter_create_prefix_byte 0 wasm_storage_iter_create_range_base 0 @@ -129,7 +131,7 @@ wasm_storage_iter_create_to_byte 0 wasm_storage_iter_next_base 0 wasm_storage_iter_next_key_byte 0 wasm_storage_iter_next_value_byte 0 -wasm_touching_trie_node 16_101_955_926, compute: 110_000_000_000 +wasm_touching_trie_node 16_101_955_926, compute: 20_000_000_000 wasm_read_cached_trie_node 2_280_000_000 wasm_promise_and_base 1_465_013_400 wasm_promise_and_per_promise 5_452_176 diff --git a/core/parameters/res/runtime_configs/parameters.yaml b/core/parameters/res/runtime_configs/parameters.yaml index 0f005066eaf..cfe8a82291f 100644 --- a/core/parameters/res/runtime_configs/parameters.yaml +++ b/core/parameters/res/runtime_configs/parameters.yaml @@ -152,6 +152,8 @@ wasm_storage_write_evicted_byte: 32_117_307 wasm_storage_read_base: 56_356_845_750 wasm_storage_read_key_byte: 30_952_533 wasm_storage_read_value_byte: 5_611_005 +wasm_storage_large_read_overhead_base: 0 +wasm_storage_large_read_overhead_byte: 0 wasm_storage_remove_base: 53_473_030_500 wasm_storage_remove_key_byte: 38_220_384 wasm_storage_remove_ret_value_byte: 11_531_556 diff --git a/core/parameters/res/runtime_configs/parameters_testnet.yaml b/core/parameters/res/runtime_configs/parameters_testnet.yaml index 7ff426ac24d..0ab1a84e51b 100644 --- a/core/parameters/res/runtime_configs/parameters_testnet.yaml +++ b/core/parameters/res/runtime_configs/parameters_testnet.yaml @@ -149,6 +149,8 @@ wasm_storage_write_evicted_byte: 32_117_307 wasm_storage_read_base: 56_356_845_750 wasm_storage_read_key_byte: 30_952_533 wasm_storage_read_value_byte: 5_611_005 +wasm_storage_large_read_overhead_base: 0 +wasm_storage_large_read_overhead_byte: 0 wasm_storage_remove_base: 53_473_030_500 wasm_storage_remove_key_byte: 38_220_384 wasm_storage_remove_ret_value_byte: 11_531_556 diff --git a/core/parameters/src/cost.rs b/core/parameters/src/cost.rs index d978b8aa239..4067fc4487d 100644 --- a/core/parameters/src/cost.rs +++ b/core/parameters/src/cost.rs @@ -103,6 +103,8 @@ impl ExtCostsConfig { ExtCosts::storage_read_base => SAFETY_MULTIPLIER * 18785615250, ExtCosts::storage_read_key_byte => SAFETY_MULTIPLIER * 10317511, ExtCosts::storage_read_value_byte => SAFETY_MULTIPLIER * 1870335, + ExtCosts::storage_large_read_overhead_base => 0, + ExtCosts::storage_large_read_overhead_byte => 0, ExtCosts::storage_remove_base => SAFETY_MULTIPLIER * 17824343500, ExtCosts::storage_remove_key_byte => SAFETY_MULTIPLIER * 12740128, ExtCosts::storage_remove_ret_value_byte => SAFETY_MULTIPLIER * 3843852, @@ -268,6 +270,8 @@ pub enum ExtCosts { bls12381_p1_decompress_element = 80, bls12381_p2_decompress_base = 81, bls12381_p2_decompress_element = 82, + storage_large_read_overhead_base = 83, + storage_large_read_overhead_byte = 84, } // Type of an action, used in fees logic. @@ -351,6 +355,12 @@ impl ExtCosts { ExtCosts::storage_read_base => Parameter::WasmStorageReadBase, ExtCosts::storage_read_key_byte => Parameter::WasmStorageReadKeyByte, ExtCosts::storage_read_value_byte => Parameter::WasmStorageReadValueByte, + ExtCosts::storage_large_read_overhead_base => { + Parameter::WasmStorageLargeReadOverheadBase + } + ExtCosts::storage_large_read_overhead_byte => { + Parameter::WasmStorageLargeReadOverheadByte + } ExtCosts::storage_remove_base => Parameter::WasmStorageRemoveBase, ExtCosts::storage_remove_key_byte => Parameter::WasmStorageRemoveKeyByte, ExtCosts::storage_remove_ret_value_byte => Parameter::WasmStorageRemoveRetValueByte, diff --git a/core/parameters/src/parameter.rs b/core/parameters/src/parameter.rs index ee8e75f5e69..3ee7aa2a28c 100644 --- a/core/parameters/src/parameter.rs +++ b/core/parameters/src/parameter.rs @@ -110,6 +110,8 @@ pub enum Parameter { WasmStorageReadBase, WasmStorageReadKeyByte, WasmStorageReadValueByte, + WasmStorageLargeReadOverheadBase, + WasmStorageLargeReadOverheadByte, WasmStorageRemoveBase, WasmStorageRemoveKeyByte, WasmStorageRemoveRetValueByte, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__0.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__0.json.snap index ae8e3f1099d..b96180ab472 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__0.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__0.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__129.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__129.json.snap index 46da61afc6f..cc12b4cb769 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__129.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__129.json.snap @@ -138,9 +138,11 @@ expression: config_view "storage_write_key_byte": 70482867, "storage_write_value_byte": 31018539, "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, + "storage_read_base": 56356845749, "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, + "storage_read_value_byte": 5611004, + "storage_large_read_overhead_base": 1, + "storage_large_read_overhead_byte": 1, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__35.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__35.json.snap index 30ac71b5126..c9a90be852f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__35.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__35.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__42.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__42.json.snap index a8d4c2b762a..d8a7a4cb8e8 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__42.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__42.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__46.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__46.json.snap index e822762d150..6aa127c7f98 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__46.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__46.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__48.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__48.json.snap index 15fbe27adc7..45313c7e296 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__48.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__48.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__49.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__49.json.snap index bcdba46a9b9..5c3ba2ab03f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__49.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__49.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__50.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__50.json.snap index eab9620755f..d8e8a28bcb6 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__50.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__50.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__52.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__52.json.snap index da7e74cc7d6..0598c2599d8 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__52.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__52.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__53.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__53.json.snap index a21b3335e5e..1b4f3bb70b0 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__53.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__53.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__55.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__55.json.snap index 5d8d299d487..4752462a9bb 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__55.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__55.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__57.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__57.json.snap index dd0f2648544..eedcb50e707 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__57.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__57.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__59.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__59.json.snap index ccbe1dcbaf4..a74a8f012dd 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__59.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__59.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__61.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__61.json.snap index 28f332e587d..af335054bee 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__61.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__61.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__62.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__62.json.snap index 9548d786a25..8840a409d5f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__62.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__62.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__63.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__63.json.snap index 9ef63c04c38..0db03fa27ed 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__63.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__63.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__64.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__64.json.snap index 3d2d6808f2e..95ae79e7274 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__64.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__64.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__66.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__66.json.snap index 4cc699faaa4..a8bea891d27 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__66.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__66.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__67.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__67.json.snap index d1cc888a825..766c6993f4f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__67.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__67.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__68.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__68.json.snap index dc6e882bea1..7bdef8b9755 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__68.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__68.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__69.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__69.json.snap index 92e3ec59091..cd9fb2d369a 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__69.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__69.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__70.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__70.json.snap index 2bfdd31fc33..82cb97c02bd 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__70.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__70.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__72.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__72.json.snap index c0d17309a78..a7310cef49f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__72.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__72.json.snap @@ -138,9 +138,11 @@ expression: config_view "storage_write_key_byte": 70482867, "storage_write_value_byte": 31018539, "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, + "storage_read_base": 56356845749, "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, + "storage_read_value_byte": 5611004, + "storage_large_read_overhead_base": 1, + "storage_large_read_overhead_byte": 1, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_0.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_0.json.snap index ae8e3f1099d..b96180ab472 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_0.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_0.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_129.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_129.json.snap index 46da61afc6f..cc12b4cb769 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_129.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_129.json.snap @@ -138,9 +138,11 @@ expression: config_view "storage_write_key_byte": 70482867, "storage_write_value_byte": 31018539, "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, + "storage_read_base": 56356845749, "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, + "storage_read_value_byte": 5611004, + "storage_large_read_overhead_base": 1, + "storage_large_read_overhead_byte": 1, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_35.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_35.json.snap index 30ac71b5126..c9a90be852f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_35.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_35.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_42.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_42.json.snap index a8d4c2b762a..d8a7a4cb8e8 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_42.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_42.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_46.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_46.json.snap index e822762d150..6aa127c7f98 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_46.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_46.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_48.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_48.json.snap index 15fbe27adc7..45313c7e296 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_48.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_48.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_49.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_49.json.snap index bcdba46a9b9..5c3ba2ab03f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_49.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_49.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_50.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_50.json.snap index eab9620755f..d8e8a28bcb6 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_50.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_50.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_52.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_52.json.snap index da7e74cc7d6..0598c2599d8 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_52.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_52.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_53.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_53.json.snap index a21b3335e5e..1b4f3bb70b0 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_53.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_53.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_55.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_55.json.snap index 5d8d299d487..4752462a9bb 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_55.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_55.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_57.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_57.json.snap index dd0f2648544..eedcb50e707 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_57.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_57.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_59.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_59.json.snap index ccbe1dcbaf4..a74a8f012dd 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_59.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_59.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_61.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_61.json.snap index 28f332e587d..af335054bee 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_61.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_61.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_62.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_62.json.snap index 9548d786a25..8840a409d5f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_62.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_62.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_63.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_63.json.snap index 9ef63c04c38..0db03fa27ed 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_63.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_63.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_64.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_64.json.snap index 3d2d6808f2e..95ae79e7274 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_64.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_64.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_66.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_66.json.snap index 4cc699faaa4..a8bea891d27 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_66.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_66.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_67.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_67.json.snap index d1cc888a825..766c6993f4f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_67.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_67.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_68.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_68.json.snap index dc6e882bea1..7bdef8b9755 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_68.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_68.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_69.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_69.json.snap index 92e3ec59091..cd9fb2d369a 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_69.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_69.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_70.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_70.json.snap index 2bfdd31fc33..82cb97c02bd 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_70.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_70.json.snap @@ -141,6 +141,8 @@ expression: config_view "storage_read_base": 56356845750, "storage_read_key_byte": 30952533, "storage_read_value_byte": 5611005, + "storage_large_read_overhead_base": 0, + "storage_large_read_overhead_byte": 0, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_72.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_72.json.snap index c0d17309a78..a7310cef49f 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_72.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_72.json.snap @@ -138,9 +138,11 @@ expression: config_view "storage_write_key_byte": 70482867, "storage_write_value_byte": 31018539, "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, + "storage_read_base": 56356845749, "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, + "storage_read_value_byte": 5611004, + "storage_large_read_overhead_base": 1, + "storage_large_read_overhead_byte": 1, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/snapshots/near_parameters__view__tests__runtime_config_view.snap b/core/parameters/src/snapshots/near_parameters__view__tests__runtime_config_view.snap index 1fef56087b2..c2697088675 100644 --- a/core/parameters/src/snapshots/near_parameters__view__tests__runtime_config_view.snap +++ b/core/parameters/src/snapshots/near_parameters__view__tests__runtime_config_view.snap @@ -138,9 +138,11 @@ expression: "&view" "storage_write_key_byte": 70482867, "storage_write_value_byte": 31018539, "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, + "storage_read_base": 56356845749, "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, + "storage_read_value_byte": 5611004, + "storage_large_read_overhead_base": 1, + "storage_large_read_overhead_byte": 1, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/parameters/src/view.rs b/core/parameters/src/view.rs index 3c1ffd812a2..a6cf2f77dc7 100644 --- a/core/parameters/src/view.rs +++ b/core/parameters/src/view.rs @@ -383,6 +383,11 @@ pub struct ExtCostsConfigView { /// Storage trie read value cost per byte cost pub storage_read_value_byte: Gas, + /// Storage trie read key overhead base cost, when doing large reads + pub storage_large_read_overhead_base: Gas, + /// Storage trie read key overhead per-byte cost, when doing large reads + pub storage_large_read_overhead_byte: Gas, + /// Remove key from trie base cost pub storage_remove_base: Gas, /// Remove key from trie per byte cost @@ -522,6 +527,10 @@ impl From for ExtCostsConfigView { storage_read_base: config.gas_cost(ExtCosts::storage_read_base), storage_read_key_byte: config.gas_cost(ExtCosts::storage_read_key_byte), storage_read_value_byte: config.gas_cost(ExtCosts::storage_read_value_byte), + storage_large_read_overhead_base: config + .gas_cost(ExtCosts::storage_large_read_overhead_base), + storage_large_read_overhead_byte: config + .gas_cost(ExtCosts::storage_large_read_overhead_byte), storage_remove_base: config.gas_cost(ExtCosts::storage_remove_base), storage_remove_key_byte: config.gas_cost(ExtCosts::storage_remove_key_byte), storage_remove_ret_value_byte: config.gas_cost(ExtCosts::storage_remove_ret_value_byte), @@ -622,6 +631,8 @@ impl From for crate::ExtCostsConfig { ExtCosts::storage_read_base => view.storage_read_base, ExtCosts::storage_read_key_byte => view.storage_read_key_byte, ExtCosts::storage_read_value_byte => view.storage_read_value_byte, + ExtCosts::storage_large_read_overhead_base => view.storage_large_read_overhead_base, + ExtCosts::storage_large_read_overhead_byte => view.storage_large_read_overhead_byte, ExtCosts::storage_remove_base => view.storage_remove_base, ExtCosts::storage_remove_key_byte => view.storage_remove_key_byte, ExtCosts::storage_remove_ret_value_byte => view.storage_remove_ret_value_byte, diff --git a/core/primitives-core/src/config.rs b/core/primitives-core/src/config.rs index 70b3dd8c436..7f912d2af7d 100644 --- a/core/primitives-core/src/config.rs +++ b/core/primitives-core/src/config.rs @@ -1,6 +1,18 @@ use crate::types::Gas; use std::hash::Hash; +/// Defines value size threshold for flat state inlining. +/// It means that values having size greater than the threshold will be stored +/// in FlatState as `FlatStateValue::Ref`, otherwise the whole value will be +/// stored as `FlatStateValue::Inlined`. +/// See the following comment for reasoning behind the threshold value: +/// +/// +/// Note that this value then propagates to memtrie, and then to the "small read" +/// costs. As such, changing it is a protocol change, and it should be turned +/// into a protocol parameter if we ever want to change it. +pub const INLINE_DISK_VALUE_THRESHOLD: usize = 4000; + #[derive( Debug, Clone, diff --git a/core/primitives/src/profile_data_v3.rs b/core/primitives/src/profile_data_v3.rs index 0a24f1481d2..97650159ed1 100644 --- a/core/primitives/src/profile_data_v3.rs +++ b/core/primitives/src/profile_data_v3.rs @@ -281,7 +281,7 @@ mod test { storage_read_value_byte -> 32 [0% host] storage_remove_base -> 33 [0% host] storage_remove_key_byte -> 34 [0% host] - storage_remove_ret_value_byte -> 35 [1% host] + storage_remove_ret_value_byte -> 35 [0% host] storage_has_key_base -> 36 [1% host] storage_has_key_byte -> 37 [1% host] storage_iter_create_prefix_base -> 38 [1% host] @@ -315,9 +315,9 @@ mod test { bls12381_p1_sum_element -> 66 [1% host] bls12381_p2_sum_base -> 67 [1% host] bls12381_p2_sum_element -> 68 [1% host] - bls12381_g1_multiexp_base -> 69 [2% host] - bls12381_g1_multiexp_element -> 70 [2% host] - bls12381_g2_multiexp_base -> 71 [2% host] + bls12381_g1_multiexp_base -> 69 [1% host] + bls12381_g1_multiexp_element -> 70 [1% host] + bls12381_g2_multiexp_base -> 71 [1% host] bls12381_g2_multiexp_element -> 72 [2% host] bls12381_map_fp_to_g1_base -> 73 [2% host] bls12381_map_fp_to_g1_element -> 74 [2% host] @@ -329,6 +329,8 @@ mod test { bls12381_p1_decompress_element -> 80 [2% host] bls12381_p2_decompress_base -> 81 [2% host] bls12381_p2_decompress_element -> 82 [2% host] + storage_large_read_overhead_base -> 83 [2% host] + storage_large_read_overhead_byte -> 84 [2% host] ------ Actions -------- create_account -> 1000 delete_account -> 1001 diff --git a/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v2_view.snap b/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v2_view.snap index ad149766e52..635a9e81444 100644 --- a/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v2_view.snap +++ b/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v2_view.snap @@ -345,6 +345,16 @@ expression: view "cost": "STORAGE_ITER_NEXT_VALUE_BYTE", "gas_used": "45" }, + { + "cost_category": "WASM_HOST_COST", + "cost": "STORAGE_LARGE_READ_OVERHEAD_BASE", + "gas_used": "0" + }, + { + "cost_category": "WASM_HOST_COST", + "cost": "STORAGE_LARGE_READ_OVERHEAD_BYTE", + "gas_used": "0" + }, { "cost_category": "WASM_HOST_COST", "cost": "STORAGE_READ_BASE", diff --git a/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap b/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap index 92e7728152d..0e4e2845797 100644 --- a/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap +++ b/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap @@ -370,6 +370,16 @@ expression: view "cost": "STORAGE_ITER_NEXT_VALUE_BYTE", "gas_used": "45" }, + { + "cost_category": "WASM_HOST_COST", + "cost": "STORAGE_LARGE_READ_OVERHEAD_BASE", + "gas_used": "83" + }, + { + "cost_category": "WASM_HOST_COST", + "cost": "STORAGE_LARGE_READ_OVERHEAD_BYTE", + "gas_used": "84" + }, { "cost_category": "WASM_HOST_COST", "cost": "STORAGE_READ_BASE", diff --git a/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap b/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap index 4025dc7b128..6b4a9c7947b 100644 --- a/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap +++ b/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap @@ -138,9 +138,11 @@ expression: "&view" "storage_write_key_byte": 70482867, "storage_write_value_byte": 31018539, "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, + "storage_read_base": 56356845749, "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, + "storage_read_value_byte": 5611004, + "storage_large_read_overhead_base": 1, + "storage_large_read_overhead_byte": 1, "storage_remove_base": 53473030500, "storage_remove_key_byte": 38220384, "storage_remove_ret_value_byte": 11531556, diff --git a/core/primitives/src/state.rs b/core/primitives/src/state.rs index 78d4bf01c1b..dcfd030e07e 100644 --- a/core/primitives/src/state.rs +++ b/core/primitives/src/state.rs @@ -70,13 +70,8 @@ pub enum FlatStateValue { } impl FlatStateValue { - /// Defines value size threshold for flat state inlining. - /// It means that values having size greater than the threshold will be stored - /// in FlatState as `FlatStateValue::Ref`, otherwise the whole value will be - /// stored as `FlatStateValue::Inlined`. - /// See the following comment for reasoning behind the threshold value: - /// - pub const INLINE_DISK_VALUE_THRESHOLD: usize = 4000; + pub const INLINE_DISK_VALUE_THRESHOLD: usize = + near_primitives_core::config::INLINE_DISK_VALUE_THRESHOLD; pub fn on_disk(value: &[u8]) -> Self { if value.len() <= Self::INLINE_DISK_VALUE_THRESHOLD { diff --git a/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile.snap b/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile.snap index 57731f93f9c..eb854e36d17 100644 --- a/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile.snap +++ b/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile.snap @@ -197,7 +197,7 @@ expression: receipts_gas_profile CostGasUsed { cost_category: "WASM_HOST_COST", cost: "STORAGE_READ_BASE", - gas_used: 112713691500, + gas_used: 112713691498, }, CostGasUsed { cost_category: "WASM_HOST_COST", @@ -207,7 +207,7 @@ expression: receipts_gas_profile CostGasUsed { cost_category: "WASM_HOST_COST", cost: "STORAGE_READ_VALUE_BYTE", - gas_used: 28055025, + gas_used: 28055020, }, CostGasUsed { cost_category: "WASM_HOST_COST", diff --git a/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nightly.snap b/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nightly.snap index 57731f93f9c..eb854e36d17 100644 --- a/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nightly.snap +++ b/integration-tests/src/tests/runtime/snapshots/integration_tests__tests__runtime__sanity_checks__receipts_gas_profile_nightly.snap @@ -197,7 +197,7 @@ expression: receipts_gas_profile CostGasUsed { cost_category: "WASM_HOST_COST", cost: "STORAGE_READ_BASE", - gas_used: 112713691500, + gas_used: 112713691498, }, CostGasUsed { cost_category: "WASM_HOST_COST", @@ -207,7 +207,7 @@ expression: receipts_gas_profile CostGasUsed { cost_category: "WASM_HOST_COST", cost: "STORAGE_READ_VALUE_BYTE", - gas_used: 28055025, + gas_used: 28055020, }, CostGasUsed { cost_category: "WASM_HOST_COST", diff --git a/runtime/near-test-contracts/estimator-contract/src/lib.rs b/runtime/near-test-contracts/estimator-contract/src/lib.rs index a1ec33bbb17..0c4cd6c6aa1 100644 --- a/runtime/near-test-contracts/estimator-contract/src/lib.rs +++ b/runtime/near-test-contracts/estimator-contract/src/lib.rs @@ -1039,66 +1039,60 @@ storage_bench!(key, 10, value, 10240, 1000, storage_write_10b_key_10kib_value_1k storage_write(10, key.as_ptr() as _, 10240, value.as_ptr() as _, 0); }); +// Function to measure `storage_write_base + storage_write_value_byte`. +// Writes to storage with 100kib value 1000 times. +storage_bench!(key, 10, value, 102400, 1000, storage_write_10b_key_100kib_value_1k, { + storage_write(10, key.as_ptr() as _, 102400, value.as_ptr() as _, 0); +}); + +// Function to measure `storage_write_base + storage_write_key_byte`. +// Writes to storage with 10kib key and 10kib value 1000 times. +storage_bench!(key, 10240, value, 10240, 1000, storage_write_10kib_key_10kib_value_1k, { + storage_write(10240, key.as_ptr() as _, 10240, value.as_ptr() as _, 0); +}); + // Storage reading. // Function to measure `storage_read_base`. -// Writes to storage 1k times. -storage_bench!(key, 10, value, 10, 1000, storage_read_10b_key_10b_value_1k, { +// Reads from storage 1k times. +storage_bench!(key, 10, value, 10, 1000, storage_read_10b_key_1k, { storage_read(10, key.as_ptr() as _, 0); }); // Function to measure `storage_read_base + storage_read_key_byte`. -// Writes to storage with 10kib key 1000 times. -storage_bench!(key, 10240, value, 10, 1000, storage_read_10kib_key_10b_value_1k, { +// Reads from storage with 10kib key 1000 times. +storage_bench!(key, 10240, value, 10, 1000, storage_read_10kib_key_1k, { storage_read(10240, key.as_ptr() as _, 0); }); -// Function to measure `storage_read_base + storage_read_value_byte`. -// Writes to storage with 10kib value 1000 times. -storage_bench!(key, 10, value, 10240, 1000, storage_read_10b_key_10kib_value_1k, { - storage_read(10, key.as_ptr() as _, 0); -}); - // Storage removing. // Function to measure `storage_remove_base`. // Writes to storage 1k times. -storage_bench!(key, 10, value, 10, 1000, storage_remove_10b_key_10b_value_1k, { +storage_bench!(key, 10, value, 10, 1000, storage_remove_10b_key_1k, { storage_remove(10, key.as_ptr() as _, 0); }); // Function to measure `storage_remove_base + storage_remove_key_byte`. // Writes to storage with 10kib key 1000 times. -storage_bench!(key, 10240, value, 10, 1000, storage_remove_10kib_key_10b_value_1k, { +storage_bench!(key, 10240, value, 10, 1000, storage_remove_10kib_key_1k, { storage_remove(10240, key.as_ptr() as _, 0); }); -// Function to measure `storage_remove_base + storage_remove_value_byte`. -// Writes to storage with 10kib value 1000 times. -storage_bench!(key, 10, value, 10240, 1000, storage_remove_10b_key_10kib_value_1k, { - storage_remove(10, key.as_ptr() as _, 0); -}); - // Storage has key. // Function to measure `storage_has_key_base`. -// Writes to storage 1k times. -storage_bench!(key, 10, value, 10, 1000, storage_has_key_10b_key_10b_value_1k, { +// Checks key existence from storage 1k times. +storage_bench!(key, 10, value, 10, 1000, storage_has_key_10b_key_1k, { storage_has_key(10, key.as_ptr() as _); }); // Function to measure `storage_has_key_base + storage_has_key_key_byte`. -// Writes to storage with 10kib key 1000 times. -storage_bench!(key, 10240, value, 10, 1000, storage_has_key_10kib_key_10b_value_1k, { +// Checks key existence from storage with 10kib key 1000 times. +storage_bench!(key, 10240, value, 10, 1000, storage_has_key_10kib_key_1k, { storage_has_key(10240, key.as_ptr() as _); }); -// Function to measure `storage_has_key_base + storage_has_key_value_byte`. -// Writes to storage with 10kib value 1000 times. -storage_bench!(key, 10, value, 10240, 1000, storage_has_key_10b_key_10kib_value_1k, { - storage_has_key(10, key.as_ptr() as _); -}); - // Function to measure `promise_and_base`. #[no_mangle] pub unsafe fn promise_and_100k() { diff --git a/runtime/near-vm-runner/src/logic/logic.rs b/runtime/near-vm-runner/src/logic/logic.rs index 09ddffa74e4..2c0c87aed64 100644 --- a/runtime/near-vm-runner/src/logic/logic.rs +++ b/runtime/near-vm-runner/src/logic/logic.rs @@ -14,6 +14,7 @@ use near_parameters::vm::{Config, StorageGetMode}; use near_parameters::{ transfer_exec_fee, transfer_send_fee, ActionCosts, ExtCosts, RuntimeFeesConfig, }; +use near_primitives_core::config::INLINE_DISK_VALUE_THRESHOLD; use near_primitives_core::hash::CryptoHash; use near_primitives_core::types::{ AccountId, Balance, Compute, EpochHeight, Gas, GasWeight, StorageUsage, @@ -3175,8 +3176,21 @@ bls12381_p2_decompress_base + bls12381_p2_decompress_element * num_elements` .checked_sub(&nodes_before) .ok_or(InconsistentStateError::IntegerOverflow)?; self.result_state.gas_counter.add_trie_fees(&nodes_delta)?; - let read = - Self::deref_value(&mut self.result_state.gas_counter, storage_read_value_byte, read?)?; + let read = match read? { + Some(read) => { + // Here we'll do u32 -> usize -> u64, which is always infallible + let read_len = read.len() as usize; + self.result_state.gas_counter.pay_per(storage_read_value_byte, read_len as u64)?; + if read_len > INLINE_DISK_VALUE_THRESHOLD { + self.result_state.gas_counter.pay_base(storage_large_read_overhead_base)?; + self.result_state + .gas_counter + .pay_per(storage_large_read_overhead_byte, read_len as u64)?; + } + Some(read.deref()?) + } + None => None, + }; #[cfg(feature = "io_trace")] tracing::trace!( diff --git a/runtime/near-vm-runner/src/profile.rs b/runtime/near-vm-runner/src/profile.rs index ac164cebdcd..bc3e31c071e 100644 --- a/runtime/near-vm-runner/src/profile.rs +++ b/runtime/near-vm-runner/src/profile.rs @@ -280,7 +280,7 @@ mod test { storage_read_value_byte -> 32 [0% host] storage_remove_base -> 33 [0% host] storage_remove_key_byte -> 34 [0% host] - storage_remove_ret_value_byte -> 35 [1% host] + storage_remove_ret_value_byte -> 35 [0% host] storage_has_key_base -> 36 [1% host] storage_has_key_byte -> 37 [1% host] storage_iter_create_prefix_base -> 38 [1% host] @@ -314,9 +314,9 @@ mod test { bls12381_p1_sum_element -> 66 [1% host] bls12381_p2_sum_base -> 67 [1% host] bls12381_p2_sum_element -> 68 [1% host] - bls12381_g1_multiexp_base -> 69 [2% host] - bls12381_g1_multiexp_element -> 70 [2% host] - bls12381_g2_multiexp_base -> 71 [2% host] + bls12381_g1_multiexp_base -> 69 [1% host] + bls12381_g1_multiexp_element -> 70 [1% host] + bls12381_g2_multiexp_base -> 71 [1% host] bls12381_g2_multiexp_element -> 72 [2% host] bls12381_map_fp_to_g1_base -> 73 [2% host] bls12381_map_fp_to_g1_element -> 74 [2% host] @@ -328,6 +328,8 @@ mod test { bls12381_p1_decompress_element -> 80 [2% host] bls12381_p2_decompress_base -> 81 [2% host] bls12381_p2_decompress_element -> 82 [2% host] + storage_large_read_overhead_base -> 83 [2% host] + storage_large_read_overhead_byte -> 84 [2% host] ------ Actions -------- create_account -> 1000 delete_account -> 1001 diff --git a/runtime/runtime-params-estimator/src/lib.rs b/runtime/runtime-params-estimator/src/lib.rs index ce501de2852..18c02a5e793 100644 --- a/runtime/runtime-params-estimator/src/lib.rs +++ b/runtime/runtime-params-estimator/src/lib.rs @@ -1164,8 +1164,8 @@ fn bls12381_p2_decompress_element(ctx: &mut EstimatorContext) -> GasCost { fn storage_has_key_base(ctx: &mut EstimatorContext) -> GasCost { fn_cost_with_setup( ctx, - "storage_write_10b_key_10b_value_1k", - "storage_has_key_10b_key_10b_value_1k", + "storage_write_10b_key_10kib_value_1k", + "storage_has_key_10b_key_1k", ExtCosts::storage_has_key_base, 1000, 0, @@ -1174,8 +1174,8 @@ fn storage_has_key_base(ctx: &mut EstimatorContext) -> GasCost { fn storage_has_key_byte(ctx: &mut EstimatorContext) -> GasCost { fn_cost_with_setup( ctx, - "storage_write_10kib_key_10b_value_1k", - "storage_has_key_10kib_key_10b_value_1k", + "storage_write_10kib_key_10kib_value_1k", + "storage_has_key_10kib_key_1k", ExtCosts::storage_has_key_byte, 10 * 1024 * 1000, 0, @@ -1188,8 +1188,8 @@ fn storage_read_base(ctx: &mut EstimatorContext) -> GasCost { } let cost = fn_cost_with_setup( ctx, - "storage_write_10b_key_10b_value_1k", - "storage_read_10b_key_10b_value_1k", + "storage_write_10b_key_10kib_value_1k", + "storage_read_10b_key_1k", ExtCosts::storage_read_base, 1000, 0, @@ -1199,8 +1199,8 @@ fn storage_read_base(ctx: &mut EstimatorContext) -> GasCost { fn storage_read_key_byte(ctx: &mut EstimatorContext) -> GasCost { fn_cost_with_setup( ctx, - "storage_write_10kib_key_10b_value_1k", - "storage_read_10kib_key_10b_value_1k", + "storage_write_10kib_key_10kib_value_1k", + "storage_read_10kib_key_1k", ExtCosts::storage_read_key_byte, 10 * 1024 * 1000, 0, @@ -1209,10 +1209,10 @@ fn storage_read_key_byte(ctx: &mut EstimatorContext) -> GasCost { fn storage_read_value_byte(ctx: &mut EstimatorContext) -> GasCost { fn_cost_with_setup( ctx, - "storage_write_10b_key_10kib_value_1k", - "storage_read_10b_key_10kib_value_1k", + "storage_write_10b_key_100kib_value_1k", + "storage_read_10b_key_1k", ExtCosts::storage_read_value_byte, - 10 * 1024 * 1000, + 100 * 1024 * 1000, 0, ) } @@ -1251,7 +1251,7 @@ fn storage_remove_base(ctx: &mut EstimatorContext) -> GasCost { fn_cost_with_setup( ctx, "storage_write_10b_key_10b_value_1k", - "storage_remove_10b_key_10b_value_1k", + "storage_remove_10b_key_1k", ExtCosts::storage_remove_base, 1000, 0, @@ -1261,7 +1261,7 @@ fn storage_remove_key_byte(ctx: &mut EstimatorContext) -> GasCost { fn_cost_with_setup( ctx, "storage_write_10kib_key_10b_value_1k", - "storage_remove_10kib_key_10b_value_1k", + "storage_remove_10kib_key_1k", ExtCosts::storage_remove_key_byte, 10 * 1024 * 1000, 0, @@ -1271,7 +1271,7 @@ fn storage_remove_ret_value_byte(ctx: &mut EstimatorContext) -> GasCost { fn_cost_with_setup( ctx, "storage_write_10b_key_10kib_value_1k", - "storage_remove_10b_key_10kib_value_1k", + "storage_remove_10b_key_1k", ExtCosts::storage_remove_ret_value_byte, 10 * 1024 * 1000, 0, diff --git a/tools/protocol-schema-check/res/protocol_schema.toml b/tools/protocol-schema-check/res/protocol_schema.toml index 21632483d7e..75b4d339fec 100644 --- a/tools/protocol-schema-check/res/protocol_schema.toml +++ b/tools/protocol-schema-check/res/protocol_schema.toml @@ -101,13 +101,13 @@ EpochInfoV3 = 91327628 EpochInfoV4 = 434230701 EpochSummary = 742414117 EpochValidatorInfo = 378323971 -ExecutionMetadata = 3532864429 -ExecutionOutcome = 3162058681 -ExecutionOutcomeWithId = 522309703 -ExecutionOutcomeWithIdAndProof = 1300070947 -ExecutionOutcomeWithProof = 3663131288 +ExecutionMetadata = 3853243413 +ExecutionOutcome = 1325623645 +ExecutionOutcomeWithId = 36999569 +ExecutionOutcomeWithIdAndProof = 4044381219 +ExecutionOutcomeWithProof = 4104315440 ExecutionStatus = 1810006625 -ExtCosts = 836392984 +ExtCosts = 1172935704 FetchingStateStatus = 2204896805 FlatStateChanges = 2811133731 FlatStateDeltaMetadata = 3401366797 @@ -157,7 +157,7 @@ Ping = 2783493472 Pong = 3159638327 PrepareError = 4009037507 ProfileDataV2 = 1955507222 -ProfileDataV3 = 302159633 +ProfileDataV3 = 1564915364 PromiseYieldIndices = 405847541 PromiseYieldTimeout = 3189361393 PublicKey = 601042198