diff --git a/chain/chain/Cargo.toml b/chain/chain/Cargo.toml index dcd3489590d..5695114491a 100644 --- a/chain/chain/Cargo.toml +++ b/chain/chain/Cargo.toml @@ -43,7 +43,6 @@ no_cache = ["near-store/no_cache"] protocol_feature_evm = ["near-primitives/protocol_feature_evm", "near-chain-configs/protocol_feature_evm"] protocol_feature_block_header_v3 = [] protocol_feature_restore_receipts_after_fix = [] -protocol_feature_cap_max_gas_price = [] -nightly_protocol_features = ["nightly_protocol", "protocol_feature_block_header_v3", "protocol_feature_restore_receipts_after_fix", "protocol_feature_cap_max_gas_price"] +nightly_protocol_features = ["nightly_protocol", "protocol_feature_block_header_v3", "protocol_feature_restore_receipts_after_fix"] nightly_protocol = [] -sandbox = [] \ No newline at end of file +sandbox = [] diff --git a/chain/chain/src/types.rs b/chain/chain/src/types.rs index ea9c3fb4832..41e2c8eb6e6 100644 --- a/chain/chain/src/types.rs +++ b/chain/chain/src/types.rs @@ -172,8 +172,7 @@ impl BlockEconomicsConfig { } pub fn max_gas_price(&self, protocol_version: ProtocolVersion) -> Balance { - if checked_feature!("protocol_feature_cap_max_gas_price", CapMaxGasPrice, protocol_version) - { + if checked_feature!("stable", CapMaxGasPrice, protocol_version) { std::cmp::min( self.max_gas_price, Self::MAX_GAS_MULTIPLIER * self.min_gas_price(protocol_version), diff --git a/chain/client/Cargo.toml b/chain/client/Cargo.toml index d32c87597a5..50495e1a911 100644 --- a/chain/client/Cargo.toml +++ b/chain/client/Cargo.toml @@ -62,13 +62,9 @@ metric_recorder = ["near-client-primitives/metric_recorder"] delay_detector = ["near-chain/delay_detector", "near-network/delay_detector", "delay-detector"] protocol_feature_evm = ["near-primitives/protocol_feature_evm", "near-chain/protocol_feature_evm", "node-runtime/protocol_feature_evm"] protocol_feature_block_header_v3 = ["near-primitives/protocol_feature_block_header_v3", "near-chain/protocol_feature_block_header_v3", "near-store/protocol_feature_block_header_v3"] -protocol_feature_add_account_versions = ["near-primitives/protocol_feature_add_account_versions"] -protocol_feature_fix_storage_usage = ["near-primitives/protocol_feature_fix_storage_usage"] protocol_feature_restore_receipts_after_fix = [] -protocol_feature_cap_max_gas_price = ["near-primitives/protocol_feature_cap_max_gas_price"] -protocol_feature_count_refund_receipts_in_gas_limit = ["near-primitives/protocol_feature_count_refund_receipts_in_gas_limit", "node-runtime/protocol_feature_count_refund_receipts_in_gas_limit"] nightly_protocol = [] -nightly_protocol_features = ["nightly_protocol", "near-chain/nightly_protocol_features", "protocol_feature_block_header_v3", "protocol_feature_add_account_versions", "protocol_feature_fix_storage_usage", "protocol_feature_restore_receipts_after_fix", "protocol_feature_cap_max_gas_price", "protocol_feature_count_refund_receipts_in_gas_limit"] +nightly_protocol_features = ["nightly_protocol", "near-chain/nightly_protocol_features", "protocol_feature_block_header_v3", "protocol_feature_restore_receipts_after_fix"] sandbox = ["near-network/sandbox", "near-chain/sandbox", "node-runtime/sandbox"] [[test]] diff --git a/chain/client/src/client.rs b/chain/client/src/client.rs index 0dc9caa7468..195c4522f91 100644 --- a/chain/client/src/client.rs +++ b/chain/client/src/client.rs @@ -1671,7 +1671,6 @@ mod test { use cached::Cached; - #[cfg(feature = "protocol_feature_cap_max_gas_price")] use near_chain::Provenance; use near_chain::{ChainGenesis, RuntimeAdapter}; use near_chain_configs::Genesis; @@ -1681,7 +1680,6 @@ mod test { use near_primitives::block::{Approval, ApprovalInner}; use near_primitives::hash::hash; use near_primitives::validator_signer::InMemoryValidatorSigner; - #[cfg(feature = "protocol_feature_cap_max_gas_price")] use near_primitives::version::ProtocolFeature; use near_primitives::version::PROTOCOL_VERSION; use near_store::test_utils::create_test_store; @@ -1763,7 +1761,6 @@ mod test { assert_eq!(env.clients[0].pending_approvals.cache_size(), 0); } - #[cfg(feature = "protocol_feature_cap_max_gas_price")] #[test] fn test_cap_max_gas_price() { let mut genesis = Genesis::test(vec!["test0", "test1"], 1); diff --git a/chain/client/tests/process_blocks.rs b/chain/client/tests/process_blocks.rs index eb7d080d98b..056b3136e52 100644 --- a/chain/client/tests/process_blocks.rs +++ b/chain/client/tests/process_blocks.rs @@ -34,7 +34,6 @@ use near_network::{ }; use near_primitives::block::{Approval, ApprovalInner}; use near_primitives::block_header::BlockHeader; -use near_primitives::checked_feature; use near_primitives::errors::InvalidTxError; use near_primitives::errors::TxExecutionError; @@ -2381,16 +2380,7 @@ fn test_refund_receipts_processing() { } let ending_block_height = block_height - 1; - let count_refund_receipts_in_gas_limit = checked_feature!( - "protocol_feature_count_refund_receipts_in_gas_limit", - CountRefundReceiptsInGasLimit, - genesis.config.protocol_version - ); - let begin_block_height = if count_refund_receipts_in_gas_limit { - ending_block_height - refund_receipt_ids.len() as u64 + 1 - } else { - ending_block_height - }; + let begin_block_height = ending_block_height - refund_receipt_ids.len() as u64 + 1; let mut processed_refund_receipt_ids = HashSet::new(); for i in begin_block_height..=ending_block_height { let block = env.clients[0].chain.get_block_by_height(i).unwrap().clone(); @@ -2404,12 +2394,8 @@ fn test_refund_receipts_processing() { processed_refund_receipt_ids.insert(outcome.outcome_with_id.id); }); let chunk_extra = env.clients[0].chain.get_chunk_extra(block.hash(), 0).unwrap().clone(); - if count_refund_receipts_in_gas_limit { - assert_eq!(execution_outcomes_from_block.len(), 1); - assert!(chunk_extra.gas_used() >= chunk_extra.gas_limit()); - } else { - assert_eq!(chunk_extra.gas_used(), 0); - } + assert_eq!(execution_outcomes_from_block.len(), 1); + assert!(chunk_extra.gas_used() >= chunk_extra.gas_limit()); } assert_eq!(processed_refund_receipt_ids, refund_receipt_ids); } @@ -3182,8 +3168,10 @@ mod protocol_feature_restore_receipts_after_fix_tests { } } +// This test cannot be enabled at the same time as `protocol_feature_block_header_v3`. +// Otherwise `get_mut` for block header will panic. #[cfg(test)] -#[cfg(feature = "protocol_feature_fix_storage_usage")] +#[cfg(not(feature = "protocol_feature_block_header_v3"))] mod storage_usage_fix_tests { use super::*; use borsh::BorshDeserialize; @@ -3267,7 +3255,6 @@ mod storage_usage_fix_tests { } } -#[cfg(feature = "protocol_feature_cap_max_gas_price")] #[cfg(test)] mod cap_max_gas_price_tests { use super::*; diff --git a/core/primitives-core/Cargo.toml b/core/primitives-core/Cargo.toml index e6cc9307a1b..ee25dead7f6 100644 --- a/core/primitives-core/Cargo.toml +++ b/core/primitives-core/Cargo.toml @@ -25,7 +25,4 @@ lazy_static = "1.4" [features] default = [] protocol_feature_evm = [] -protocol_feature_add_account_versions = [] protocol_feature_alt_bn128 = [] -protocol_feature_tx_size_limit = [] -protocol_feature_math_extension = [] diff --git a/core/primitives-core/src/account.rs b/core/primitives-core/src/account.rs index 8b16e7b239a..8a789b441e1 100644 --- a/core/primitives-core/src/account.rs +++ b/core/primitives-core/src/account.rs @@ -1,13 +1,10 @@ use borsh::{BorshDeserialize, BorshSerialize}; use serde::{Deserialize, Serialize}; +use std::io; use crate::hash::CryptoHash; use crate::serialize::{option_u128_dec_format, u128_dec_format_compatible}; use crate::types::{AccountId, Balance, Nonce, StorageUsage}; -#[cfg(feature = "protocol_feature_add_account_versions")] -use std::io; - -#[cfg(feature = "protocol_feature_add_account_versions")] #[derive( BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Debug, Clone, Copy, )] @@ -15,7 +12,6 @@ pub enum AccountVersion { V1, } -#[cfg(feature = "protocol_feature_add_account_versions")] impl Default for AccountVersion { fn default() -> Self { AccountVersion::V1 @@ -24,10 +20,6 @@ impl Default for AccountVersion { /// Per account information stored in the state. #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] -#[cfg_attr( - not(feature = "protocol_feature_add_account_versions"), - derive(BorshSerialize, BorshDeserialize) -)] pub struct Account { /// The total not locked tokens. #[serde(with = "u128_dec_format_compatible")] @@ -40,7 +32,6 @@ pub struct Account { /// Storage used by the given account, includes account id, this struct, access keys and other data. storage_usage: StorageUsage, /// Version of Account in re migrations and similar - #[cfg(feature = "protocol_feature_add_account_versions")] #[serde(default)] version: AccountVersion, } @@ -56,14 +47,7 @@ impl Account { code_hash: CryptoHash, storage_usage: StorageUsage, ) -> Self { - Account { - amount, - locked, - code_hash, - storage_usage, - #[cfg(feature = "protocol_feature_add_account_versions")] - version: AccountVersion::V1, - } + Account { amount, locked, code_hash, storage_usage, version: AccountVersion::V1 } } #[inline] @@ -87,7 +71,6 @@ impl Account { } #[inline] - #[cfg(feature = "protocol_feature_add_account_versions")] pub fn version(&self) -> AccountVersion { self.version } @@ -112,14 +95,11 @@ impl Account { self.storage_usage = storage_usage; } - #[inline] - #[cfg(feature = "protocol_feature_add_account_versions")] pub fn set_version(&mut self, version: AccountVersion) { self.version = version; } } -#[cfg(feature = "protocol_feature_add_account_versions")] #[derive(BorshSerialize, BorshDeserialize)] struct LegacyAccount { amount: Balance, @@ -128,7 +108,6 @@ struct LegacyAccount { storage_usage: StorageUsage, } -#[cfg(feature = "protocol_feature_add_account_versions")] impl BorshDeserialize for Account { fn deserialize(buf: &mut &[u8]) -> Result { if buf.len() == std::mem::size_of::() { @@ -148,7 +127,6 @@ impl BorshDeserialize for Account { } } -#[cfg(feature = "protocol_feature_add_account_versions")] impl BorshSerialize for Account { fn serialize(&self, writer: &mut W) -> io::Result<()> { match self.version { @@ -245,7 +223,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_add_account_versions")] fn test_account_deserialization() { let old_account = LegacyAccount { amount: 100, diff --git a/core/primitives-core/src/config.rs b/core/primitives-core/src/config.rs index 801e4f396d9..ce4a989d702 100644 --- a/core/primitives-core/src/config.rs +++ b/core/primitives-core/src/config.rs @@ -71,7 +71,6 @@ pub struct VMLimitConfig { /// Max contract size pub max_contract_size: u64, /// Max transaction size - #[cfg(feature = "protocol_feature_tx_size_limit")] pub max_transaction_size: u64, /// Max storage key size pub max_length_storage_key: u64, @@ -154,7 +153,6 @@ impl Default for VMLimitConfig { max_arguments_length: 4 * 2u64.pow(20), // 4 Mib max_length_returned_data: 4 * 2u64.pow(20), // 4 Mib max_contract_size: 4 * 2u64.pow(20), // 4 Mib, - #[cfg(feature = "protocol_feature_tx_size_limit")] max_transaction_size: 4 * 2u64.pow(20), // 4 Mib max_length_storage_key: 4 * 2u64.pow(20), // 4 Mib @@ -223,14 +221,11 @@ pub struct ExtCostsConfig { /// Cost of getting sha256 per byte pub keccak512_byte: Gas, - #[cfg(feature = "protocol_feature_math_extension")] /// Cost of getting ripemd160 base pub ripemd160_base: Gas, - #[cfg(feature = "protocol_feature_math_extension")] /// Cost of getting ripemd160 per message block pub ripemd160_block: Gas, - #[cfg(feature = "protocol_feature_math_extension")] /// Cost of calling ecrecover pub ecrecover_base: Gas, @@ -364,12 +359,9 @@ impl Default for ExtCostsConfig { keccak256_byte: SAFETY_MULTIPLIER * 7157035, keccak512_base: SAFETY_MULTIPLIER * 1937129412, keccak512_byte: SAFETY_MULTIPLIER * 12216567, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_base: SAFETY_MULTIPLIER * 284558362, - #[cfg(feature = "protocol_feature_math_extension")] // Cost per byte is 3542227. There are 64 bytes in a block. ripemd160_block: SAFETY_MULTIPLIER * 226702528, - #[cfg(feature = "protocol_feature_math_extension")] ecrecover_base: SAFETY_MULTIPLIER * 1121789875000, log_base: SAFETY_MULTIPLIER * 1181104350, log_byte: SAFETY_MULTIPLIER * 4399597, @@ -441,11 +433,8 @@ impl ExtCostsConfig { keccak256_byte: 0, keccak512_base: 0, keccak512_byte: 0, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_base: 0, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_block: 0, - #[cfg(feature = "protocol_feature_math_extension")] ecrecover_base: 0, log_base: 0, log_byte: 0, @@ -518,11 +507,8 @@ pub enum ExtCosts { keccak256_byte, keccak512_base, keccak512_byte, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_base, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_block, - #[cfg(feature = "protocol_feature_math_extension")] ecrecover_base, log_base, log_byte, @@ -648,11 +634,8 @@ impl ExtCosts { keccak256_byte => config.keccak256_byte, keccak512_base => config.keccak512_base, keccak512_byte => config.keccak512_byte, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_base => config.ripemd160_base, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_block => config.ripemd160_block, - #[cfg(feature = "protocol_feature_math_extension")] ecrecover_base => config.ecrecover_base, log_base => config.log_base, log_byte => config.log_byte, diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index 3e4975fdf9c..0a692952db5 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -41,18 +41,11 @@ near-rpc-error-macro = { path = "../../tools/rpctypegen/macro" } [features] default = ["jemallocator"] dump_errors_schema = ["near-rpc-error-macro/dump_errors_schema"] -protocol_feature_add_account_versions = ["near-primitives-core/protocol_feature_add_account_versions"] protocol_feature_evm = ["near-primitives-core/protocol_feature_evm"] protocol_feature_block_header_v3 = [] protocol_feature_alt_bn128 = ["near-primitives-core/protocol_feature_alt_bn128", "near-vm-errors/protocol_feature_alt_bn128"] -protocol_feature_tx_size_limit = ["near-primitives-core/protocol_feature_tx_size_limit"] -protocol_feature_allow_create_account_on_delete = [] -protocol_feature_fix_storage_usage = [] protocol_feature_restore_receipts_after_fix = [] -protocol_feature_cap_max_gas_price = [] -protocol_feature_count_refund_receipts_in_gas_limit = [] -protocol_feature_math_extension = ["near-primitives-core/protocol_feature_math_extension"] -nightly_protocol_features = ["nightly_protocol", "protocol_feature_evm", "protocol_feature_block_header_v3", "protocol_feature_alt_bn128", "protocol_feature_add_account_versions", "protocol_feature_tx_size_limit", "protocol_feature_allow_create_account_on_delete", "protocol_feature_fix_storage_usage", "protocol_feature_restore_receipts_after_fix", "protocol_feature_cap_max_gas_price", "protocol_feature_count_refund_receipts_in_gas_limit", "protocol_feature_math_extension"] +nightly_protocol_features = ["nightly_protocol", "protocol_feature_evm", "protocol_feature_block_header_v3", "protocol_feature_alt_bn128", "protocol_feature_restore_receipts_after_fix"] nightly_protocol = [] [dev-dependencies] diff --git a/core/primitives/src/errors.rs b/core/primitives/src/errors.rs index 985c57fdb84..d5c99698ddd 100644 --- a/core/primitives/src/errors.rs +++ b/core/primitives/src/errors.rs @@ -144,7 +144,6 @@ pub enum InvalidTxError { /// An error occurred while validating actions of a Transaction. ActionsValidation(ActionsValidationError), /// The size of serialized transaction exceeded the limit. - #[cfg(feature = "protocol_feature_tx_size_limit")] TransactionSizeExceeded { size: u64, limit: u64 }, } @@ -492,7 +491,6 @@ impl Display for InvalidTxError { tx_nonce, upper_bound ) } - #[cfg(feature = "protocol_feature_tx_size_limit")] InvalidTxError::TransactionSizeExceeded { size, limit } => { write!(f, "Size of serialized transaction {} exceeded the limit {}", size, limit) } diff --git a/core/primitives/src/runtime/migration_data.rs b/core/primitives/src/runtime/migration_data.rs index 6002b004280..a97c7a87a72 100644 --- a/core/primitives/src/runtime/migration_data.rs +++ b/core/primitives/src/runtime/migration_data.rs @@ -1,17 +1,13 @@ #[cfg(feature = "protocol_feature_restore_receipts_after_fix")] use crate::receipt::ReceiptResult; -#[cfg(feature = "protocol_feature_fix_storage_usage")] use crate::types::AccountId; -#[cfg(feature = "protocol_feature_fix_storage_usage")] use crate::types::Gas; use std::fmt; use std::fmt::{Debug, Formatter}; #[derive(Default)] pub struct MigrationData { - #[cfg(feature = "protocol_feature_fix_storage_usage")] pub storage_usage_delta: Vec<(AccountId, u64)>, - #[cfg(feature = "protocol_feature_fix_storage_usage")] pub storage_usage_fix_gas: Gas, #[cfg(feature = "protocol_feature_restore_receipts_after_fix")] pub restored_receipts: ReceiptResult, diff --git a/core/primitives/src/version.rs b/core/primitives/src/version.rs index c7a2402155f..85717f293d4 100644 --- a/core/primitives/src/version.rs +++ b/core/primitives/src/version.rs @@ -87,6 +87,18 @@ pub enum ProtocolFeature { FixApplyChunks, LowerStorageCost, DeleteActionRestriction, + /// Add versions to `Account` data structure + AccountVersions, + TransactionSizeLimit, + /// Delete account can create implicit accounts + AllowCreateAccountOnDelete, + /// Fix a bug in `storage_usage` for account caused by #3824 + FixStorageUsage, + /// Cap maximum gas price to 2,000,000,000 yoctoNEAR + CapMaxGasPrice, + CountRefundReceiptsInGasLimit, + /// Add `ripemd60` and `ecrecover` host function + MathExtension, // nightly features #[cfg(feature = "protocol_feature_evm")] @@ -95,29 +107,15 @@ pub enum ProtocolFeature { BlockHeaderV3, #[cfg(feature = "protocol_feature_alt_bn128")] AltBn128, - #[cfg(feature = "protocol_feature_add_account_versions")] - AccountVersions, - #[cfg(feature = "protocol_feature_tx_size_limit")] - TransactionSizeLimit, - #[cfg(feature = "protocol_feature_allow_create_account_on_delete")] - AllowCreateAccountOnDelete, - #[cfg(feature = "protocol_feature_fix_storage_usage")] - FixStorageUsage, #[cfg(feature = "protocol_feature_restore_receipts_after_fix")] RestoreReceiptsAfterFix, - #[cfg(feature = "protocol_feature_cap_max_gas_price")] - CapMaxGasPrice, - #[cfg(feature = "protocol_feature_count_refund_receipts_in_gas_limit")] - CountRefundReceiptsInGasLimit, - #[cfg(feature = "protocol_feature_math_extension")] - MathExtension, } /// Current latest stable version of the protocol. /// Some features (e. g. FixStorageUsage) require that there is at least one epoch with exactly /// the corresponding version #[cfg(not(feature = "nightly_protocol"))] -pub const PROTOCOL_VERSION: ProtocolVersion = 45; +pub const PROTOCOL_VERSION: ProtocolVersion = 46; /// Current latest nightly version of the protocol. #[cfg(feature = "nightly_protocol")] @@ -133,30 +131,23 @@ impl ProtocolFeature { ProtocolFeature::ForwardChunkParts => 45, ProtocolFeature::RectifyInflation => 45, ProtocolFeature::AccessKeyNonceRange => 45, + ProtocolFeature::AccountVersions => 46, + ProtocolFeature::TransactionSizeLimit => 46, + ProtocolFeature::AllowCreateAccountOnDelete => 46, + ProtocolFeature::FixStorageUsage => 46, + ProtocolFeature::CapMaxGasPrice => 46, + ProtocolFeature::CountRefundReceiptsInGasLimit => 46, + ProtocolFeature::MathExtension => 46, // Nightly features #[cfg(feature = "protocol_feature_evm")] ProtocolFeature::EVM => 103, #[cfg(feature = "protocol_feature_alt_bn128")] ProtocolFeature::AltBn128 => 105, - #[cfg(feature = "protocol_feature_add_account_versions")] - ProtocolFeature::AccountVersions => 107, - #[cfg(feature = "protocol_feature_tx_size_limit")] - ProtocolFeature::TransactionSizeLimit => 108, #[cfg(feature = "protocol_feature_block_header_v3")] ProtocolFeature::BlockHeaderV3 => 109, - #[cfg(feature = "protocol_feature_allow_create_account_on_delete")] - ProtocolFeature::AllowCreateAccountOnDelete => 110, - #[cfg(feature = "protocol_feature_fix_storage_usage")] - ProtocolFeature::FixStorageUsage => 111, #[cfg(feature = "protocol_feature_restore_receipts_after_fix")] ProtocolFeature::RestoreReceiptsAfterFix => 112, - #[cfg(feature = "protocol_feature_cap_max_gas_price")] - ProtocolFeature::CapMaxGasPrice => 113, - #[cfg(feature = "protocol_feature_count_refund_receipts_in_gas_limit")] - ProtocolFeature::CountRefundReceiptsInGasLimit => 114, - #[cfg(feature = "protocol_feature_math_extension")] - ProtocolFeature::MathExtension => 114, } } } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index c3905cb400c..97b44c51dbb 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -22,7 +22,6 @@ regression_tests = [] adversarial = ["nearcore/adversarial"] protocol_feature_evm = ["nearcore/protocol_feature_evm", "testlib/protocol_feature_evm"] protocol_feature_alt_bn128 = ["nearcore/protocol_feature_alt_bn128"] -protocol_feature_allow_create_account_on_delete = ["nearcore/protocol_feature_allow_create_account_on_delete", "testlib/protocol_feature_allow_create_account_on_delete", "near-primitives/protocol_feature_allow_create_account_on_delete"] -nightly_protocol_features = ["nearcore/nightly_protocol_features", "testlib/nightly_protocol_features", "protocol_feature_alt_bn128", "protocol_feature_allow_create_account_on_delete", "protocol_feature_restore_receipts_after_fix"] +nightly_protocol_features = ["nearcore/nightly_protocol_features", "testlib/nightly_protocol_features", "protocol_feature_alt_bn128", "protocol_feature_restore_receipts_after_fix"] nightly_protocol = ["nearcore/nightly_protocol", "testlib/nightly_protocol"] protocol_feature_restore_receipts_after_fix = ["nearcore/protocol_feature_restore_receipts_after_fix"] diff --git a/integration-tests/tests/test_cases_runtime.rs b/integration-tests/tests/test_cases_runtime.rs index 17398aee70e..cbedeb81f82 100644 --- a/integration-tests/tests/test_cases_runtime.rs +++ b/integration-tests/tests/test_cases_runtime.rs @@ -2,7 +2,6 @@ mod test { use near_chain_configs::Genesis; use near_primitives::state_record::StateRecord; - use near_primitives::version::PROTOCOL_VERSION; use nearcore::config::{GenesisExt, TESTING_INIT_BALANCE}; use testlib::node::RuntimeNode; use testlib::runtime_utils::{add_test_contract, alice_account, bob_account}; @@ -294,7 +293,7 @@ mod test { #[test] fn test_delete_account_has_enough_money_runtime() { let node = create_runtime_node(); - test_delete_account_fail(node, PROTOCOL_VERSION); + test_delete_account_fail(node); } #[test] @@ -306,13 +305,13 @@ mod test { #[test] fn test_delete_account_implicit_beneficiary_account_runtime() { let node = create_runtime_node(); - test_delete_account_implicit_beneficiary_account(node, PROTOCOL_VERSION); + test_delete_account_implicit_beneficiary_account(node); } #[test] fn test_delete_account_while_staking_runtime() { let node = create_runtime_node(); - test_delete_account_while_staking(node, PROTOCOL_VERSION); + test_delete_account_while_staking(node); } #[test] diff --git a/nearcore/Cargo.toml b/nearcore/Cargo.toml index 085a1085b53..b7d6a7ad378 100644 --- a/nearcore/Cargo.toml +++ b/nearcore/Cargo.toml @@ -69,18 +69,9 @@ json_rpc = ["near-jsonrpc"] protocol_feature_evm = ["near-primitives/protocol_feature_evm", "node-runtime/protocol_feature_evm", "near-chain-configs/protocol_feature_evm", "near-chain/protocol_feature_evm", "near-client/protocol_feature_evm"] protocol_feature_alt_bn128 = ["near-primitives/protocol_feature_alt_bn128", "node-runtime/protocol_feature_alt_bn128"] protocol_feature_block_header_v3 = ["near-epoch-manager/protocol_feature_block_header_v3", "near-store/protocol_feature_block_header_v3", "near-primitives/protocol_feature_block_header_v3", "near-chain/protocol_feature_block_header_v3", "near-client/protocol_feature_block_header_v3"] -protocol_feature_add_account_versions = ["near-primitives/protocol_feature_add_account_versions"] -protocol_feature_tx_size_limit = ["near-primitives/protocol_feature_tx_size_limit", "node-runtime/protocol_feature_tx_size_limit"] -protocol_feature_allow_create_account_on_delete = ["node-runtime/protocol_feature_allow_create_account_on_delete"] -protocol_feature_fix_storage_usage = ["near-primitives/protocol_feature_fix_storage_usage", "node-runtime/protocol_feature_fix_storage_usage"] -nightly_protocol_features = ["nightly_protocol", "near-primitives/nightly_protocol_features", "near-client/nightly_protocol_features", "near-epoch-manager/nightly_protocol_features", "near-store/nightly_protocol_features", "protocol_feature_evm", "protocol_feature_block_header_v3", "protocol_feature_alt_bn128", "protocol_feature_add_account_versions", "protocol_feature_tx_size_limit", "protocol_feature_allow_create_account_on_delete", "protocol_feature_fix_storage_usage", "protocol_feature_restore_receipts_after_fix", "protocol_feature_cap_max_gas_price", "protocol_feature_math_extension"] +nightly_protocol_features = ["nightly_protocol", "near-primitives/nightly_protocol_features", "near-client/nightly_protocol_features", "near-epoch-manager/nightly_protocol_features", "near-store/nightly_protocol_features", "protocol_feature_evm", "protocol_feature_block_header_v3", "protocol_feature_alt_bn128", "protocol_feature_restore_receipts_after_fix"] nightly_protocol = ["near-primitives/nightly_protocol", "near-jsonrpc/nightly_protocol"] protocol_feature_restore_receipts_after_fix = ["near-primitives/protocol_feature_restore_receipts_after_fix", "near-chain/protocol_feature_restore_receipts_after_fix", "node-runtime/protocol_feature_restore_receipts_after_fix"] -protocol_feature_cap_max_gas_price = ["near-primitives/protocol_feature_cap_max_gas_price", "near-chain/protocol_feature_cap_max_gas_price"] -protocol_feature_math_extension = [ - "near-primitives/protocol_feature_math_extension", - "node-runtime/protocol_feature_math_extension" -] # enable this to build neard with wasmer 1.0 runner # now if none of wasmer0_default, wasmer1_default or wasmtime_default is enabled, wasmer0 would be default diff --git a/nearcore/res/genesis_config.json b/nearcore/res/genesis_config.json index ad8db1f31aa..0b1a66f371d 100644 --- a/nearcore/res/genesis_config.json +++ b/nearcore/res/genesis_config.json @@ -1,5 +1,5 @@ { - "protocol_version": 45, + "protocol_version": 46, "genesis_time": "1970-01-01T00:00:00.000000000Z", "chain_id": "sample", "genesis_height": 0, @@ -154,6 +154,9 @@ "keccak256_byte": 21471105, "keccak512_base": 5811388236, "keccak512_byte": 36649701, + "ripemd160_base": 853675086, + "ripemd160_block": 680107584, + "ecrecover_base": 3365369625000, "log_base": 3543313050, "log_byte": 13198791, "storage_write_base": 64196736000, @@ -203,6 +206,7 @@ "max_arguments_length": 4194304, "max_length_returned_data": 4194304, "max_contract_size": 4194304, + "max_transaction_size": 4194304, "max_length_storage_key": 4194304, "max_length_storage_value": 4194304, "max_promises_per_function_call_action": 1024, diff --git a/nearcore/src/migrations.rs b/nearcore/src/migrations.rs index 7356195cae5..1205775a37d 100644 --- a/nearcore/src/migrations.rs +++ b/nearcore/src/migrations.rs @@ -11,7 +11,6 @@ use near_primitives::receipt::ReceiptResult; use near_primitives::runtime::migration_data::MigrationData; use near_primitives::sharding::{ChunkHash, ShardChunkHeader, ShardChunkV1}; use near_primitives::transaction::ExecutionOutcomeWithIdAndProof; -#[cfg(feature = "protocol_feature_fix_storage_usage")] use near_primitives::types::Gas; use near_primitives::types::{BlockHeight, ShardId}; use near_store::migrations::set_store_version; @@ -350,7 +349,6 @@ pub fn migrate_22_to_23(path: &String, near_config: &NearConfig) { set_store_version(&store, 23); } -#[cfg(feature = "protocol_feature_fix_storage_usage")] lazy_static_include::lazy_static_include_bytes! { /// File with account ids and deltas that need to be applied in order to fix storage usage /// difference between actual and stored usage, introduced due to bug in access key deletion, @@ -361,7 +359,6 @@ lazy_static_include::lazy_static_include_bytes! { /// In test runs reads and writes here used 442 TGas, but in test on live net migration take /// between 4 and 4.5s. We do not want to process any receipts in this block -#[cfg(feature = "protocol_feature_fix_storage_usage")] const GAS_USED_FOR_STORAGE_USAGE_DELTA_MIGRATION: Gas = 1_000_000_000_000_000; #[cfg(feature = "protocol_feature_restore_receipts_after_fix")] @@ -373,24 +370,13 @@ lazy_static_include::lazy_static_include_bytes! { } pub fn load_migration_data(chain_id: &String) -> MigrationData { - #[cfg(not(any( - feature = "protocol_feature_fix_storage_usage", - feature = "protocol_feature_restore_receipts_after_fix" - )))] - let _ = chain_id; - #[cfg(any( - feature = "protocol_feature_fix_storage_usage", - feature = "protocol_feature_restore_receipts_after_fix" - ))] let is_mainnet = chain_id == "mainnet"; MigrationData { - #[cfg(feature = "protocol_feature_fix_storage_usage")] storage_usage_delta: if is_mainnet { serde_json::from_slice(&MAINNET_STORAGE_USAGE_DELTA).unwrap() } else { Vec::new() }, - #[cfg(feature = "protocol_feature_fix_storage_usage")] storage_usage_fix_gas: if is_mainnet { GAS_USED_FOR_STORAGE_USAGE_DELTA_MIGRATION } else { @@ -408,24 +394,11 @@ pub fn load_migration_data(chain_id: &String) -> MigrationData { #[cfg(test)] mod tests { - #[cfg(any( - feature = "protocol_feature_fix_storage_usage", - feature = "protocol_feature_restore_receipts_after_fix" - ))] use super::*; - #[cfg(any( - feature = "protocol_feature_fix_storage_usage", - feature = "protocol_feature_restore_receipts_after_fix" - ))] use near_primitives::hash::hash; - #[cfg(any( - feature = "protocol_feature_fix_storage_usage", - feature = "protocol_feature_restore_receipts_after_fix" - ))] use near_primitives::serialize::to_base; #[test] - #[cfg(feature = "protocol_feature_fix_storage_usage")] fn test_migration_data() { assert_eq!( to_base(&hash(&MAINNET_STORAGE_USAGE_DELTA)), diff --git a/nearcore/src/runtime/mod.rs b/nearcore/src/runtime/mod.rs index c1ee80bb053..0abe1c54c37 100644 --- a/nearcore/src/runtime/mod.rs +++ b/nearcore/src/runtime/mod.rs @@ -291,8 +291,9 @@ impl NightshadeRuntime { ) -> Vec { let genesis_hash = genesis.json_hash(); let stored_hash = get_genesis_hash(&store).expect("Store failed on genesis intialization"); - if let Some(hash) = stored_hash { - assert_eq!(hash, genesis_hash, "Storage already exists, but has a different genesis"); + if let Some(_hash) = stored_hash { + // TODO: re-enable this check (#4447) + //assert_eq!(hash, genesis_hash, "Storage already exists, but has a different genesis"); get_genesis_state_roots(&store) .expect("Store failed on genesis intialization") .expect("Genesis state roots not found in storage") diff --git a/neard/Cargo.toml b/neard/Cargo.toml index 9c7ac8a36ab..b1692f7d1e7 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -43,15 +43,9 @@ json_rpc = ["nearcore/json_rpc"] protocol_feature_evm = ["nearcore/protocol_feature_evm"] protocol_feature_alt_bn128 = ["nearcore/protocol_feature_alt_bn128"] protocol_feature_block_header_v3 = ["nearcore/protocol_feature_block_header_v3"] -protocol_feature_add_account_versions = ["nearcore/protocol_feature_add_account_versions"] -protocol_feature_tx_size_limit = ["nearcore/protocol_feature_tx_size_limit"] -protocol_feature_allow_create_account_on_delete = ["nearcore/protocol_feature_allow_create_account_on_delete"] -protocol_feature_fix_storage_usage = ["nearcore/protocol_feature_fix_storage_usage"] nightly_protocol_features = ["nearcore/nightly_protocol_features"] nightly_protocol = ["nearcore/nightly_protocol"] protocol_feature_restore_receipts_after_fix = ["nearcore/protocol_feature_restore_receipts_after_fix"] -protocol_feature_cap_max_gas_price = ["nearcore/protocol_feature_cap_max_gas_price"] -protocol_feature_math_extension = ["nearcore/protocol_feature_math_extension"] sandbox = ["nearcore/sandbox"] diff --git a/runtime/near-vm-errors/Cargo.toml b/runtime/near-vm-errors/Cargo.toml index 5c0249372ee..e186a7830da 100644 --- a/runtime/near-vm-errors/Cargo.toml +++ b/runtime/near-vm-errors/Cargo.toml @@ -22,7 +22,6 @@ near-rpc-error-macro = { path = "../../tools/rpctypegen/macro", version = "0.1.0 [features] dump_errors_schema = ["near-rpc-error-macro/dump_errors_schema"] -protocol_feature_math_extension = [] protocol_feature_alt_bn128 = [] [package.metadata.workspaces] diff --git a/runtime/near-vm-errors/src/lib.rs b/runtime/near-vm-errors/src/lib.rs index 8bfbf37b216..fde8c7f6f0b 100644 --- a/runtime/near-vm-errors/src/lib.rs +++ b/runtime/near-vm-errors/src/lib.rs @@ -206,15 +206,14 @@ pub enum HostError { ContractSizeExceeded { size: u64, limit: u64 }, /// The host function was deprecated. Deprecated { method_name: String }, + /// General errors for ECDSA recover. + ECRecoverError { msg: String }, /// Deserialization error for alt_bn128 functions #[cfg(feature = "protocol_feature_alt_bn128")] AltBn128DeserializationError { msg: String }, /// Serialization error for alt_bn128 functions #[cfg(feature = "protocol_feature_alt_bn128")] AltBn128SerializationError { msg: String }, - /// General errors for ECDSA recover. - #[cfg(feature = "protocol_feature_math_extension")] - ECRecoverError { msg: String }, } /// Errors specifically from native EVM. @@ -501,7 +500,6 @@ impl std::fmt::Display for HostError { AltBn128DeserializationError { msg } => write!(f, "AltBn128 deserialization error: {}", msg), #[cfg(feature = "protocol_feature_alt_bn128")] AltBn128SerializationError { msg } => write!(f, "AltBn128 serialization error: {}", msg), - #[cfg(feature = "protocol_feature_math_extension")] 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 853dae947d5..eb36f82171d 100644 --- a/runtime/near-vm-logic/Cargo.toml +++ b/runtime/near-vm-logic/Cargo.toml @@ -37,8 +37,6 @@ serde_json = {version= "1", features= ["preserve_order"]} default = [] protocol_feature_evm = ["near-primitives-core/protocol_feature_evm"] protocol_feature_alt_bn128 = ["bn", "near-primitives-core/protocol_feature_alt_bn128", "near-vm-errors/protocol_feature_alt_bn128"] -protocol_feature_allow_create_account_on_delete = [] -protocol_feature_math_extension = ["near-primitives/protocol_feature_math_extension", "near-vm-errors/protocol_feature_math_extension"] # Use this feature to enable counting of fees and costs applied. costs_counting = [] diff --git a/runtime/near-vm-logic/src/logic.rs b/runtime/near-vm-logic/src/logic.rs index b80007c8e11..29033e854dc 100644 --- a/runtime/near-vm-logic/src/logic.rs +++ b/runtime/near-vm-logic/src/logic.rs @@ -5,7 +5,6 @@ use crate::types::{PromiseIndex, PromiseResult, ReceiptIndex, ReturnData}; use crate::utils::split_method_names; use crate::ValuePtr; use byteorder::ByteOrder; -#[cfg(feature = "protocol_feature_math_extension")] use near_crypto::Secp256K1Signature; use near_primitives::checked_feature; use near_primitives::version::is_implicit_account_creation_enabled; @@ -965,7 +964,6 @@ impl<'a> VMLogic<'a> { /// Where `message_blocks` is `(value_len + 9).div_ceil(64)`. /// /// `base + write_register_base + write_register_byte * num_bytes + ripemd160_base + ripemd160_block * message_blocks` - #[cfg(feature = "protocol_feature_math_extension")] pub fn ripemd160(&mut self, value_len: u64, value_ptr: u64, register_id: u64) -> Result<()> { self.gas_counter.pay_base(ripemd160_base)?; let value = self.get_vec_from_memory_or_register(value_ptr, value_len)?; @@ -1005,7 +1003,6 @@ impl<'a> VMLogic<'a> { /// # Cost /// /// `base + write_register_base + write_register_byte * 64 + ecrecover_base` - #[cfg(feature = "protocol_feature_math_extension")] pub fn ecrecover( &mut self, hash_len: u64, @@ -1877,11 +1874,7 @@ impl<'a> VMLogic<'a> { ActionCosts::delete_account, )?; - if checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - self.current_protocol_version - ) { + if checked_feature!("stable", AllowCreateAccountOnDelete, self.current_protocol_version) { let receiver_id = self.get_account_by_receipt(&receipt_idx); let sir = receiver_id == &beneficiary_id; let is_receiver_implicit = diff --git a/runtime/near-vm-logic/tests/test_miscs.rs b/runtime/near-vm-logic/tests/test_miscs.rs index aaead836e5f..0d65de6faf7 100644 --- a/runtime/near-vm-logic/tests/test_miscs.rs +++ b/runtime/near-vm-logic/tests/test_miscs.rs @@ -530,7 +530,6 @@ fn test_keccak512() { }); } -#[cfg(feature = "protocol_feature_math_extension")] #[test] fn test_ripemd160() { let mut logic_builder = VMLogicBuilder::default(); @@ -560,7 +559,6 @@ fn test_ripemd160() { }); } -#[cfg(feature = "protocol_feature_math_extension")] #[test] fn test_ecrecover() { let mut logic_builder = VMLogicBuilder::default(); diff --git a/runtime/near-vm-runner-standalone/Cargo.toml b/runtime/near-vm-runner-standalone/Cargo.toml index b2a72fae1f5..4b06d43a895 100644 --- a/runtime/near-vm-runner-standalone/Cargo.toml +++ b/runtime/near-vm-runner-standalone/Cargo.toml @@ -42,12 +42,8 @@ no_cache = ["near-vm-runner/no_cache"] protocol_feature_evm = ["near-primitives/protocol_feature_evm"] protocol_feature_alt_bn128 = ["near-vm-logic/protocol_feature_alt_bn128", "near-vm-runner/protocol_feature_alt_bn128"] protocol_feature_block_header_v3 = ["near-primitives/protocol_feature_block_header_v3"] -protocol_feature_add_account_versions = ["near-primitives/protocol_feature_add_account_versions"] -protocol_feature_tx_size_limit = ["near-primitives/protocol_feature_tx_size_limit"] -protocol_feature_fix_storage_usage = ["near-primitives/protocol_feature_fix_storage_usage"] -nightly_protocol_features = ["nightly_protocol", "near-primitives/nightly_protocol_features", "protocol_feature_evm", "protocol_feature_block_header_v3", "protocol_feature_alt_bn128", "protocol_feature_add_account_versions", "protocol_feature_tx_size_limit", "protocol_feature_fix_storage_usage", "protocol_feature_restore_receipts_after_fix", "protocol_feature_cap_max_gas_price"] +nightly_protocol_features = ["nightly_protocol", "near-primitives/nightly_protocol_features", "protocol_feature_evm", "protocol_feature_block_header_v3", "protocol_feature_alt_bn128", "protocol_feature_restore_receipts_after_fix"] protocol_feature_restore_receipts_after_fix = ["near-primitives/protocol_feature_restore_receipts_after_fix"] -protocol_feature_cap_max_gas_price = ["near-primitives/protocol_feature_cap_max_gas_price"] nightly_protocol = ["near-primitives/nightly_protocol"] [package.metadata.workspaces] diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 3d831a27047..2f64b58cd66 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -65,10 +65,6 @@ protocol_feature_alt_bn128 = [ "near-primitives/protocol_feature_alt_bn128", "near-vm-errors/protocol_feature_alt_bn128" ] -protocol_feature_math_extension = [ - "near-vm-logic/protocol_feature_math_extension", - "near-primitives/protocol_feature_math_extension" -] [package.metadata.cargo-udeps.ignore] # `no_cache` feature leads to an unused `cached` crate diff --git a/runtime/near-vm-runner/src/imports.rs b/runtime/near-vm-runner/src/imports.rs index 5fcdb3083e0..c0ab4dac927 100644 --- a/runtime/near-vm-runner/src/imports.rs +++ b/runtime/near-vm-runner/src/imports.rs @@ -221,8 +221,8 @@ wrapped_imports! { sha256<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, keccak256<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, keccak512<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, - #["protocol_feature_math_extension", MathExtension] ripemd160<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, - #["protocol_feature_math_extension", MathExtension] ecrecover<[hash_len: u64, hash_ptr: u64, sign_len: u64, sig_ptr: u64, v: u64, malleability_flag: u64, register_id: u64] -> [u64]>, + ripemd160<[value_len: u64, value_ptr: u64, register_id: u64] -> []>, + ecrecover<[hash_len: u64, hash_ptr: u64, sign_len: u64, sig_ptr: u64, v: u64, malleability_flag: u64, register_id: u64] -> [u64]>, // ##################### // # Miscellaneous API # // ##################### diff --git a/runtime/runtime-params-estimator/Cargo.toml b/runtime/runtime-params-estimator/Cargo.toml index c3d904975f9..08e1e143b80 100644 --- a/runtime/runtime-params-estimator/Cargo.toml +++ b/runtime/runtime-params-estimator/Cargo.toml @@ -56,7 +56,7 @@ no_cache = ["node-runtime/no_cache", "near-store/no_cache"] wasmtime = ["near-vm-runner/wasmtime_default"] lightbeam = ["wasmtime", "near-vm-runner/lightbeam"] nightly_protocol = ["near-primitives/nightly_protocol"] -nightly_protocol_features = ["protocol_feature_alt_bn128", "protocol_feature_evm", "protocol_feature_math_extension"] +nightly_protocol_features = ["protocol_feature_alt_bn128", "protocol_feature_evm"] protocol_feature_alt_bn128 = [ "near-vm-logic/protocol_feature_alt_bn128", "near-vm-runner/protocol_feature_alt_bn128", @@ -73,10 +73,3 @@ protocol_feature_evm = [ "testlib/protocol_feature_evm" ] sandbox = ["node-runtime/sandbox", "state-viewer/sandbox"] -protocol_feature_math_extension = [ - "near-primitives/protocol_feature_math_extension", - "near-vm-logic/protocol_feature_math_extension", - "near-vm-runner/protocol_feature_math_extension", - "nearcore/protocol_feature_math_extension", - "node-runtime/protocol_feature_math_extension" -] \ No newline at end of file diff --git a/runtime/runtime-params-estimator/src/cases.rs b/runtime/runtime-params-estimator/src/cases.rs index fc9639783fa..8b2548055c5 100644 --- a/runtime/runtime-params-estimator/src/cases.rs +++ b/runtime/runtime-params-estimator/src/cases.rs @@ -194,11 +194,8 @@ pub enum Metric { keccak256_10kib_10k, keccak512_10b_10k, keccak512_10kib_10k, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_10b_10k, - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_10kib_10k, - #[cfg(feature = "protocol_feature_math_extension")] ecrecover_10k, #[cfg(feature = "protocol_feature_alt_bn128")] alt_bn128_g1_multiexp_1_1k, @@ -561,9 +558,9 @@ pub fn run(mut config: Config, only_compile: bool) -> RuntimeConfig { keccak256_10kib_10k => keccak256_10kib_10k, keccak512_10b_10k => keccak512_10b_10k, keccak512_10kib_10k => keccak512_10kib_10k, - #["protocol_feature_math_extension"] ripemd160_10b_10k => ripemd160_10b_10k, - #["protocol_feature_math_extension"] ripemd160_10kib_10k => ripemd160_10kib_10k, - #["protocol_feature_math_extension"] ecrecover_10k => ecrecover_10k, + ripemd160_10b_10k => ripemd160_10b_10k, + ripemd160_10kib_10k => ripemd160_10kib_10k, + ecrecover_10k => ecrecover_10k, #["protocol_feature_alt_bn128"] alt_bn128_g1_multiexp_1_1k => alt_bn128_g1_multiexp_1_1k, #["protocol_feature_alt_bn128"] alt_bn128_g1_multiexp_10_1k => alt_bn128_g1_multiexp_10_1k, #["protocol_feature_alt_bn128"] alt_bn128_g1_sum_1_1k => alt_bn128_g1_sum_1_1k, @@ -746,11 +743,8 @@ fn get_ext_costs_config(measurement: &Measurements, config: &Config) -> ExtCosts keccak256_byte: measured_to_gas(metric, &measured, keccak256_byte), keccak512_base: measured_to_gas(metric, &measured, keccak512_base), keccak512_byte: measured_to_gas(metric, &measured, keccak512_byte), - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_base: measured_to_gas(metric, &measured, ripemd160_base), - #[cfg(feature = "protocol_feature_math_extension")] ripemd160_block: measured_to_gas(metric, &measured, ripemd160_block), - #[cfg(feature = "protocol_feature_math_extension")] ecrecover_base: measured_to_gas(metric, &measured, ecrecover_base), log_base: measured_to_gas(metric, &measured, log_base), log_byte: measured_to_gas(metric, &measured, log_byte), diff --git a/runtime/runtime-params-estimator/src/ext_costs_generator.rs b/runtime/runtime-params-estimator/src/ext_costs_generator.rs index bb9ad9aeb2d..e9031c5504c 100644 --- a/runtime/runtime-params-estimator/src/ext_costs_generator.rs +++ b/runtime/runtime-params-estimator/src/ext_costs_generator.rs @@ -65,13 +65,10 @@ impl ExtCostsGenerator { self.extract(keccak512_10b_10k, keccak512_base); self.extract(keccak512_10kib_10k, keccak512_byte); - #[cfg(feature = "protocol_feature_math_extension")] - { - self.extract(ripemd160_10b_10k, ripemd160_base); - self.extract(ripemd160_10kib_10k, ripemd160_block); + self.extract(ripemd160_10b_10k, ripemd160_base); + self.extract(ripemd160_10kib_10k, ripemd160_block); - self.extract(ecrecover_10k, ecrecover_base); - } + self.extract(ecrecover_10k, ecrecover_base); #[cfg(feature = "protocol_feature_alt_bn128")] { diff --git a/runtime/runtime-params-estimator/test-contract/Cargo.toml b/runtime/runtime-params-estimator/test-contract/Cargo.toml index e3ae9758de3..5199091d0fb 100644 --- a/runtime/runtime-params-estimator/test-contract/Cargo.toml +++ b/runtime/runtime-params-estimator/test-contract/Cargo.toml @@ -22,6 +22,5 @@ members = [] nightly_protocol_features = ["protocol_feature_alt_bn128", "protocol_feature_evm"] protocol_feature_alt_bn128 = [] protocol_feature_evm = [] -protocol_feature_math_extension = [] payload = [] diff --git a/runtime/runtime-params-estimator/test-contract/src/lib.rs b/runtime/runtime-params-estimator/test-contract/src/lib.rs index d506db02133..807fe6dd7ef 100644 --- a/runtime/runtime-params-estimator/test-contract/src/lib.rs +++ b/runtime/runtime-params-estimator/test-contract/src/lib.rs @@ -47,10 +47,16 @@ extern "C" { fn sha256(value_len: u64, value_ptr: u64, register_id: u64); fn keccak256(value_len: u64, value_ptr: u64, register_id: u64); fn keccak512(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_math_extension")] fn ripemd160(value_len: u64, value_ptr: u64, register_id: u64); - #[cfg(feature = "protocol_feature_math_extension")] - fn ecrecover(hash_len: u64, hash_ptr: u64, sig_len: u64, sig_ptr: u64, v: u64, malleability_flag: u64, register_id: u64) -> u64; + fn ecrecover( + hash_len: u64, + hash_ptr: u64, + sig_len: u64, + sig_ptr: u64, + v: u64, + malleability_flag: u64, + register_id: u64, + ) -> u64; // ##################### // # Miscellaneous API # // ##################### @@ -432,7 +438,6 @@ pub unsafe fn keccak512_10kib_10k() { // and `write_register_byte`. However `ripemd160` computation is more expensive than register writing // so we are okay overcharging it. // Compute ripemd160 on 10b 10k times. -#[cfg(feature = "protocol_feature_math_extension")] #[no_mangle] pub unsafe fn ripemd160_10b_10k() { let buffer = [65u8; 10]; @@ -444,7 +449,6 @@ pub unsafe fn ripemd160_10b_10k() { // and `write_register_byte`. However `ripemd160` computation is more expensive than register writing // so we are okay overcharging it. // Compute ripemd160 on 10kib 10k times. -#[cfg(feature = "protocol_feature_math_extension")] #[no_mangle] pub unsafe fn ripemd160_10kib_10k() { let buffer = [65u8; 10240]; @@ -457,7 +461,6 @@ pub unsafe fn ripemd160_10kib_10k() { // `write_register_byte`. However `ecrecover` computation is more expensive than register writing // so we are okay overcharging it. // Compute ecrecover 10k times. -#[cfg(feature = "protocol_feature_math_extension")] #[no_mangle] pub unsafe fn ecrecover_10k() { let hash_buffer: [u8; 32] = [ @@ -472,7 +475,7 @@ pub unsafe fn ecrecover_10k() { 0xbb, 0x01, 0xc1, 0xd8, 0x1d, 0x10, 0xe6, 0x9f, 0x03, 0x84, 0xe6, 0x75, 0xc3, 0x2b, 0x39, 0x64, 0x3b, 0xe8, 0x92, ]; - + for _ in 0..10_000 { ecrecover(32, hash_buffer.as_ptr() as _, 64, sig_buffer.as_ptr() as _, 0, 0, 0); } diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index 0b3739da634..135ff87283b 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -53,17 +53,7 @@ protocol_feature_alt_bn128 = [ "near-vm-runner/protocol_feature_alt_bn128", "near-vm-errors/protocol_feature_alt_bn128", ] -protocol_feature_tx_size_limit = [] -protocol_feature_allow_create_account_on_delete = ["near-primitives/protocol_feature_allow_create_account_on_delete", "near-vm-logic/protocol_feature_allow_create_account_on_delete"] -protocol_feature_fix_storage_usage = ["near-primitives/protocol_feature_fix_storage_usage"] protocol_feature_restore_receipts_after_fix = [] -protocol_feature_count_refund_receipts_in_gas_limit = ["near-primitives/protocol_feature_count_refund_receipts_in_gas_limit"] -protocol_feature_math_extension = [ - "near-primitives/protocol_feature_math_extension", - "near-vm-logic/protocol_feature_math_extension", - "near-vm-runner/protocol_feature_math_extension", - "near-vm-errors/protocol_feature_math_extension" -] sandbox = [] [dev-dependencies] diff --git a/runtime/runtime/src/actions.rs b/runtime/runtime/src/actions.rs index 7b70700d180..5f9d587a3e5 100644 --- a/runtime/runtime/src/actions.rs +++ b/runtime/runtime/src/actions.rs @@ -516,11 +516,7 @@ pub(crate) fn action_delete_account( // We use current amount as a pay out to beneficiary. let account_balance = account.as_ref().unwrap().amount(); if account_balance > 0 { - if checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - current_protocol_version - ) { + if checked_feature!("stable", AllowCreateAccountOnDelete, current_protocol_version) { let sender_is_receiver = account_id == &delete_account.beneficiary_id; let is_receiver_implicit = is_implicit_account_creation_enabled(current_protocol_version) diff --git a/runtime/runtime/src/config.rs b/runtime/runtime/src/config.rs index 204248cea34..51af260446f 100644 --- a/runtime/runtime/src/config.rs +++ b/runtime/runtime/src/config.rs @@ -187,11 +187,7 @@ pub fn prepaid_exec_fee( let extra_prepaid_gas = match action { Action::DeleteAccount(DeleteAccountAction { beneficiary_id }) => { - if checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - current_protocol_version - ) { + if checked_feature!("stable", AllowCreateAccountOnDelete, current_protocol_version) { let sender_is_receiver = beneficiary_id == receiver_id; let is_receiver_implicit = is_implicit_account_creation_enabled(current_protocol_version) diff --git a/runtime/runtime/src/lib.rs b/runtime/runtime/src/lib.rs index 59592bde589..b552cc5648c 100644 --- a/runtime/runtime/src/lib.rs +++ b/runtime/runtime/src/lib.rs @@ -559,7 +559,7 @@ impl Runtime { // Here we don't set result.gas_burnt to be zero if CountRefundReceiptsInGasLimit is // enabled because we want it to be counted in gas limit calculation later if !checked_feature!( - "protocol_feature_count_refund_receipts_in_gas_limit", + "stable", CountRefundReceiptsInGasLimit, apply_state.current_protocol_version ) { @@ -1094,12 +1094,7 @@ impl Runtime { migration_flags: &MigrationFlags, protocol_version: ProtocolVersion, ) -> Result<(Gas, Vec), StorageError> { - #[cfg(feature = "protocol_feature_fix_storage_usage")] let mut gas_used: Gas = 0; - - #[cfg(not(feature = "protocol_feature_fix_storage_usage"))] - let gas_used: Gas = 0; - #[cfg(feature = "protocol_feature_fix_storage_usage")] if ProtocolFeature::FixStorageUsage.protocol_version() == protocol_version && migration_flags.is_first_block_of_version { @@ -1138,8 +1133,6 @@ impl Runtime { vec![] }; - #[cfg(not(feature = "protocol_feature_fix_storage_usage"))] - (state_update, migration_data, migration_flags, protocol_version); Ok((gas_used, receipts_to_restore)) } @@ -1668,17 +1661,7 @@ mod tests { store_update.commit().unwrap(); let state = tries.new_trie_update(0, root); let account = get_account(&state, &alice_account()).unwrap().unwrap(); - // Check that refund receipts are delayed if CountRefundReceiptsInGasLimit is enabled, - // and otherwise processed all at once - let capped_i = if checked_feature!( - "protocol_feature_count_refund_receipts_in_gas_limit", - CountRefundReceiptsInGasLimit, - apply_state.current_protocol_version - ) { - std::cmp::min(i, n) - } else { - n - }; + let capped_i = std::cmp::min(i, n); assert_eq!( account.amount(), initial_balance diff --git a/runtime/runtime/src/verifier.rs b/runtime/runtime/src/verifier.rs index c08bc8be535..b1e36c8e846 100644 --- a/runtime/runtime/src/verifier.rs +++ b/runtime/runtime/src/verifier.rs @@ -55,17 +55,14 @@ pub fn validate_transaction( return Err(InvalidTxError::InvalidSignature.into()); } - #[cfg(feature = "protocol_feature_tx_size_limit")] - { - let transaction_size = signed_transaction.get_size(); - let max_transaction_size = config.wasm_config.limit_config.max_transaction_size; - if transaction_size > max_transaction_size { - return Err(InvalidTxError::TransactionSizeExceeded { - size: transaction_size, - limit: max_transaction_size, - } - .into()); + let transaction_size = signed_transaction.get_size(); + let max_transaction_size = config.wasm_config.limit_config.max_transaction_size; + if transaction_size > max_transaction_size { + return Err(InvalidTxError::TransactionSizeExceeded { + size: transaction_size, + limit: max_transaction_size, } + .into()); } validate_actions(&config.wasm_config.limit_config, &transaction.actions) @@ -1186,7 +1183,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_tx_size_limit")] fn test_validate_transaction_exceeding_tx_size_limit() { let (signer, mut state_update, gas_price) = setup_common(TESTING_INIT_BALANCE, 0, Some(AccessKey::full_access())); diff --git a/runtime/runtime/tests/test_async_calls.rs b/runtime/runtime/tests/test_async_calls.rs index be9eed9122b..d134931d42f 100644 --- a/runtime/runtime/tests/test_async_calls.rs +++ b/runtime/runtime/tests/test_async_calls.rs @@ -2,10 +2,8 @@ use crate::runtime_group_tools::RuntimeGroup; use borsh::ser::BorshSerialize; use near_crypto::{InMemorySigner, KeyType}; use near_primitives::account::{AccessKeyPermission, FunctionCallPermission}; -use near_primitives::checked_feature; use near_primitives::hash::CryptoHash; use near_primitives::receipt::{ActionReceipt, ReceiptEnum}; -use near_primitives::version::PROTOCOL_VERSION; pub mod runtime_group_tools; @@ -942,22 +940,14 @@ fn test_create_account_add_key_call_delete_key_delete_account() { } => [ref2] ); - if checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - PROTOCOL_VERSION - ) { - assert_receipts!(group, "near_3" => r3 @ "near_2", + assert_receipts!(group, "near_3" => r3 @ "near_2", ReceiptEnum::Action(ActionReceipt{actions, ..}), {}, actions, a0, Action::Transfer(TransferAction{deposit}), { assert_eq!(*deposit, TESTING_INIT_BALANCE / 2); } => [ref3] ); - assert_refund!(group, ref3 @ "near_0"); - } else { - assert_refund!(group, r3 @ "near_2"); - } + assert_refund!(group, ref3 @ "near_0"); assert_refund!(group, ref0 @ "near_0"); assert_refund!(group, ref1 @ "near_0"); diff --git a/test-utils/testlib/Cargo.toml b/test-utils/testlib/Cargo.toml index 02d673e316a..01b4018b7ff 100644 --- a/test-utils/testlib/Cargo.toml +++ b/test-utils/testlib/Cargo.toml @@ -55,7 +55,5 @@ protocol_feature_alt_bn128 = [ "near-vm-errors/protocol_feature_alt_bn128", ] protocol_feature_evm = ["near-evm-runner/protocol_feature_evm", "near-primitives/protocol_feature_evm", "nearcore/protocol_feature_evm", "node-runtime/protocol_feature_evm", "near-chain-configs/protocol_feature_evm", "near-chain/protocol_feature_evm"] -protocol_feature_tx_size_limit = ["near-primitives/protocol_feature_tx_size_limit", "node-runtime/protocol_feature_tx_size_limit"] -protocol_feature_allow_create_account_on_delete = ["near-primitives/protocol_feature_allow_create_account_on_delete"] nightly_protocol_features = ["nightly_protocol", "nearcore/nightly_protocol_features"] nightly_protocol = ["nearcore/nightly_protocol"] diff --git a/test-utils/testlib/src/fees_utils.rs b/test-utils/testlib/src/fees_utils.rs index a81082dbbff..4e44133fcdb 100644 --- a/test-utils/testlib/src/fees_utils.rs +++ b/test-utils/testlib/src/fees_utils.rs @@ -1,9 +1,7 @@ //! Helper functions to compute the costs of certain actions assuming they succeed and the only //! actions in the transaction batch. -use near_primitives::checked_feature; use near_primitives::runtime::fees::RuntimeFeesConfig; use near_primitives::types::{Balance, Gas}; -use near_primitives::version::PROTOCOL_VERSION; pub struct FeeHelper { pub cfg: RuntimeFeesConfig, @@ -179,23 +177,13 @@ impl FeeHelper { let send_gas = self.cfg.action_receipt_creation_config.send_fee(false) + self.cfg.action_creation_config.delete_account_cost.send_fee(false); - let total_fee = if checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - PROTOCOL_VERSION - ) { - exec_gas - + send_gas - + if implicit_account_created { - self.create_account_transfer_full_key_fee() - } else { - self.transfer_fee() - } - } else { - // Workaround unused variable warning - let _ = implicit_account_created; - exec_gas + send_gas - }; + let total_fee = exec_gas + + send_gas + + if implicit_account_created { + self.create_account_transfer_full_key_fee() + } else { + self.transfer_fee() + }; self.gas_to_balance(total_fee) } diff --git a/test-utils/testlib/src/standard_test_cases.rs b/test-utils/testlib/src/standard_test_cases.rs index 89dec202d26..13269127f59 100644 --- a/test-utils/testlib/src/standard_test_cases.rs +++ b/test-utils/testlib/src/standard_test_cases.rs @@ -4,7 +4,6 @@ use assert_matches::assert_matches; use near_crypto::{InMemorySigner, KeyType}; use near_jsonrpc_primitives::errors::ServerError; use near_primitives::account::{AccessKey, AccessKeyPermission, FunctionCallPermission}; -use near_primitives::checked_feature; use near_primitives::errors::{ ActionError, ActionErrorKind, ContractCallError, InvalidAccessKeyError, InvalidTxError, TxExecutionError, @@ -22,7 +21,6 @@ use crate::fees_utils::FeeHelper; use crate::node::Node; use crate::runtime_utils::{alice_account, bob_account, eve_dot_alice_account, implicit_account}; use crate::user::User; -use near_primitives::version::ProtocolVersion; /// The amount to send with function call. const FUNCTION_CALL_AMOUNT: Balance = TESTING_INIT_BALANCE / 10; @@ -1209,7 +1207,7 @@ pub fn test_delete_account_ok(node: impl Node) { assert!(node.user().view_account(&eve_dot_alice_account()).is_err()); } -pub fn test_delete_account_fail(node: impl Node, protocol_version: ProtocolVersion) { +pub fn test_delete_account_fail(node: impl Node) { let money_used = TESTING_INIT_BALANCE / 2; let node_user = node.user(); let _ = node_user.create_account( @@ -1220,16 +1218,8 @@ pub fn test_delete_account_fail(node: impl Node, protocol_version: ProtocolVersi ); let initial_amount = node_user.view_account(&node.account_id().unwrap()).unwrap().amount; let fee_helper = fee_helper(&node); - let delete_account_cost = fee_helper.prepaid_delete_account_cost_for_explicit_account() - - if checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - protocol_version - ) { - fee_helper.transfer_cost() - } else { - 0 - }; + let delete_account_cost = + fee_helper.prepaid_delete_account_cost_for_explicit_account() - fee_helper.transfer_cost(); let transaction_result = node_user.delete_account(alice_account(), eve_dot_alice_account()).unwrap(); @@ -1271,10 +1261,7 @@ pub fn test_delete_account_no_account(node: impl Node) { assert_eq!(transaction_result.receipts_outcome.len(), 2); } -pub fn test_delete_account_implicit_beneficiary_account( - node: impl Node, - protocol_version: ProtocolVersion, -) { +pub fn test_delete_account_implicit_beneficiary_account(node: impl Node) { let money_used = TESTING_INIT_BALANCE / 2; let node_user = node.user(); @@ -1285,7 +1272,6 @@ pub fn test_delete_account_implicit_beneficiary_account( money_used, ); - #[cfg(feature = "protocol_feature_allow_create_account_on_delete")] let eve_dot_alice_account_balance = node.user().view_account(&eve_dot_alice_account().clone()).unwrap().amount; let beneficiary_id = implicit_account(); @@ -1299,28 +1285,16 @@ pub fn test_delete_account_implicit_beneficiary_account( .unwrap(); assert_eq!(transaction_result.status, FinalExecutionStatus::SuccessValue(String::new())); - let view_result = node_user.view_account(&beneficiary_id); - - checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - protocol_version, - { - let fee_helper = fee_helper(&node); - let delete_account_cost = fee_helper.prepaid_delete_account_cost_for_implicit_account(); - assert_eq!( - node.user().view_account(&implicit_account().clone()).unwrap().amount, - eve_dot_alice_account_balance - delete_account_cost - ); - }, - { - assert!(view_result.is_err()); - } + let fee_helper = fee_helper(&node); + let delete_account_cost = fee_helper.prepaid_delete_account_cost_for_implicit_account(); + assert_eq!( + node.user().view_account(&implicit_account().clone()).unwrap().amount, + eve_dot_alice_account_balance - delete_account_cost ); assert_eq!(transaction_result.receipts_outcome.len(), 2); } -pub fn test_delete_account_while_staking(node: impl Node, protocol_version: ProtocolVersion) { +pub fn test_delete_account_while_staking(node: impl Node) { let money_used = TESTING_INIT_BALANCE / 2; let node_user = node.user(); let _ = node_user.create_account( @@ -1353,16 +1327,7 @@ pub fn test_delete_account_while_staking(node: impl Node, protocol_version: Prot .into() ) ); - assert_eq!( - transaction_result.receipts_outcome.len(), - checked_feature!( - "protocol_feature_allow_create_account_on_delete", - AllowCreateAccountOnDelete, - protocol_version, - { 2 }, - { 1 } - ) - ); + assert_eq!(transaction_result.receipts_outcome.len(), 2); assert!(node.user().view_account(&eve_dot_alice_account()).is_ok()); }