Skip to content

Commit

Permalink
feat: set storage compute cost > gas cost (#8924)
Browse files Browse the repository at this point in the history
This is a protocol feature, updating the storage cost as agreed in #8006
to allow flat storage to be deployed without undercharging risks.
  • Loading branch information
jakmeier authored and nikurt committed Apr 28, 2023
1 parent bb83484 commit 6e859e6
Show file tree
Hide file tree
Showing 5 changed files with 392 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Contract preparation and gas charging for wasm execution also switched to using our own code, as per the finite-wasm specification. Contract execution gas costs will change slightly for expected use cases. This opens up opportunities for further changing the execution gas costs (eg. with different costs per opcode) to lower contract execution cost long-term.
* Compute Costs are implemented and stabilized. Compute usage of the chunk is now limited according to the compute costs. [#8915](https://github.com/near/nearcore/pull/8915), [NEP-455](https://github.com/near/NEPs/blob/master/neps/nep-0455.md).
* Write related storage compute costs are increased which means they fill a chunk sooner but gas costs are unaffected. [#8924](https://github.com/near/nearcore/pull/8924)

### Non-protocol Changes

Expand Down
8 changes: 8 additions & 0 deletions core/primitives/res/runtime_configs/61.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
max_stack_height: { old: 16384, new: 262144 }
contract_prepare_version: { old: 1, new: 2 }

# Compute costs to allow for flat storage read-only MVP.
# See https://github.com/near/nearcore/issues/8006
wasm_touching_trie_node: { old: 16_101_955_926, new: { gas: 16_101_955_926, compute: 110_000_000_000 } }
wasm_storage_write_base: { old: 64_196_736_000, new: { gas: 64_196_736_000, compute: 200_000_000_000 } }
wasm_storage_remove_base: { old: 53_473_030_500, new: { gas: 53_473_030_500, compute: 200_000_000_000 } }
wasm_storage_read_base: { old: 56_356_845_750, new: { gas: 56_356_845_750, compute: 200_000_000_000 } }
wasm_storage_has_key_base: { old: 54_039_896_625, new: { gas: 54_039_896_625, compute: 200_000_000_000 } }
10 changes: 5 additions & 5 deletions core/primitives/res/runtime_configs/parameters.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ wasm_ed25519_verify_base 210_000_000_000
wasm_ed25519_verify_byte 9_000_000
wasm_log_base 3_543_313_050
wasm_log_byte 13_198_791
wasm_storage_write_base 64_196_736_000
wasm_storage_write_base 64_196_736_000, compute: 200_000_000_000
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
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_remove_base 53_473_030_500
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
wasm_storage_has_key_base 54_039_896_625, compute: 200_000_000_000
wasm_storage_has_key_byte 30_790_845
wasm_storage_iter_create_prefix_base 0
wasm_storage_iter_create_prefix_byte 0
Expand All @@ -123,7 +123,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
wasm_touching_trie_node 16_101_955_926, compute: 110_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
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/tests/client/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod fix_storage_usage;
#[cfg(feature = "protocol_feature_flat_state")]
mod flat_storage;
mod increase_deployment_cost;
mod increase_storage_compute_cost;
mod limit_contract_functions_number;
mod lower_storage_key_limit;
mod restore_receipts_after_fix_apply_chunks;
Expand Down
Loading

0 comments on commit 6e859e6

Please sign in to comment.