From 770f15337d312e40a8b56b9187a6a3965464dfab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 16 May 2022 18:54:40 +0100 Subject: [PATCH 1/6] test: add more positive tests for alt_bn128 Extra test cases were generated using go-ethereum implementation of the curves. --- runtime/near-vm-logic/src/tests/alt_bn128.rs | 54 +++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/runtime/near-vm-logic/src/tests/alt_bn128.rs b/runtime/near-vm-logic/src/tests/alt_bn128.rs index d5286d3b252..408c4b228b6 100644 --- a/runtime/near-vm-logic/src/tests/alt_bn128.rs +++ b/runtime/near-vm-logic/src/tests/alt_bn128.rs @@ -1,4 +1,5 @@ use super::{fixtures::get_context, vm_logic_builder::VMLogicBuilder}; +use bn::Group; use near_vm_errors::{HostError, VMLogicError}; use std::fmt::Write; @@ -109,12 +110,31 @@ fn test_alt_bn128_g1_multiexp() { } check_ok(&le_bytes![], &le_bytes![0x0 0x0]); + check_ok( + &le_bytes![ + 0x2d6b17489d86fcd5f91e8e92eb55081d8cb4413e408047249ef4fb5baa1b518b 0x1e4d0a30dbadd9dad40f7847c7013754ded8d0371c052d19f01453f4ae1506d7 0x1, + ], + &le_bytes![0x2d6b17489d86fcd5f91e8e92eb55081d8cb4413e408047249ef4fb5baa1b518b 0x1e4d0a30dbadd9dad40f7847c7013754ded8d0371c052d19f01453f4ae1506d7], + ); + check_ok( &le_bytes![ 0x12b453155ca3be5d0b14a4804cc39a0b4635b06d512735350cd031051644d3ec 0x2944829dcfa7dd72bb04d12e46869e6a6c8162698f9a6c35724f91f597e25fc4 0x112b450c0769c7cd80ffa552aaab2153adb5646664ee091639784a7f887411f7, 0x032b2c8b9f1e7f5e53c262ae87ccd1366df1af019f2dbfe1a58a6749ba4b923f 0x0017741cde8d55ccce3a1dac210f531d22f574885226ea46fbbce4a4c75f7ed8 0x19e4956d3cf5e04f938bc9dee72f2fcab15934c7e0450ae15afee161606b071a, ], - &le_bytes![0x2923a9d452a047e0f24ab419d7893ecbf0c32a842afd88f991a6723decba82aa 0x2e3a00f94191675c0730510133c2fca248160750d87b5157c534146d4d260b61], + &le_bytes![ + 0x2923a9d452a047e0f24ab419d7893ecbf0c32a842afd88f991a6723decba82aa 0x2e3a00f94191675c0730510133c2fca248160750d87b5157c534146d4d260b61 + ], + ); + check_ok( + &le_bytes![ + 0x26a1602aeb36e32dd1c534b1c014e920b138f4a8b87f2833ea6051c8cbd5eea2 0x01eb929f0ab6720df89837a84f2787d6d8a8bd97e0daab0576321d85143633ee 0x1, + 0x15ad51e3d708bdf9ae99a3732af9354cc7b0f2ce71832b958b3e9b0215e63578 0x231d7b68932527abdeb71488bd5c1e339306c10490d3c65f7daaa651a367c618 0x1, + 0x1302ac2f870ef22bdec4cd48058f309bcef761a7b40f78744157f3bbf25a016d 0x0c75e87050e62a4c3bf1e261da5a0f11c7ccaa090a0585365658f7a2b4b96fee 0x1, + ], + &le_bytes![ + 0x2ee5c54dee890fb79c9964f7a08c7295111990435dc3adff9fb6d63aadded21f 0x2c3fa1abf295e7df565379efcdb0398d08fc959a0a7e5d3f30118fefe9450a67 + ], ); check_err(b"XXXX", "invalid array, byte length 4, element size 96"); @@ -155,6 +175,12 @@ fn test_alt_bn128_g1_sum() { } check_ok(&le_bytes![], &le_bytes![0x0 0x0]); + check_ok( + &le_bytes![ + 0u8 0x2d6b17489d86fcd5f91e8e92eb55081d8cb4413e408047249ef4fb5baa1b518b 0x1e4d0a30dbadd9dad40f7847c7013754ded8d0371c052d19f01453f4ae1506d7, + ], + &le_bytes![0x2d6b17489d86fcd5f91e8e92eb55081d8cb4413e408047249ef4fb5baa1b518b 0x1e4d0a30dbadd9dad40f7847c7013754ded8d0371c052d19f01453f4ae1506d7,], + ); check_ok( &le_bytes![ 0u8 0x12b453155ca3be5d0b14a4804cc39a0b4635b06d512735350cd031051644d3ec 0x2944829dcfa7dd72bb04d12e46869e6a6c8162698f9a6c35724f91f597e25fc4, @@ -165,6 +191,17 @@ fn test_alt_bn128_g1_sum() { ], ); + check_ok( + &le_bytes![ + 0u8 0x26a1602aeb36e32dd1c534b1c014e920b138f4a8b87f2833ea6051c8cbd5eea2 0x01eb929f0ab6720df89837a84f2787d6d8a8bd97e0daab0576321d85143633ee, + 0u8 0x15ad51e3d708bdf9ae99a3732af9354cc7b0f2ce71832b958b3e9b0215e63578 0x231d7b68932527abdeb71488bd5c1e339306c10490d3c65f7daaa651a367c618, + 0u8 0x1302ac2f870ef22bdec4cd48058f309bcef761a7b40f78744157f3bbf25a016d 0x0c75e87050e62a4c3bf1e261da5a0f11c7ccaa090a0585365658f7a2b4b96fee, + ], + &le_bytes![ + 0x2ee5c54dee890fb79c9964f7a08c7295111990435dc3adff9fb6d63aadded21f 0x2c3fa1abf295e7df565379efcdb0398d08fc959a0a7e5d3f30118fefe9450a67 + ], + ); + check_err(&[92], "invalid array, byte length 1, element size 65"); check_err( &le_bytes![ @@ -215,6 +252,21 @@ fn test_alt_bn128_pairing_check() { ], 1, ); + check_ok( + &le_bytes![ + 0x0763111c06b5066cc812f8e058d5b82a7bc356c83a1a5ab743ea4e7163d90a75 0x041068a8ed41f6755c1ad2d30aacc3974a4fae3293aee34c7103b4c073358624 + + 0x291aea4fac742aaf8772caa00c8763d509c3d6f20d1be64d73c10d06db031a01 0x1de7a958e4adb3a128cd3b942b13bc85ee4124f0dee6f4266b39707c81c06fd4 + 0x1e2d816ba8b96e5cb444883a2b095533becb805c654418fa2c65bba533a34311 0x195dd519dc841a301a14de412c520b858c01ccc7ba0bd4177dd85d4b116416bb, + + + 0x0763111c06b5066cc812f8e058d5b82a7bc356c83a1a5ab743ea4e7163d90a75 0x041068a8ed41f6755c1ad2d30aacc3974a4fae3293aee34c7103b4c073358624 + + 0x201eef3c872a7313da79f6aa628cc9795314fbac78484fdae2eba5086755ad6d 0x204e0376b942fe92ba6e2746d07d62f5dede7b8b6e172fa89ea0c5c4ccabaa31 + 0x00e9f62300f921f5d4f2f7008aec59449a3f5e75add585ec4eccf04f5dc5b32f 0x17c150f0fb2ff472816b41868b98b9170233ee4647fe4bc41a1336c9a2c6567c + ], + 0, + ); check_err(b"XXXX", "invalid array, byte length 4, element size 192"); check_err(&le_bytes![0x0 0x0 0x0 0x0 0x0 0x0, 0x0 0x0 0x0 0x0 0x0 0x111], "invalid g2"); From ed832aee53f3bda8f56e0af77dc7d00c41ca6aac Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 16 May 2022 19:03:50 +0100 Subject: [PATCH 2/6] feat: stabilize alt_bn128 familiy of host functions --- chain/jsonrpc/res/rpc_errors_schema.json | 10 ++++- core/primitives-core/Cargo.toml | 1 - core/primitives-core/src/config.rs | 36 ++-------------- core/primitives-core/src/parameter.rs | 6 --- core/primitives-core/src/profile.rs | 12 ------ core/primitives/Cargo.toml | 5 --- ..._runtime__config_store__tests__0.json.snap | 8 +++- ...runtime__config_store__tests__42.json.snap | 8 +++- ...runtime__config_store__tests__48.json.snap | 8 +++- ...runtime__config_store__tests__49.json.snap | 8 +++- ...runtime__config_store__tests__50.json.snap | 8 +++- ...runtime__config_store__tests__52.json.snap | 8 +++- ...runtime__config_store__tests__53.json.snap | 8 +++- ...__config_store__tests__testnet_0.json.snap | 8 +++- ..._config_store__tests__testnet_42.json.snap | 8 +++- ..._config_store__tests__testnet_48.json.snap | 8 +++- ..._config_store__tests__testnet_49.json.snap | 8 +++- ..._config_store__tests__testnet_50.json.snap | 8 +++- ..._config_store__tests__testnet_52.json.snap | 8 +++- ..._config_store__tests__testnet_53.json.snap | 8 +++- core/primitives/src/version.rs | 8 ++-- integration-tests/Cargo.toml | 6 --- ...__sanity_checks__receipts_gas_profile.snap | 36 ++++++++++++++-- nearcore/Cargo.toml | 5 --- neard/Cargo.toml | 1 - .../contract-for-fuzzing-rs/src/lib.rs | 3 -- runtime/near-test-contracts/src/lib.rs | 2 +- .../test-contract-rs/Cargo.toml | 4 +- .../test-contract-rs/src/lib.rs | 8 ++-- runtime/near-vm-errors/Cargo.toml | 1 - runtime/near-vm-errors/src/lib.rs | 2 - runtime/near-vm-logic/Cargo.toml | 7 +--- runtime/near-vm-logic/src/lib.rs | 2 - runtime/near-vm-logic/src/logic.rs | 3 -- runtime/near-vm-logic/src/tests/alt_bn128.rs | 1 - runtime/near-vm-logic/src/tests/mod.rs | 1 - runtime/near-vm-runner-standalone/Cargo.toml | 5 --- runtime/near-vm-runner/Cargo.toml | 7 ---- runtime/near-vm-runner/src/imports.rs | 6 +-- runtime/near-vm-runner/src/tests/cache.rs | 28 ++++++------- .../near-vm-runner/src/tests/rs_contract.rs | 6 +-- runtime/runtime-params-estimator/Cargo.toml | 7 ---- .../src/costs_to_runtime_config.rs | 6 --- runtime/runtime-params-estimator/src/lib.rs | 42 ++++--------------- .../test-contract/Cargo.toml | 3 +- .../test-contract/src/lib.rs | 12 ------ runtime/runtime/Cargo.toml | 6 --- test-utils/testlib/Cargo.toml | 4 -- 48 files changed, 179 insertions(+), 225 deletions(-) diff --git a/chain/jsonrpc/res/rpc_errors_schema.json b/chain/jsonrpc/res/rpc_errors_schema.json index f2bfdc35fb3..a1ab234544a 100644 --- a/chain/jsonrpc/res/rpc_errors_schema.json +++ b/chain/jsonrpc/res/rpc_errors_schema.json @@ -1,5 +1,12 @@ { "schema": { + "AltBn128InvalidInput": { + "name": "AltBn128InvalidInput", + "subtypes": [], + "props": { + "msg": "" + } + }, "BadUTF16": { "name": "BadUTF16", "subtypes": [], @@ -139,7 +146,8 @@ "ReturnedValueLengthExceeded", "ContractSizeExceeded", "Deprecated", - "ECRecoverError" + "ECRecoverError", + "AltBn128InvalidInput" ], "props": {} }, diff --git a/core/primitives-core/Cargo.toml b/core/primitives-core/Cargo.toml index fe0d4c56ead..db7c292c82a 100644 --- a/core/primitives-core/Cargo.toml +++ b/core/primitives-core/Cargo.toml @@ -30,7 +30,6 @@ serde_json = "1" [features] default = [] -protocol_feature_alt_bn128 = [] protocol_feature_routing_exchange_algorithm = [] deepsize_feature = [ "deepsize", diff --git a/core/primitives-core/src/config.rs b/core/primitives-core/src/config.rs index 7fbc8df6c48..3aa262371e6 100644 --- a/core/primitives-core/src/config.rs +++ b/core/primitives-core/src/config.rs @@ -400,22 +400,16 @@ pub struct ExtCostsConfig { // # Alt BN128 # // ############# /// Base cost for multiexp - #[cfg(feature = "protocol_feature_alt_bn128")] pub alt_bn128_g1_multiexp_base: Gas, - /// byte cost for multiexp - #[cfg(feature = "protocol_feature_alt_bn128")] + /// Per element cost for multiexp pub alt_bn128_g1_multiexp_element: Gas, /// Base cost for sum - #[cfg(feature = "protocol_feature_alt_bn128")] pub alt_bn128_g1_sum_base: Gas, - /// byte cost for sum - #[cfg(feature = "protocol_feature_alt_bn128")] + /// Per element byte for sum pub alt_bn128_g1_sum_element: Gas, /// Base cost for pairing check - #[cfg(feature = "protocol_feature_alt_bn128")] pub alt_bn128_pairing_check_base: Gas, - /// Cost for pairing check per byte - #[cfg(feature = "protocol_feature_alt_bn128")] + /// Per element cost for pairing check pub alt_bn128_pairing_check_element: Gas, } @@ -488,17 +482,11 @@ impl ExtCostsConfig { validator_total_stake_base: SAFETY_MULTIPLIER * 303944908800, _unused1: 0, _unused2: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_base: 713_000_000_000, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_element: 320_000_000_000, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_base: 9_686_000_000_000, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_element: 5_102_000_000_000, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_base: 3_000_000_000, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_element: 5_000_000_000, } } @@ -560,17 +548,11 @@ impl ExtCostsConfig { validator_total_stake_base: 0, _unused1: 0, _unused2: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_base: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_element: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_base: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_element: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_base: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_element: 0, } } @@ -633,17 +615,11 @@ pub enum ExtCosts { promise_return, validator_stake_base, validator_total_stake_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_element, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_element, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_element, } @@ -720,17 +696,11 @@ impl ExtCosts { promise_return => config.promise_return, validator_stake_base => config.validator_stake_base, validator_total_stake_base => config.validator_total_stake_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_base => config.alt_bn128_g1_multiexp_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_element => config.alt_bn128_g1_multiexp_element, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_base => config.alt_bn128_pairing_check_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_element => config.alt_bn128_pairing_check_element, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_base => config.alt_bn128_g1_sum_base, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_element => config.alt_bn128_g1_sum_element, } } diff --git a/core/primitives-core/src/parameter.rs b/core/primitives-core/src/parameter.rs index 7075fc19e76..2099a33aac3 100644 --- a/core/primitives-core/src/parameter.rs +++ b/core/primitives-core/src/parameter.rs @@ -264,17 +264,11 @@ impl Parameter { Parameter::WasmPromiseReturn, Parameter::WasmValidatorStakeBase, Parameter::WasmValidatorTotalStakeBase, - #[cfg(feature = "protocol_feature_alt_bn128")] Parameter::WasmAltBn128G1MultiexpBase, - #[cfg(feature = "protocol_feature_alt_bn128")] Parameter::WasmAltBn128G1MultiexpElement, - #[cfg(feature = "protocol_feature_alt_bn128")] Parameter::WasmAltBn128PairingCheckBase, - #[cfg(feature = "protocol_feature_alt_bn128")] Parameter::WasmAltBn128PairingCheckElement, - #[cfg(feature = "protocol_feature_alt_bn128")] Parameter::WasmAltBn128G1SumBase, - #[cfg(feature = "protocol_feature_alt_bn128")] Parameter::WasmAltBn128G1SumElement, ] .iter() diff --git a/core/primitives-core/src/profile.rs b/core/primitives-core/src/profile.rs index 0714a2c69ce..004c07dc5d2 100644 --- a/core/primitives-core/src/profile.rs +++ b/core/primitives-core/src/profile.rs @@ -246,17 +246,11 @@ impl Cost { Cost::ExtCost { ext_cost_kind: ExtCosts::validator_stake_base }, Cost::ExtCost { ext_cost_kind: ExtCosts::validator_total_stake_base }, Cost::WasmInstruction, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_multiexp_base }, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_multiexp_element }, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_pairing_check_base }, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_pairing_check_element }, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_sum_base }, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_sum_element }, ]; @@ -326,17 +320,11 @@ impl Cost { Cost::ExtCost { ext_cost_kind: ExtCosts::validator_total_stake_base } => 61, Cost::WasmInstruction => 62, Cost::ExtCost { ext_cost_kind: ExtCosts::read_cached_trie_node } => 63, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_multiexp_base } => 64, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_multiexp_element } => 65, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_pairing_check_base } => 66, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_pairing_check_element } => 67, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_sum_base } => 68, - #[cfg(feature = "protocol_feature_alt_bn128")] Cost::ExtCost { ext_cost_kind: ExtCosts::alt_bn128_g1_sum_element } => 69, } } diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index 56fec040956..6025ef80081 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -40,17 +40,12 @@ near-rpc-error-macro = { path = "../../tools/rpctypegen/macro" } [features] dump_errors_schema = ["near-rpc-error-macro/dump_errors_schema"] -protocol_feature_alt_bn128 = [ - "near-primitives-core/protocol_feature_alt_bn128", - "near-vm-errors/protocol_feature_alt_bn128", -] protocol_feature_chunk_only_producers = [] protocol_feature_routing_exchange_algorithm = ["near-primitives-core/protocol_feature_routing_exchange_algorithm"] protocol_feature_access_key_nonce_for_implicit_accounts = [] protocol_feature_fix_staking_threshold = [] nightly = [ "nightly_protocol", - "protocol_feature_alt_bn128", "protocol_feature_chunk_only_producers", "protocol_feature_routing_exchange_algorithm", "protocol_feature_access_key_nonce_for_implicit_accounts", diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__0.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__0.json.snap index 35e26b534b8..4de3f97bcc6 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__0.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__0.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 3856371, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__42.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__42.json.snap index 001b46e0119..0a66808e8bf 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__42.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__42.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 3856371, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__48.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__48.json.snap index debe1b587f6..22eccefc668 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__48.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__48.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 2207874, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__49.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__49.json.snap index 57629bcfb61..269da95b382 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__49.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__49.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__50.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__50.json.snap index 0a5a9080689..f5d540f29ca 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__50.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__50.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__52.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__52.json.snap index d6cf45f9493..e0620e82b23 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__52.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__52.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__53.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__53.json.snap index 057ff4114b3..125a6d0949d 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__53.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__53.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_0.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_0.json.snap index 35e26b534b8..4de3f97bcc6 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_0.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_0.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 3856371, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_42.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_42.json.snap index 001b46e0119..0a66808e8bf 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_42.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_42.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 3856371, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_48.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_48.json.snap index debe1b587f6..22eccefc668 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_48.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_48.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 2207874, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_49.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_49.json.snap index 57629bcfb61..269da95b382 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_49.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_49.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_50.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_50.json.snap index 0a5a9080689..f5d540f29ca 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_50.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_50.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_52.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_52.json.snap index d6cf45f9493..e0620e82b23 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_52.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_52.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_53.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_53.json.snap index 057ff4114b3..125a6d0949d 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_53.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_53.json.snap @@ -155,7 +155,13 @@ expression: store.get_config(*version) "validator_stake_base": 911834726400, "validator_total_stake_base": 911834726400, "contract_compile_base": 0, - "contract_compile_bytes": 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 }, "grow_mem_cost": 1, "regular_op_cost": 822756, diff --git a/core/primitives/src/version.rs b/core/primitives/src/version.rs index cffd064e473..a4f04fab415 100644 --- a/core/primitives/src/version.rs +++ b/core/primitives/src/version.rs @@ -149,10 +149,9 @@ pub enum ProtocolFeature { ChunkNodesCache, /// Lower `max_length_storage_key` limit, which itself limits trie node sizes. LowerStorageKeyLimit, - - // nightly features - #[cfg(feature = "protocol_feature_alt_bn128")] + // alt_bn128_g1_multiexp, alt_bn128_g1_sum, alt_bn128_pairing_check host functions AltBn128, + #[cfg(feature = "protocol_feature_chunk_only_producers")] ChunkOnlyProducers, #[cfg(feature = "protocol_feature_routing_exchange_algorithm")] @@ -233,10 +232,9 @@ impl ProtocolFeature { | ProtocolFeature::LimitContractLocals | ProtocolFeature::ChunkNodesCache | ProtocolFeature::LowerStorageKeyLimit => 53, + ProtocolFeature::AltBn128 => 54, // Nightly features - #[cfg(feature = "protocol_feature_alt_bn128")] - ProtocolFeature::AltBn128 => 105, #[cfg(feature = "protocol_feature_chunk_only_producers")] ProtocolFeature::ChunkOnlyProducers => 124, #[cfg(feature = "protocol_feature_routing_exchange_algorithm")] diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index d2e7061b2e3..abec13e44d5 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -67,11 +67,6 @@ performance_stats = [ ] expensive_tests = [] test_features = ["nearcore/test_features"] -protocol_feature_alt_bn128 = [ - "near-primitives/protocol_feature_alt_bn128", - "node-runtime/protocol_feature_alt_bn128", - "near-vm-errors/protocol_feature_alt_bn128", -] protocol_feature_chunk_only_producers = [ "near-client/protocol_feature_chunk_only_producers", "near-primitives/protocol_feature_chunk_only_producers", @@ -83,7 +78,6 @@ protocol_feature_access_key_nonce_for_implicit_accounts = [ nightly = [ "nightly_protocol", "nearcore/nightly", - "protocol_feature_alt_bn128", "protocol_feature_chunk_only_producers", "protocol_feature_access_key_nonce_for_implicit_accounts", ] 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 fb3a427b134..84348ace8f8 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 @@ -49,6 +49,36 @@ expression: receipts_gas_profile cost: "TRANSFER", gas_used: 230246125000, }, + CostGasUsed { + cost_category: "WASM_HOST_COST", + cost: "ALT_BN128_G1_MULTIEXP_BASE", + gas_used: 713000000000, + }, + CostGasUsed { + cost_category: "WASM_HOST_COST", + cost: "ALT_BN128_G1_MULTIEXP_ELEMENT", + gas_used: 320000000000, + }, + CostGasUsed { + cost_category: "WASM_HOST_COST", + cost: "ALT_BN128_G1_SUM_BASE", + gas_used: 3000000000, + }, + CostGasUsed { + cost_category: "WASM_HOST_COST", + cost: "ALT_BN128_G1_SUM_ELEMENT", + gas_used: 5000000000, + }, + CostGasUsed { + cost_category: "WASM_HOST_COST", + cost: "ALT_BN128_PAIRING_CHECK_BASE", + gas_used: 9686000000000, + }, + CostGasUsed { + cost_category: "WASM_HOST_COST", + cost: "ALT_BN128_PAIRING_CHECK_ELEMENT", + gas_used: 5102000000000, + }, CostGasUsed { cost_category: "WASM_HOST_COST", cost: "BASE", @@ -97,12 +127,12 @@ expression: receipts_gas_profile CostGasUsed { cost_category: "WASM_HOST_COST", cost: "READ_MEMORY_BASE", - gas_used: 174860834400, + gas_used: 182690424000, }, CostGasUsed { cost_category: "WASM_HOST_COST", cost: "READ_MEMORY_BYTE", - gas_used: 3402193035, + gas_used: 4744063584, }, CostGasUsed { cost_category: "WASM_HOST_COST", @@ -247,7 +277,7 @@ expression: receipts_gas_profile CostGasUsed { cost_category: "WASM_HOST_COST", cost: "WRITE_REGISTER_BASE", - gas_used: 31520747346, + gas_used: 37251792318, }, CostGasUsed { cost_category: "WASM_HOST_COST", diff --git a/nearcore/Cargo.toml b/nearcore/Cargo.toml index f79a15708b5..66e2e138237 100644 --- a/nearcore/Cargo.toml +++ b/nearcore/Cargo.toml @@ -104,10 +104,6 @@ no_cache = [ delay_detector = ["near-client/delay_detector", "delay-detector/delay_detector"] rosetta_rpc = ["near-rosetta-rpc"] json_rpc = ["near-jsonrpc"] -protocol_feature_alt_bn128 = [ - "near-primitives/protocol_feature_alt_bn128", - "node-runtime/protocol_feature_alt_bn128", -] protocol_feature_chunk_only_producers = [ "near-chain-configs/protocol_feature_chunk_only_producers", "near-epoch-manager/protocol_feature_chunk_only_producers", @@ -138,7 +134,6 @@ nightly = [ "near-client/nightly", "near-epoch-manager/nightly", "near-store/nightly", - "protocol_feature_alt_bn128", "protocol_feature_chunk_only_producers", "protocol_feature_routing_exchange_algorithm", "protocol_feature_access_key_nonce_for_implicit_accounts", diff --git a/neard/Cargo.toml b/neard/Cargo.toml index 7fbac7084ab..1a4c769eb37 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -58,7 +58,6 @@ no_cache = ["nearcore/no_cache"] delay_detector = ["nearcore/delay_detector"] rosetta_rpc = ["nearcore/rosetta_rpc"] json_rpc = ["nearcore/json_rpc"] -protocol_feature_alt_bn128 = ["nearcore/protocol_feature_alt_bn128"] protocol_feature_chunk_only_producers = [ "nearcore/protocol_feature_chunk_only_producers", "near-primitives/protocol_feature_chunk_only_producers", diff --git a/runtime/near-test-contracts/contract-for-fuzzing-rs/src/lib.rs b/runtime/near-test-contracts/contract-for-fuzzing-rs/src/lib.rs index 915857968e5..62725d420a1 100644 --- a/runtime/near-test-contracts/contract-for-fuzzing-rs/src/lib.rs +++ b/runtime/near-test-contracts/contract-for-fuzzing-rs/src/lib.rs @@ -146,11 +146,8 @@ extern "C" { // ################# // # alt_bn128 API # // ################# - #[cfg(feature = "protocol_feature_alt_bn128")] fn alt_bn128_g1_multiexp(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_alt_bn128")] fn alt_bn128_g1_sum(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_alt_bn128")] fn alt_bn128_pairing_check(value_len: u64, value_ptr: u64) -> u64; } diff --git a/runtime/near-test-contracts/src/lib.rs b/runtime/near-test-contracts/src/lib.rs index e4b4e214340..62d9ce36f5e 100644 --- a/runtime/near-test-contracts/src/lib.rs +++ b/runtime/near-test-contracts/src/lib.rs @@ -167,7 +167,7 @@ pub fn arbitrary_contract(seed: u64) -> Vec { config.exceptions_enabled = false; config.saturating_float_to_int_enabled = false; config.sign_extension_enabled = false; - config.available_imports = Some(rs_contract().to_vec()); + config.available_imports = Some(base_rs_contract().to_vec()); let module = wasm_smith::Module::new(config, &mut arbitrary).expect("generate module"); module.to_bytes() } diff --git a/runtime/near-test-contracts/test-contract-rs/Cargo.toml b/runtime/near-test-contracts/test-contract-rs/Cargo.toml index 83669d7a21c..cede0f4aad0 100644 --- a/runtime/near-test-contracts/test-contract-rs/Cargo.toml +++ b/runtime/near-test-contracts/test-contract-rs/Cargo.toml @@ -31,7 +31,5 @@ incremental = false members = [] [features] -nightly = ["protocol_feature_alt_bn128"] -protocol_feature_alt_bn128 = [] -protocol_feature_function_call_weight = [] +nightly = [] latest_protocol = [] diff --git a/runtime/near-test-contracts/test-contract-rs/src/lib.rs b/runtime/near-test-contracts/test-contract-rs/src/lib.rs index c1af38340ae..8ddaf2ea44a 100644 --- a/runtime/near-test-contracts/test-contract-rs/src/lib.rs +++ b/runtime/near-test-contracts/test-contract-rs/src/lib.rs @@ -166,11 +166,11 @@ extern "C" { // ################# // # alt_bn128 API # // ################# - #[cfg(feature = "protocol_feature_alt_bn128")] + #[cfg(feature = "latest_protocol")] fn alt_bn128_g1_multiexp(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_alt_bn128")] + #[cfg(feature = "latest_protocol")] fn alt_bn128_g1_sum(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_alt_bn128")] + #[cfg(feature = "latest_protocol")] fn alt_bn128_pairing_check(value_len: u64, value_ptr: u64) -> u64; } @@ -1191,7 +1191,7 @@ pub unsafe fn sanity_check() { // ################# // # alt_bn128 API # // ################# - #[cfg(feature = "protocol_feature_alt_bn128")] + #[cfg(feature = "latest_protocol")] { let buffer: [u8; 96] = [ 16, 238, 91, 161, 241, 22, 172, 158, 138, 252, 202, 212, 136, 37, 110, 231, 118, 220, diff --git a/runtime/near-vm-errors/Cargo.toml b/runtime/near-vm-errors/Cargo.toml index 261bcac9884..2ddcfff0bde 100644 --- a/runtime/near-vm-errors/Cargo.toml +++ b/runtime/near-vm-errors/Cargo.toml @@ -24,7 +24,6 @@ near-rpc-error-macro = { path = "../../tools/rpctypegen/macro" } [features] dump_errors_schema = ["near-rpc-error-macro/dump_errors_schema"] -protocol_feature_alt_bn128 = [] deepsize_feature = [ "deepsize", "near-account-id/deepsize_feature", diff --git a/runtime/near-vm-errors/src/lib.rs b/runtime/near-vm-errors/src/lib.rs index f8b14062eab..dcb0036908c 100644 --- a/runtime/near-vm-errors/src/lib.rs +++ b/runtime/near-vm-errors/src/lib.rs @@ -223,7 +223,6 @@ pub enum HostError { ECRecoverError { msg: String }, /// Invalid input to alt_bn128 familiy of functions (e.g., point which isn't /// on the curve). - #[cfg(feature = "protocol_feature_alt_bn128")] AltBn128InvalidInput { msg: String }, } @@ -420,7 +419,6 @@ impl std::fmt::Display for HostError { ReturnedValueLengthExceeded { length, limit } => write!(f, "The length of a returned value {} exceeds the limit {}", length, limit), ContractSizeExceeded { size, limit } => write!(f, "The size of a contract code in DeployContract action {} exceeds the limit {}", size, limit), Deprecated {method_name}=> write!(f, "Attempted to call deprecated host function {}", method_name), - #[cfg(feature = "protocol_feature_alt_bn128")] AltBn128InvalidInput { msg } => write!(f, "AltBn128 invalid input: {}", msg), ECRecoverError { msg } => write!(f, "ECDSA recover error: {}", msg), } diff --git a/runtime/near-vm-logic/Cargo.toml b/runtime/near-vm-logic/Cargo.toml index f69875d1b3d..5af666de113 100644 --- a/runtime/near-vm-logic/Cargo.toml +++ b/runtime/near-vm-logic/Cargo.toml @@ -30,7 +30,7 @@ near-primitives = { path = "../../core/primitives" } near-primitives-core = { path = "../../core/primitives-core" } near-vm-errors = { path = "../near-vm-errors" } -bn = { package = "zeropool-bn", version = "0.5.11", features = [], optional = true } +bn = { package = "zeropool-bn", version = "0.5.11", features = [] } tracing = { version = "0.1.13", optional = true} [dev-dependencies] @@ -39,11 +39,6 @@ serde_json = { version = "1", features = ["preserve_order"] } [features] default = [] -protocol_feature_alt_bn128 = [ - "bn", - "near-primitives-core/protocol_feature_alt_bn128", - "near-vm-errors/protocol_feature_alt_bn128", -] # Use this feature to enable counting of fees and costs applied. costs_counting = [] diff --git a/runtime/near-vm-logic/src/lib.rs b/runtime/near-vm-logic/src/lib.rs index 0791f29cb8d..8875be22c12 100644 --- a/runtime/near-vm-logic/src/lib.rs +++ b/runtime/near-vm-logic/src/lib.rs @@ -1,8 +1,6 @@ #![doc = include_str!("../README.md")] -#[cfg(feature = "protocol_feature_alt_bn128")] mod alt_bn128; -#[cfg(feature = "protocol_feature_alt_bn128")] mod array_utils; mod context; mod dependencies; diff --git a/runtime/near-vm-logic/src/logic.rs b/runtime/near-vm-logic/src/logic.rs index 37062991763..a1e0e2a5539 100644 --- a/runtime/near-vm-logic/src/logic.rs +++ b/runtime/near-vm-logic/src/logic.rs @@ -817,7 +817,6 @@ impl<'a> VMLogic<'a> { /// `base + write_register_base + write_register_byte * num_bytes + /// alt_bn128_g1_multiexp_base + /// alt_bn128_g1_multiexp_element * num_elements` - #[cfg(feature = "protocol_feature_alt_bn128")] pub fn alt_bn128_g1_multiexp( &mut self, value_len: u64, @@ -861,7 +860,6 @@ impl<'a> VMLogic<'a> { /// /// `base + write_register_base + write_register_byte * num_bytes + /// alt_bn128_g1_sum_base + alt_bn128_g1_sum_element * num_elements` - #[cfg(feature = "protocol_feature_alt_bn128")] pub fn alt_bn128_g1_sum( &mut self, value_len: u64, @@ -906,7 +904,6 @@ impl<'a> VMLogic<'a> { /// # Cost /// /// `base + write_register_base + write_register_byte * num_bytes + alt_bn128_pairing_base + alt_bn128_pairing_element * num_elements` - #[cfg(feature = "protocol_feature_alt_bn128")] pub fn alt_bn128_pairing_check(&mut self, value_len: u64, value_ptr: u64) -> Result { self.gas_counter.pay_base(alt_bn128_pairing_check_base)?; let data = self.get_vec_from_memory_or_register(value_ptr, value_len)?; diff --git a/runtime/near-vm-logic/src/tests/alt_bn128.rs b/runtime/near-vm-logic/src/tests/alt_bn128.rs index 408c4b228b6..280ac487ed0 100644 --- a/runtime/near-vm-logic/src/tests/alt_bn128.rs +++ b/runtime/near-vm-logic/src/tests/alt_bn128.rs @@ -1,5 +1,4 @@ use super::{fixtures::get_context, vm_logic_builder::VMLogicBuilder}; -use bn::Group; use near_vm_errors::{HostError, VMLogicError}; use std::fmt::Write; diff --git a/runtime/near-vm-logic/src/tests/mod.rs b/runtime/near-vm-logic/src/tests/mod.rs index 51862f24658..3085d8fe4d0 100644 --- a/runtime/near-vm-logic/src/tests/mod.rs +++ b/runtime/near-vm-logic/src/tests/mod.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "protocol_feature_alt_bn128")] mod alt_bn128; mod context; mod fixtures; diff --git a/runtime/near-vm-runner-standalone/Cargo.toml b/runtime/near-vm-runner-standalone/Cargo.toml index 167b2cce031..14f20cebd27 100644 --- a/runtime/near-vm-runner-standalone/Cargo.toml +++ b/runtime/near-vm-runner-standalone/Cargo.toml @@ -40,13 +40,8 @@ near-test-contracts = { path = "../near-test-contracts" } [features] default = [] no_cache = ["near-vm-runner/no_cache"] -protocol_feature_alt_bn128 = [ - "near-vm-logic/protocol_feature_alt_bn128", - "near-vm-runner/protocol_feature_alt_bn128", -] nightly = [ "nightly_protocol", "near-primitives/nightly", - "protocol_feature_alt_bn128", ] nightly_protocol = ["near-primitives/nightly_protocol"] diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index c7e900c9fe5..2c7bdc1b382 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -92,15 +92,8 @@ no_cpu_compatibility_checks = [] no_cache = [] -protocol_feature_alt_bn128 = [ - "near-vm-logic/protocol_feature_alt_bn128", - "near-primitives/protocol_feature_alt_bn128", - "near-vm-errors/protocol_feature_alt_bn128" -] - nightly = [ "near-primitives/nightly", - "protocol_feature_alt_bn128", ] sandbox = ["near-vm-logic/sandbox"] diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 3fbafe09d3e..ce27f40d342 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -225,9 +225,9 @@ imports! { // ############# // # Alt BN128 # // ############# - #["protocol_feature_alt_bn128", AltBn128] alt_bn128_g1_multiexp<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, - #["protocol_feature_alt_bn128", AltBn128] alt_bn128_g1_sum<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, - #["protocol_feature_alt_bn128", AltBn128] alt_bn128_pairing_check<[value_len: u64, value_ptr: u64] -> [u64]>, + #[AltBn128] alt_bn128_g1_multiexp<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, + #[AltBn128] alt_bn128_g1_sum<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, + #[AltBn128] alt_bn128_pairing_check<[value_len: u64, value_ptr: u64] -> [u64]>, // ############# // # Sandbox # // ############# diff --git a/runtime/near-vm-runner/src/tests/cache.rs b/runtime/near-vm-runner/src/tests/cache.rs index 68a36b08f02..02df020bfe0 100644 --- a/runtime/near-vm-runner/src/tests/cache.rs +++ b/runtime/near-vm-runner/src/tests/cache.rs @@ -105,23 +105,23 @@ fn test_wasmer2_artifact_output_stability() { // fall through the cracks here, but hopefully it should catch most of the fish just fine. let seeds = [2, 3, 5, 7, 11, 13, 17]; let prepared_hashes = [ - 5920482302426237644, - 4305202105567340810, - 5775536517394665889, - 6282866610476321669, - 9987754974020503265, - 2522443647498253022, - 1434775828544411571, + 12248437801724644735, + 2647244875869025389, + 892153519407678490, + 8592050243596620350, + 2309330154575012917, + 9323529151210819831, + 11488755771702465226, ]; let mut got_prepared_hashes = Vec::with_capacity(seeds.len()); let compiled_hashes = [ - 4678798493694903297, - 4722680261811640693, - 7795642610370765019, - 15143423944524767029, - 7504125870827587271, - 3662584175683490815, - 13449186496170384379, + 5827744486935367002, + 3163481497450515654, + 12932669301919595047, + 4509630115775888919, + 5285162149441033812, + 15892844827657184765, + 7871022777077203514, ]; let mut got_compiled_hashes = Vec::with_capacity(seeds.len()); for seed in seeds { diff --git a/runtime/near-vm-runner/src/tests/rs_contract.rs b/runtime/near-vm-runner/src/tests/rs_contract.rs index 7f30eddf708..4e12c2fd936 100644 --- a/runtime/near-vm-runner/src/tests/rs_contract.rs +++ b/runtime/near-vm-runner/src/tests/rs_contract.rs @@ -18,11 +18,7 @@ use crate::vm_kind::VMKind; use crate::VMResult; fn test_contract() -> ContractCode { - let code = if cfg!(feature = "protocol_feature_alt_bn128") { - near_test_contracts::nightly_rs_contract() - } else { - near_test_contracts::rs_contract() - }; + let code = near_test_contracts::rs_contract(); ContractCode::new(code.to_vec(), None) } diff --git a/runtime/runtime-params-estimator/Cargo.toml b/runtime/runtime-params-estimator/Cargo.toml index 8e51081997d..70b027e5102 100644 --- a/runtime/runtime-params-estimator/Cargo.toml +++ b/runtime/runtime-params-estimator/Cargo.toml @@ -61,13 +61,6 @@ no_cache = [ wasmtime = ["near-vm-runner/force_wasmtime"] nightly = [ "nightly_protocol", - "protocol_feature_alt_bn128" ] nightly_protocol = ["near-primitives/nightly_protocol"] -protocol_feature_alt_bn128 = [ - "near-vm-logic/protocol_feature_alt_bn128", - "near-vm-runner/protocol_feature_alt_bn128", - "node-runtime/protocol_feature_alt_bn128", - "nearcore/protocol_feature_alt_bn128", -] sandbox = ["node-runtime/sandbox"] diff --git a/runtime/runtime-params-estimator/src/costs_to_runtime_config.rs b/runtime/runtime-params-estimator/src/costs_to_runtime_config.rs index d12d064c601..a4655421450 100644 --- a/runtime/runtime-params-estimator/src/costs_to_runtime_config.rs +++ b/runtime/runtime-params-estimator/src/costs_to_runtime_config.rs @@ -148,17 +148,11 @@ fn ext_costs_config(cost_table: &CostTable) -> anyhow::Result { validator_total_stake_base: 303944908800, _unused1: 0, _unused2: 0, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_base: get(Cost::AltBn128G1SumBase)?, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_sum_element: get(Cost::AltBn128G1SumElement)?, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_base: get(Cost::AltBn128G1MultiexpBase)?, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_element: get(Cost::AltBn128G1MultiexpElement)?, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_base: get(Cost::AltBn128PairingCheckBase)?, - #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_pairing_check_element: get(Cost::AltBn128PairingCheckElement)?, }; diff --git a/runtime/runtime-params-estimator/src/lib.rs b/runtime/runtime-params-estimator/src/lib.rs index c2e526e6d2f..5738278b324 100644 --- a/runtime/runtime-params-estimator/src/lib.rs +++ b/runtime/runtime-params-estimator/src/lib.rs @@ -899,57 +899,29 @@ fn ecrecover_base(ctx: &mut EstimatorContext) -> GasCost { } fn alt_bn128g1_multiexp_base(ctx: &mut EstimatorContext) -> GasCost { - #[cfg(feature = "protocol_feature_alt_bn128")] - return fn_cost(ctx, "alt_bn128_g1_multiexp_1_10", ExtCosts::alt_bn128_g1_multiexp_base, 10); - #[cfg(not(feature = "protocol_feature_alt_bn128"))] - return GasCost::zero(ctx.config.metric); + fn_cost(ctx, "alt_bn128_g1_multiexp_1_10", ExtCosts::alt_bn128_g1_multiexp_base, 10) } fn alt_bn128g1_multiexp_element(ctx: &mut EstimatorContext) -> GasCost { - #[cfg(feature = "protocol_feature_alt_bn128")] - return fn_cost( - ctx, - "alt_bn128_g1_multiexp_10_10", - ExtCosts::alt_bn128_g1_multiexp_element, - 10 * 10, - ); - #[cfg(not(feature = "protocol_feature_alt_bn128"))] - return GasCost::zero(ctx.config.metric); + fn_cost(ctx, "alt_bn128_g1_multiexp_10_10", ExtCosts::alt_bn128_g1_multiexp_element, 10 * 10) } fn alt_bn128g1_sum_base(ctx: &mut EstimatorContext) -> GasCost { - #[cfg(feature = "protocol_feature_alt_bn128")] - return fn_cost(ctx, "alt_bn128_g1_sum_1_1k", ExtCosts::alt_bn128_g1_sum_base, 1000); - #[cfg(not(feature = "protocol_feature_alt_bn128"))] - return GasCost::zero(ctx.config.metric); + fn_cost(ctx, "alt_bn128_g1_sum_1_1k", ExtCosts::alt_bn128_g1_sum_base, 1000) } fn alt_bn128g1_sum_element(ctx: &mut EstimatorContext) -> GasCost { - #[cfg(feature = "protocol_feature_alt_bn128")] - return fn_cost(ctx, "alt_bn128_g1_sum_10_1k", ExtCosts::alt_bn128_g1_sum_element, 10 * 1000); - #[cfg(not(feature = "protocol_feature_alt_bn128"))] - return GasCost::zero(ctx.config.metric); + fn_cost(ctx, "alt_bn128_g1_sum_10_1k", ExtCosts::alt_bn128_g1_sum_element, 10 * 1000) } fn alt_bn128_pairing_check_base(ctx: &mut EstimatorContext) -> GasCost { - #[cfg(feature = "protocol_feature_alt_bn128")] - return fn_cost( - ctx, - "alt_bn128_pairing_check_1_10", - ExtCosts::alt_bn128_pairing_check_base, - 10, - ); - #[cfg(not(feature = "protocol_feature_alt_bn128"))] - return GasCost::zero(ctx.config.metric); + fn_cost(ctx, "alt_bn128_pairing_check_1_10", ExtCosts::alt_bn128_pairing_check_base, 10) } fn alt_bn128_pairing_check_element(ctx: &mut EstimatorContext) -> GasCost { - #[cfg(feature = "protocol_feature_alt_bn128")] - return fn_cost( + fn_cost( ctx, "alt_bn128_pairing_check_10_10", ExtCosts::alt_bn128_pairing_check_element, 10 * 10, - ); - #[cfg(not(feature = "protocol_feature_alt_bn128"))] - return GasCost::zero(ctx.config.metric); + ) } fn storage_has_key_base(ctx: &mut EstimatorContext) -> GasCost { diff --git a/runtime/runtime-params-estimator/test-contract/Cargo.toml b/runtime/runtime-params-estimator/test-contract/Cargo.toml index c7aeab9657e..63dfa572d66 100644 --- a/runtime/runtime-params-estimator/test-contract/Cargo.toml +++ b/runtime/runtime-params-estimator/test-contract/Cargo.toml @@ -23,7 +23,6 @@ panic = "abort" members = [] [features] -nightly = ["protocol_feature_alt_bn128"] -protocol_feature_alt_bn128 = [] +nightly = [] payload = [] diff --git a/runtime/runtime-params-estimator/test-contract/src/lib.rs b/runtime/runtime-params-estimator/test-contract/src/lib.rs index ca57ca50d4a..35d838957a0 100644 --- a/runtime/runtime-params-estimator/test-contract/src/lib.rs +++ b/runtime/runtime-params-estimator/test-contract/src/lib.rs @@ -37,11 +37,8 @@ extern "C" { // ############ // # Math API # // ############ - #[cfg(feature = "protocol_feature_alt_bn128")] fn alt_bn128_g1_multiexp(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_alt_bn128")] fn alt_bn128_g1_sum(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_alt_bn128")] fn alt_bn128_pairing_check(value_len: u64, value_ptr: u64) -> u64; fn random_seed(register_id: u64); fn sha256(value_len: u64, value_ptr: u64, register_id: u64); @@ -482,14 +479,12 @@ pub unsafe fn ecrecover_10k() { } #[repr(C)] -#[cfg(feature = "protocol_feature_alt_bn128")] struct MultiexpElem([u8; 64], [u8; 32]); // Function to measure `alt_bn128_g1_multiexp_base` and `alt_bn128_g1_multiexp_sublinear`. Also measures `base`, `write_register_base`, // and `write_register_byte`. However `g1_multiexp` computation is more expensive than register writing // so we are okay overcharging it. // Compute g1_multiexp on 1 element 10 times. -#[cfg(feature = "protocol_feature_alt_bn128")] #[no_mangle] pub unsafe fn alt_bn128_g1_multiexp_1_10() { #[rustfmt::skip] @@ -509,7 +504,6 @@ pub unsafe fn alt_bn128_g1_multiexp_1_10() { // and `write_register_byte`. However `g1_multiexp` computation is more expensive than register writing // so we are okay overcharging it. // Compute g1_multiexp on 10 elements 10 times. -#[cfg(feature = "protocol_feature_alt_bn128")] #[no_mangle] pub unsafe fn alt_bn128_g1_multiexp_10_10() { #[rustfmt::skip] @@ -545,14 +539,12 @@ pub unsafe fn alt_bn128_g1_multiexp_10_10() { } #[repr(C)] -#[cfg(feature = "protocol_feature_alt_bn128")] struct SumElem(u8, [u8; 64]); // Function to measure `alt_bn128_g1_sum_base` and `alt_bn128_g1_sum_element`. Also measures `base`, `write_register_base`, // and `write_register_byte`. However `g1_sum` computation is more expensive than register writing // so we are okay overcharging it. // Compute g1_sum on 1 element 1k times. -#[cfg(feature = "protocol_feature_alt_bn128")] #[no_mangle] pub unsafe fn alt_bn128_g1_sum_1_1k() { #[rustfmt::skip] @@ -572,7 +564,6 @@ pub unsafe fn alt_bn128_g1_sum_1_1k() { // and `write_register_byte`. However `g1_sum` computation is more expensive than register writing // so we are okay overcharging it. // Compute g1_sum on 10 element 1k times. -#[cfg(feature = "protocol_feature_alt_bn128")] #[no_mangle] pub unsafe fn alt_bn128_g1_sum_10_1k() { #[rustfmt::skip] @@ -598,14 +589,12 @@ pub unsafe fn alt_bn128_g1_sum_10_1k() { } #[repr(C)] -#[cfg(feature = "protocol_feature_alt_bn128")] struct PairingElem([u8; 64], [u8; 128]); // Function to measure `alt_bn128_pairing_check_base` and `alt_bn128_pairing_check_element`. Also measures `base`, `write_register_base`, // and `write_register_byte`. However `g1_multiexp` computation is more expensive than register writing // so we are okay overcharging it. // Compute pairing_check on 1 element 10 times. -#[cfg(feature = "protocol_feature_alt_bn128")] #[no_mangle] pub unsafe fn alt_bn128_pairing_check_1_10() { #[rustfmt::skip] @@ -624,7 +613,6 @@ pub unsafe fn alt_bn128_pairing_check_1_10() { // and `write_register_byte`. However `g1_multiexp` computation is more expensive than register writing // so we are okay overcharging it. // Compute pairing_check on 10 elements 10 times. -#[cfg(feature = "protocol_feature_alt_bn128")] #[no_mangle] pub unsafe fn alt_bn128_pairing_check_10_10() { #[rustfmt::skip] diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index 3f31a13b908..572ed16d544 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -49,12 +49,6 @@ no_cache = [ "near-store/no_cache", ] -protocol_feature_alt_bn128 = [ - "near-primitives/protocol_feature_alt_bn128", - "near-vm-logic/protocol_feature_alt_bn128", - "near-vm-runner/protocol_feature_alt_bn128", - "near-vm-errors/protocol_feature_alt_bn128", -] sandbox = ["near-vm-logic/sandbox", "near-vm-runner/sandbox"] [dev-dependencies] diff --git a/test-utils/testlib/Cargo.toml b/test-utils/testlib/Cargo.toml index fb58d311b6d..f3fad8d5b3d 100644 --- a/test-utils/testlib/Cargo.toml +++ b/test-utils/testlib/Cargo.toml @@ -19,9 +19,6 @@ near-test-contracts = { path = "../../runtime/near-test-contracts" } [features] default = [] -protocol_feature_alt_bn128 = [ - "near-primitives/protocol_feature_alt_bn128", -] protocol_feature_chunk_only_producers = [ "near-chain-configs/protocol_feature_chunk_only_producers", "near-chain/protocol_feature_chunk_only_producers", @@ -30,6 +27,5 @@ protocol_feature_chunk_only_producers = [ nightly = [ "nightly_protocol", "protocol_feature_chunk_only_producers", - "protocol_feature_alt_bn128", ] nightly_protocol = [] From 5b029aad460af9e20b2cd1f3271fc287f2288f8d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 18 May 2022 12:31:47 +0100 Subject: [PATCH 3/6] hack: work-around broken estimations --- runtime/runtime-params-estimator/test-contract/build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/runtime-params-estimator/test-contract/build.sh b/runtime/runtime-params-estimator/test-contract/build.sh index 7fecefad116..8a3133e3f0e 100755 --- a/runtime/runtime-params-estimator/test-contract/build.sh +++ b/runtime/runtime-params-estimator/test-contract/build.sh @@ -46,8 +46,11 @@ echo ${bare_wasm} # Generate several files of various sizes. We will compile these files into the Wasm binary to # bloat its size to the given values. +# FIXME(#6822): we should just remove the payload logic. 10Kib variant is +# broken, because the baseline contract is >10KiB (data for alt_bn estimatons). + # 10KiB -dd if=/dev/urandom of=./res/payload bs=$(expr 10240 - ${bare_wasm}) count=1 +dd if=/dev/urandom of=./res/payload bs=1 count=1 cargo build --target wasm32-unknown-unknown --release --features "payload$features_with_comma" cp target/wasm32-unknown-unknown/release/test_contract.wasm ./res/stable_small_contract.wasm From 52efb41b86aee6fb747cdc33c85d9207e009b255 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 18 May 2022 13:00:47 +0100 Subject: [PATCH 4/6] doc: changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 054b369000d..1d06bab7ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ ### Protocol Changes -* Introduced protobuf encoding as the new network protocol. Borsh support will be removed in two releases as per normal protocol upgrade policies [#6672](https://github.com/near/nearcore/pull/6672) +* Introduced protobuf encoding as the new network protocol. Borsh support will be removed in two releases as per normal protocol upgrade policies [#6672](https://github.com/near/nearcore/pull/6672). +* Stabilized `alt_bn128_g1_multiexp`, `alt_bn128_g1_sum`, `alt_bn128_pairing_check` host functions [#6813](https://github.com/near/nearcore/pull/6813). ### Non-protocol Changes From 05abb6c537df86245068c20ddd624606a7458556 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 19 May 2022 10:14:27 +0100 Subject: [PATCH 5/6] Update core/primitives-core/src/config.rs Co-authored-by: Jakob Meier --- core/primitives-core/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/primitives-core/src/config.rs b/core/primitives-core/src/config.rs index 3aa262371e6..0351a9338a8 100644 --- a/core/primitives-core/src/config.rs +++ b/core/primitives-core/src/config.rs @@ -405,7 +405,7 @@ pub struct ExtCostsConfig { pub alt_bn128_g1_multiexp_element: Gas, /// Base cost for sum pub alt_bn128_g1_sum_base: Gas, - /// Per element byte for sum + /// Per element cost for sum pub alt_bn128_g1_sum_element: Gas, /// Base cost for pairing check pub alt_bn128_pairing_check_base: Gas, From 115fd00d4946500b70b88067739a64a5e628032f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 23 May 2022 12:24:22 +0100 Subject: [PATCH 6/6] fix: use correct protocol version --- chain/chain/src/tests/simple_chain.rs | 4 ++-- core/primitives/src/version.rs | 4 ++-- ...__tests__runtime__sanity_checks__receipts_gas_profile.snap | 2 +- nearcore/res/genesis_config.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/chain/chain/src/tests/simple_chain.rs b/chain/chain/src/tests/simple_chain.rs index ce98c1e2849..22796d9ed08 100644 --- a/chain/chain/src/tests/simple_chain.rs +++ b/chain/chain/src/tests/simple_chain.rs @@ -41,7 +41,7 @@ fn build_chain() { if cfg!(feature = "nightly") { insta::assert_display_snapshot!(hash, @"8F4vXPPNevoQXVGdwKAZQfzzxhSyqWp3xJiik4RMUKSk"); } else { - insta::assert_display_snapshot!(hash, @"sFAi6Xq5jWcbRetAkMQ3A44GvfLHSLMnb8SqaRsmWmo"); + insta::assert_display_snapshot!(hash, @"6sAno2uEwwQ5yiDscePWY8HWmRJLpGNv39uoff3BCpxT"); } for i in 1..5 { @@ -70,7 +70,7 @@ fn build_chain() { if cfg!(feature = "nightly") { insta::assert_display_snapshot!(hash, @"DrW7MsRaFhEdjQcxjqrTXvNmQ1eptgURQ7RUTeZnrBXC"); } else { - insta::assert_display_snapshot!(hash, @"F5srbRRkG5KBzvDzEpDiiJp257SCVUaeFhNeXAddbHGZ"); + insta::assert_display_snapshot!(hash, @"Fn9MgjUx6VXhPYNqqDtf2C9kBVveY2vuSLXNLZUNJCqK"); } } diff --git a/core/primitives/src/version.rs b/core/primitives/src/version.rs index a4f04fab415..302fb6633ec 100644 --- a/core/primitives/src/version.rs +++ b/core/primitives/src/version.rs @@ -170,7 +170,7 @@ pub const PEER_MIN_ALLOWED_PROTOCOL_VERSION: ProtocolVersion = STABLE_PROTOCOL_V /// 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 = 54; +const STABLE_PROTOCOL_VERSION: ProtocolVersion = 55; /// Version used by this binary. #[cfg(not(feature = "nightly_protocol"))] @@ -232,7 +232,7 @@ impl ProtocolFeature { | ProtocolFeature::LimitContractLocals | ProtocolFeature::ChunkNodesCache | ProtocolFeature::LowerStorageKeyLimit => 53, - ProtocolFeature::AltBn128 => 54, + ProtocolFeature::AltBn128 => 55, // Nightly features #[cfg(feature = "protocol_feature_chunk_only_producers")] 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 84348ace8f8..4ef88917129 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 @@ -282,7 +282,7 @@ expression: receipts_gas_profile CostGasUsed { cost_category: "WASM_HOST_COST", cost: "WRITE_REGISTER_BYTE", - gas_used: 1417983372, + gas_used: 1904583564, }, ], [ diff --git a/nearcore/res/genesis_config.json b/nearcore/res/genesis_config.json index 571fca48c0e..0d960c70601 100644 --- a/nearcore/res/genesis_config.json +++ b/nearcore/res/genesis_config.json @@ -1,5 +1,5 @@ { - "protocol_version": 54, + "protocol_version": 55, "genesis_time": "1970-01-01T00:00:00.000000000Z", "chain_id": "sample", "genesis_height": 0, @@ -67,4 +67,4 @@ 6250 ], "records": [] -} +} \ No newline at end of file