From 0119aeacbcf8de4c447d44dfa09ce298e0056b17 Mon Sep 17 00:00:00 2001 From: Jan Ciolek Date: Wed, 22 May 2024 14:19:04 +0000 Subject: [PATCH] Lower transaction size limit to 1.5MiB The size limit for a single single transaction used to be 4MiB, this PR reduces it to 1.5MiB. Transactions larger than 1.5MiB will be rejected. This is done to help with https://github.com/near/nearcore/issues/11103. It's hard to limit the size of `ChunkStateWitness` when a single transaction can be as large as 4MiB. Having 1.5MiB transactions makes things much more manageable. This will break some transactions. On current mainnet there is approximately one transaction larger than 1.5MiB per day (~420 large txs per year). We've decided that it's okay to break those transactions. The new limit is introduced in protocol version `68`. This protocol version could be released before the full stateless validation launch, to see if anyone complains. Note that this change doesn't limit the size of receipts, only transactions. It's still possible to create a receipt with a 4MiB contract or function call, but that's out of scope for the transaction size limit. Zulip discussion about lowering the limit: https://near.zulipchat.com/#narrow/stream/295306-contract-runtime/topic/.E2.9C.94.20Lowering.20the.20limit.20for.20contract.20code.20size --- chain/chain/src/tests/simple_chain.rs | 4 +- .../jsonrpc-tests/res/genesis_config.json | 2 +- core/parameters/res/runtime_configs/68.yaml | 1 + .../res/runtime_configs/parameters.snap | 2 +- core/parameters/src/config_store.rs | 1 + ...meters__config_store__tests__129.json.snap | 2 +- ...meters__config_store__tests__138.json.snap | 2 +- ...meters__config_store__tests__139.json.snap | 2 +- ...meters__config_store__tests__142.json.snap | 2 +- ...ameters__config_store__tests__68.json.snap | 227 ++++++++++++++++++ ...ameters__config_store__tests__83.json.snap | 2 +- ...ameters__config_store__tests__85.json.snap | 2 +- ...config_store__tests__testnet_129.json.snap | 2 +- ...config_store__tests__testnet_138.json.snap | 2 +- ...config_store__tests__testnet_139.json.snap | 2 +- ...config_store__tests__testnet_142.json.snap | 2 +- ..._config_store__tests__testnet_68.json.snap | 227 ++++++++++++++++++ ..._config_store__tests__testnet_83.json.snap | 2 +- ..._config_store__tests__testnet_85.json.snap | 2 +- ...ers__view__tests__runtime_config_view.snap | 2 +- core/primitives-core/src/version.rs | 2 +- ...es__views__tests__runtime_config_view.snap | 2 +- .../src/tests/client/benchmarks.rs | 6 +- .../src/action_costs.rs | 8 +- runtime/runtime-params-estimator/src/lib.rs | 10 +- 25 files changed, 487 insertions(+), 31 deletions(-) create mode 100644 core/parameters/res/runtime_configs/68.yaml create mode 100644 core/parameters/src/snapshots/near_parameters__config_store__tests__68.json.snap create mode 100644 core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_68.json.snap diff --git a/chain/chain/src/tests/simple_chain.rs b/chain/chain/src/tests/simple_chain.rs index 3243f9c98a4..ebac9508698 100644 --- a/chain/chain/src/tests/simple_chain.rs +++ b/chain/chain/src/tests/simple_chain.rs @@ -34,7 +34,7 @@ fn build_chain() { if cfg!(feature = "nightly") { insta::assert_snapshot!(hash, @"C3zeKRZubVungxfrSdq379TSCYnuz2YzjEkcJTdm3pU4"); } else { - insta::assert_snapshot!(hash, @"2WHohfYksQnwKwSEoTKpkseu2RWthbGf9kmGetgHgfQQ"); + insta::assert_snapshot!(hash, @"Gy5ScP5b8NmHSFvdRHWmdvfRwLfx3gs5GoasiXXtmNmv"); } for i in 1..5 { @@ -52,7 +52,7 @@ fn build_chain() { if cfg!(feature = "nightly") { insta::assert_snapshot!(hash, @"EjLaoHRiAdRp2NcDqwbMcAYYxGfcv5R7GuYUNfRpaJvB"); } else { - insta::assert_snapshot!(hash, @"HJuuENeSwwikoR9BZA7cSonxAPZgY5mKQWL2pSXwjAwZ"); + insta::assert_snapshot!(hash, @"HoBdHTTC2QSkQfsmBerpTJnBVyfMDBzjBA9DwM4wnpMC"); } } diff --git a/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json b/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json index 850645e6e89..627df3b9e3e 100644 --- a/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json +++ b/chain/jsonrpc/jsonrpc-tests/res/genesis_config.json @@ -1,5 +1,5 @@ { - "protocol_version": 67, + "protocol_version": 68, "genesis_time": "1970-01-01T00:00:00.000000000Z", "chain_id": "sample", "genesis_height": 0, diff --git a/core/parameters/res/runtime_configs/68.yaml b/core/parameters/res/runtime_configs/68.yaml new file mode 100644 index 00000000000..a2755d4b0e4 --- /dev/null +++ b/core/parameters/res/runtime_configs/68.yaml @@ -0,0 +1 @@ +max_transaction_size: {old: 4_194_304, new: 1_572_864} diff --git a/core/parameters/res/runtime_configs/parameters.snap b/core/parameters/res/runtime_configs/parameters.snap index 89248b9ac11..efadfd8ebdc 100644 --- a/core/parameters/res/runtime_configs/parameters.snap +++ b/core/parameters/res/runtime_configs/parameters.snap @@ -160,7 +160,7 @@ max_length_method_name 256 max_arguments_length 4_194_304 max_length_returned_data 4_194_304 max_contract_size 4_194_304 -max_transaction_size 4_194_304 +max_transaction_size 1_572_864 max_length_storage_key 2_048 max_length_storage_value 4_194_304 max_promises_per_function_call_action 1_024 diff --git a/core/parameters/src/config_store.rs b/core/parameters/src/config_store.rs index b55e3e775d2..b6e8e37fd3f 100644 --- a/core/parameters/src/config_store.rs +++ b/core/parameters/src/config_store.rs @@ -39,6 +39,7 @@ static CONFIG_DIFFS: &[(ProtocolVersion, &str)] = &[ (64, include_config!("64.yaml")), (66, include_config!("66.yaml")), (67, include_config!("67.yaml")), + (68, include_config!("68.yaml")), (83, include_config!("83.yaml")), (85, include_config!("85.yaml")), (129, include_config!("129.yaml")), 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 ac0ec16da8b..b93d7542852 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 @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__138.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__138.json.snap index bb5d7b8ea62..92d04e4e303 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__138.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__138.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__139.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__139.json.snap index bb5d7b8ea62..92d04e4e303 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__139.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__139.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__142.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__142.json.snap index bb5d7b8ea62..92d04e4e303 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__142.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__142.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, 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 new file mode 100644 index 00000000000..0e54689078e --- /dev/null +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__68.json.snap @@ -0,0 +1,227 @@ +--- +source: core/parameters/src/config_store.rs +expression: config_view +--- +{ + "storage_amount_per_byte": "10000000000000000000", + "transaction_costs": { + "action_receipt_creation_config": { + "send_sir": 108059500000, + "send_not_sir": 108059500000, + "execution": 108059500000 + }, + "data_receipt_creation_config": { + "base_cost": { + "send_sir": 36486732312, + "send_not_sir": 36486732312, + "execution": 36486732312 + }, + "cost_per_byte": { + "send_sir": 17212011, + "send_not_sir": 17212011, + "execution": 17212011 + } + }, + "action_creation_config": { + "create_account_cost": { + "send_sir": 3850000000000, + "send_not_sir": 3850000000000, + "execution": 3850000000000 + }, + "deploy_contract_cost": { + "send_sir": 184765750000, + "send_not_sir": 184765750000, + "execution": 184765750000 + }, + "deploy_contract_cost_per_byte": { + "send_sir": 6812999, + "send_not_sir": 6812999, + "execution": 64572944 + }, + "function_call_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 780000000000 + }, + "function_call_cost_per_byte": { + "send_sir": 2235934, + "send_not_sir": 2235934, + "execution": 2235934 + }, + "transfer_cost": { + "send_sir": 115123062500, + "send_not_sir": 115123062500, + "execution": 115123062500 + }, + "stake_cost": { + "send_sir": 141715687500, + "send_not_sir": 141715687500, + "execution": 102217625000 + }, + "add_key_cost": { + "full_access_cost": { + "send_sir": 101765125000, + "send_not_sir": 101765125000, + "execution": 101765125000 + }, + "function_call_cost": { + "send_sir": 102217625000, + "send_not_sir": 102217625000, + "execution": 102217625000 + }, + "function_call_cost_per_byte": { + "send_sir": 1925331, + "send_not_sir": 1925331, + "execution": 1925331 + } + }, + "delete_key_cost": { + "send_sir": 94946625000, + "send_not_sir": 94946625000, + "execution": 94946625000 + }, + "delete_account_cost": { + "send_sir": 147489000000, + "send_not_sir": 147489000000, + "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 + } + }, + "storage_usage_config": { + "num_bytes_account": 100, + "num_extra_bytes_record": 40 + }, + "burnt_gas_reward": [ + 3, + 10 + ], + "pessimistic_gas_price_inflation_ratio": [ + 103, + 100 + ], + "storage_proof_size_soft_limit": 999999999999999 + }, + "wasm_config": { + "ext_costs": { + "base": 264768111, + "contract_loading_base": 35445963, + "contract_loading_bytes": 1089295, + "read_memory_base": 2609863200, + "read_memory_byte": 3801333, + "write_memory_base": 2803794861, + "write_memory_byte": 2723772, + "read_register_base": 2517165186, + "read_register_byte": 98562, + "write_register_base": 2865522486, + "write_register_byte": 3801564, + "utf8_decoding_base": 3111779061, + "utf8_decoding_byte": 291580479, + "utf16_decoding_base": 3543313050, + "utf16_decoding_byte": 163577493, + "sha256_base": 4540970250, + "sha256_byte": 24117351, + "keccak256_base": 5879491275, + "keccak256_byte": 21471105, + "keccak512_base": 5811388236, + "keccak512_byte": 36649701, + "ripemd160_base": 853675086, + "ripemd160_block": 680107584, + "ed25519_verify_base": 210000000000, + "ed25519_verify_byte": 9000000, + "ecrecover_base": 278821988457, + "log_base": 3543313050, + "log_byte": 13198791, + "storage_write_base": 64196736000, + "storage_write_key_byte": 70482867, + "storage_write_value_byte": 31018539, + "storage_write_evicted_byte": 32117307, + "storage_read_base": 56356845750, + "storage_read_key_byte": 30952533, + "storage_read_value_byte": 5611005, + "storage_remove_base": 53473030500, + "storage_remove_key_byte": 38220384, + "storage_remove_ret_value_byte": 11531556, + "storage_has_key_base": 54039896625, + "storage_has_key_byte": 30790845, + "storage_iter_create_prefix_base": 0, + "storage_iter_create_prefix_byte": 0, + "storage_iter_create_range_base": 0, + "storage_iter_create_from_byte": 0, + "storage_iter_create_to_byte": 0, + "storage_iter_next_base": 0, + "storage_iter_next_key_byte": 0, + "storage_iter_next_value_byte": 0, + "touching_trie_node": 16101955926, + "read_cached_trie_node": 2280000000, + "promise_and_base": 1465013400, + "promise_and_per_promise": 5452176, + "promise_return": 560152386, + "validator_stake_base": 911834726400, + "validator_total_stake_base": 911834726400, + "contract_compile_base": 0, + "contract_compile_bytes": 0, + "alt_bn128_g1_multiexp_base": 713000000000, + "alt_bn128_g1_multiexp_element": 320000000000, + "alt_bn128_g1_sum_base": 3000000000, + "alt_bn128_g1_sum_element": 5000000000, + "alt_bn128_pairing_check_base": 9686000000000, + "alt_bn128_pairing_check_element": 5102000000000, + "yield_create_base": 153411779276, + "yield_create_byte": 15643988, + "yield_resume_base": 1195627285210, + "yield_resume_byte": 1195627285210 + }, + "grow_mem_cost": 1, + "regular_op_cost": 822756, + "vm_kind": "", + "disable_9393_fix": false, + "storage_get_mode": "FlatStorage", + "fix_contract_loading_cost": false, + "implicit_account_creation": true, + "math_extension": true, + "ed25519_verify": true, + "alt_bn128": true, + "function_call_weight": true, + "eth_implicit_accounts": false, + "yield_resume_host_functions": true, + "limit_config": { + "max_gas_burnt": 300000000000000, + "max_stack_height": 262144, + "contract_prepare_version": 2, + "initial_memory_pages": 1024, + "max_memory_pages": 2048, + "registers_memory_limit": 1073741824, + "max_register_size": 104857600, + "max_number_registers": 100, + "max_number_logs": 100, + "max_total_log_length": 16384, + "max_total_prepaid_gas": 300000000000000, + "max_actions_per_receipt": 100, + "max_number_bytes_method_names": 2000, + "max_length_method_name": 256, + "max_arguments_length": 4194304, + "max_length_returned_data": 4194304, + "max_contract_size": 4194304, + "max_transaction_size": 1572864, + "max_length_storage_key": 2048, + "max_length_storage_value": 4194304, + "max_promises_per_function_call_action": 1024, + "max_number_input_data_dependencies": 128, + "max_functions_number_per_contract": 10000, + "wasmer2_stack_limit": 204800, + "max_locals_per_contract": 1000000, + "account_id_validity_rules_version": 1, + "yield_timeout_length_in_blocks": 200, + "max_yield_payload_size": 1024, + "storage_proof_size_receipt_limit": 999999999999999 + } + }, + "account_creation_config": { + "min_allowed_top_level_account_length": 65, + "registrar_account_id": "registrar" + } +} diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__83.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__83.json.snap index 750af8c5be3..98b04d4166c 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__83.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__83.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__85.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__85.json.snap index 60349cb7759..755f9ad828a 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__85.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__85.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, 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 ac0ec16da8b..b93d7542852 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 @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_138.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_138.json.snap index bb5d7b8ea62..92d04e4e303 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_138.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_138.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_139.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_139.json.snap index bb5d7b8ea62..92d04e4e303 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_139.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_139.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_142.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_142.json.snap index bb5d7b8ea62..92d04e4e303 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_142.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_142.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, 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 new file mode 100644 index 00000000000..0e54689078e --- /dev/null +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_68.json.snap @@ -0,0 +1,227 @@ +--- +source: core/parameters/src/config_store.rs +expression: config_view +--- +{ + "storage_amount_per_byte": "10000000000000000000", + "transaction_costs": { + "action_receipt_creation_config": { + "send_sir": 108059500000, + "send_not_sir": 108059500000, + "execution": 108059500000 + }, + "data_receipt_creation_config": { + "base_cost": { + "send_sir": 36486732312, + "send_not_sir": 36486732312, + "execution": 36486732312 + }, + "cost_per_byte": { + "send_sir": 17212011, + "send_not_sir": 17212011, + "execution": 17212011 + } + }, + "action_creation_config": { + "create_account_cost": { + "send_sir": 3850000000000, + "send_not_sir": 3850000000000, + "execution": 3850000000000 + }, + "deploy_contract_cost": { + "send_sir": 184765750000, + "send_not_sir": 184765750000, + "execution": 184765750000 + }, + "deploy_contract_cost_per_byte": { + "send_sir": 6812999, + "send_not_sir": 6812999, + "execution": 64572944 + }, + "function_call_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 780000000000 + }, + "function_call_cost_per_byte": { + "send_sir": 2235934, + "send_not_sir": 2235934, + "execution": 2235934 + }, + "transfer_cost": { + "send_sir": 115123062500, + "send_not_sir": 115123062500, + "execution": 115123062500 + }, + "stake_cost": { + "send_sir": 141715687500, + "send_not_sir": 141715687500, + "execution": 102217625000 + }, + "add_key_cost": { + "full_access_cost": { + "send_sir": 101765125000, + "send_not_sir": 101765125000, + "execution": 101765125000 + }, + "function_call_cost": { + "send_sir": 102217625000, + "send_not_sir": 102217625000, + "execution": 102217625000 + }, + "function_call_cost_per_byte": { + "send_sir": 1925331, + "send_not_sir": 1925331, + "execution": 1925331 + } + }, + "delete_key_cost": { + "send_sir": 94946625000, + "send_not_sir": 94946625000, + "execution": 94946625000 + }, + "delete_account_cost": { + "send_sir": 147489000000, + "send_not_sir": 147489000000, + "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 + } + }, + "storage_usage_config": { + "num_bytes_account": 100, + "num_extra_bytes_record": 40 + }, + "burnt_gas_reward": [ + 3, + 10 + ], + "pessimistic_gas_price_inflation_ratio": [ + 103, + 100 + ], + "storage_proof_size_soft_limit": 999999999999999 + }, + "wasm_config": { + "ext_costs": { + "base": 264768111, + "contract_loading_base": 35445963, + "contract_loading_bytes": 1089295, + "read_memory_base": 2609863200, + "read_memory_byte": 3801333, + "write_memory_base": 2803794861, + "write_memory_byte": 2723772, + "read_register_base": 2517165186, + "read_register_byte": 98562, + "write_register_base": 2865522486, + "write_register_byte": 3801564, + "utf8_decoding_base": 3111779061, + "utf8_decoding_byte": 291580479, + "utf16_decoding_base": 3543313050, + "utf16_decoding_byte": 163577493, + "sha256_base": 4540970250, + "sha256_byte": 24117351, + "keccak256_base": 5879491275, + "keccak256_byte": 21471105, + "keccak512_base": 5811388236, + "keccak512_byte": 36649701, + "ripemd160_base": 853675086, + "ripemd160_block": 680107584, + "ed25519_verify_base": 210000000000, + "ed25519_verify_byte": 9000000, + "ecrecover_base": 278821988457, + "log_base": 3543313050, + "log_byte": 13198791, + "storage_write_base": 64196736000, + "storage_write_key_byte": 70482867, + "storage_write_value_byte": 31018539, + "storage_write_evicted_byte": 32117307, + "storage_read_base": 56356845750, + "storage_read_key_byte": 30952533, + "storage_read_value_byte": 5611005, + "storage_remove_base": 53473030500, + "storage_remove_key_byte": 38220384, + "storage_remove_ret_value_byte": 11531556, + "storage_has_key_base": 54039896625, + "storage_has_key_byte": 30790845, + "storage_iter_create_prefix_base": 0, + "storage_iter_create_prefix_byte": 0, + "storage_iter_create_range_base": 0, + "storage_iter_create_from_byte": 0, + "storage_iter_create_to_byte": 0, + "storage_iter_next_base": 0, + "storage_iter_next_key_byte": 0, + "storage_iter_next_value_byte": 0, + "touching_trie_node": 16101955926, + "read_cached_trie_node": 2280000000, + "promise_and_base": 1465013400, + "promise_and_per_promise": 5452176, + "promise_return": 560152386, + "validator_stake_base": 911834726400, + "validator_total_stake_base": 911834726400, + "contract_compile_base": 0, + "contract_compile_bytes": 0, + "alt_bn128_g1_multiexp_base": 713000000000, + "alt_bn128_g1_multiexp_element": 320000000000, + "alt_bn128_g1_sum_base": 3000000000, + "alt_bn128_g1_sum_element": 5000000000, + "alt_bn128_pairing_check_base": 9686000000000, + "alt_bn128_pairing_check_element": 5102000000000, + "yield_create_base": 153411779276, + "yield_create_byte": 15643988, + "yield_resume_base": 1195627285210, + "yield_resume_byte": 1195627285210 + }, + "grow_mem_cost": 1, + "regular_op_cost": 822756, + "vm_kind": "", + "disable_9393_fix": false, + "storage_get_mode": "FlatStorage", + "fix_contract_loading_cost": false, + "implicit_account_creation": true, + "math_extension": true, + "ed25519_verify": true, + "alt_bn128": true, + "function_call_weight": true, + "eth_implicit_accounts": false, + "yield_resume_host_functions": true, + "limit_config": { + "max_gas_burnt": 300000000000000, + "max_stack_height": 262144, + "contract_prepare_version": 2, + "initial_memory_pages": 1024, + "max_memory_pages": 2048, + "registers_memory_limit": 1073741824, + "max_register_size": 104857600, + "max_number_registers": 100, + "max_number_logs": 100, + "max_total_log_length": 16384, + "max_total_prepaid_gas": 300000000000000, + "max_actions_per_receipt": 100, + "max_number_bytes_method_names": 2000, + "max_length_method_name": 256, + "max_arguments_length": 4194304, + "max_length_returned_data": 4194304, + "max_contract_size": 4194304, + "max_transaction_size": 1572864, + "max_length_storage_key": 2048, + "max_length_storage_value": 4194304, + "max_promises_per_function_call_action": 1024, + "max_number_input_data_dependencies": 128, + "max_functions_number_per_contract": 10000, + "wasmer2_stack_limit": 204800, + "max_locals_per_contract": 1000000, + "account_id_validity_rules_version": 1, + "yield_timeout_length_in_blocks": 200, + "max_yield_payload_size": 1024, + "storage_proof_size_receipt_limit": 999999999999999 + } + }, + "account_creation_config": { + "min_allowed_top_level_account_length": 65, + "registrar_account_id": "registrar" + } +} diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_83.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_83.json.snap index 750af8c5be3..98b04d4166c 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_83.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_83.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_85.json.snap b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_85.json.snap index 60349cb7759..755f9ad828a 100644 --- a/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_85.json.snap +++ b/core/parameters/src/snapshots/near_parameters__config_store__tests__testnet_85.json.snap @@ -206,7 +206,7 @@ expression: config_view "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, 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 5951499fd93..5235a918f37 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 @@ -206,7 +206,7 @@ expression: "&view" "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/core/primitives-core/src/version.rs b/core/primitives-core/src/version.rs index 1e0ac19e996..9f1971171f6 100644 --- a/core/primitives-core/src/version.rs +++ b/core/primitives-core/src/version.rs @@ -247,7 +247,7 @@ impl ProtocolFeature { /// Current protocol version used on the mainnet. /// Some features (e. g. FixStorageUsage) require that there is at least one epoch with exactly /// the corresponding version -const STABLE_PROTOCOL_VERSION: ProtocolVersion = 67; +const STABLE_PROTOCOL_VERSION: ProtocolVersion = 68; /// Largest protocol version supported by the current binary. pub const PROTOCOL_VERSION: ProtocolVersion = if cfg!(feature = "statelessnet_protocol") { 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 e7df3feb636..32eb5daed99 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 @@ -206,7 +206,7 @@ expression: "&view" "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, - "max_transaction_size": 4194304, + "max_transaction_size": 1572864, "max_length_storage_key": 2048, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/integration-tests/src/tests/client/benchmarks.rs b/integration-tests/src/tests/client/benchmarks.rs index ebd1860a628..bb886f49b05 100644 --- a/integration-tests/src/tests/client/benchmarks.rs +++ b/integration-tests/src/tests/client/benchmarks.rs @@ -23,8 +23,8 @@ use nearcore::test_utils::TestEnvNightshadeSetupExt; fn benchmark_large_chunk_production_time() { let mb = 1024usize.pow(2); - let n_txes = 20; - let tx_size = 3 * mb; + let n_txes = 60; + let tx_size = 1 * mb; let genesis = Genesis::test(vec!["test0".parse().unwrap(), "test1".parse().unwrap()], 1); let mut env = TestEnv::builder(&genesis.config).nightshade_runtimes(&genesis).build(); @@ -56,5 +56,5 @@ fn benchmark_large_chunk_production_time() { // Check that we limit the size of the chunk and not include all `n_txes` // transactions in the chunk. - assert!(30 * mb < size && size < 40 * mb, "{size}"); + assert!(25 * mb < size && size < 40 * mb, "{size}"); } diff --git a/runtime/runtime-params-estimator/src/action_costs.rs b/runtime/runtime-params-estimator/src/action_costs.rs index 8184e9059a2..d886dd701df 100644 --- a/runtime/runtime-params-estimator/src/action_costs.rs +++ b/runtime/runtime-params-estimator/src/action_costs.rs @@ -791,8 +791,8 @@ impl ActionSize { // calling "noop" requires 4 bytes ActionSize::Min => 4, // max_arguments_length: 4_194_304 - // max_transaction_size: 4_194_304 - ActionSize::Max => (4_194_304 / 100) - 35, + // max_transaction_size: 1_572_864 + ActionSize::Max => (1_572_864 / 100) - 35, } } @@ -813,7 +813,7 @@ impl ActionSize { // fails with `InvalidTxError(TransactionSizeExceeded`, it could be a // protocol change due to the TX limit computation changing. // The test `test_deploy_contract_tx_max_size` checks this. - ActionSize::Max => 4 * 1024 * 1024 - 182, + ActionSize::Max => 1_572_864 - 182, } } } @@ -827,7 +827,7 @@ mod tests { fn test_deploy_contract_tx_max_size() { // The size of a transaction constructed from this must be exactly at the limit. let deploy_action = deploy_action(ActionSize::Max); - let limit = 4_194_304; + let limit = 1_572_864; // We also need some account IDs constructed the same way as in the estimator. // Let's try multiple index sizes to ensure this does not affect the length. diff --git a/runtime/runtime-params-estimator/src/lib.rs b/runtime/runtime-params-estimator/src/lib.rs index 22f7268c22a..a10aa81b151 100644 --- a/runtime/runtime-params-estimator/src/lib.rs +++ b/runtime/runtime-params-estimator/src/lib.rs @@ -719,13 +719,13 @@ fn pure_deploy_bytes(ctx: &mut EstimatorContext) -> GasCost { let config_store = RuntimeConfigStore::new(None); let vm_config = config_store.get_config(PROTOCOL_VERSION).wasm_config.clone(); let small_code = generate_data_only_contract(0, &vm_config); - let large_code = generate_data_only_contract(bytesize::mb(4u64) as usize, &vm_config); + let large_code = generate_data_only_contract(bytesize::kb(1500u64) as usize, &vm_config); let small_code_len = small_code.len(); let large_code_len = large_code.len(); let cost_empty = deploy_contract_cost(ctx, small_code, Some(b"main")); - let cost_4mb = deploy_contract_cost(ctx, large_code, Some(b"main")); + let cost_15mb = deploy_contract_cost(ctx, large_code, Some(b"main")); - (cost_4mb - cost_empty) / (large_code_len - small_code_len) as u64 + (cost_15mb - cost_empty) / (large_code_len - small_code_len) as u64 } /// Base cost for a fn call action, without receipt creation or contract loading. @@ -749,7 +749,7 @@ fn action_function_call_per_byte(ctx: &mut EstimatorContext) -> GasCost { // X values below 1M have a rather high variance. Therefore, use one small X // value and two larger values to fit a curve that gets the slope about // right. - let xs = [1, 1_000_000, 4_000_000]; + let xs = [1, 1_000_000, 1_500_000]; let ys: Vec = xs .iter() .map(|&arg_len| inner_action_function_call_per_byte(ctx, arg_len as usize)) @@ -800,7 +800,7 @@ fn function_call_per_storage_byte(ctx: &mut EstimatorContext) -> GasCost { let small_code = generate_data_only_contract(0, &vm_config); let small_cost = fn_cost_in_contract(ctx, "main", &small_code, n_actions); - let large_code = generate_data_only_contract(4_000_000, &vm_config); + let large_code = generate_data_only_contract(1_000_000, &vm_config); let large_cost = fn_cost_in_contract(ctx, "main", &large_code, n_actions); large_cost.saturating_sub(&small_cost, &NonNegativeTolerance::PER_MILLE)