From 1b3c02f93903b1924b06abe370cb758d308c9ef3 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 20 Feb 2023 13:00:45 +0100 Subject: [PATCH 1/2] feat: stabilize meta transactions NEP-366 Tracking issue: https://github.com/near/nearcore/issues/8075 --- chain/client/Cargo.toml | 2 - chain/client/src/test_utils.rs | 6 +- chain/rosetta-rpc/Cargo.toml | 7 +-- chain/rosetta-rpc/src/adapters/mod.rs | 4 +- core/primitives-core/Cargo.toml | 3 +- core/primitives-core/src/config.rs | 1 - core/primitives-core/src/parameter.rs | 1 - core/primitives-core/src/runtime/fees.rs | 7 +-- core/primitives/Cargo.toml | 4 -- core/primitives/src/delegate_action.rs | 42 +------------ core/primitives/src/transaction.rs | 5 +- core/primitives/src/version.rs | 12 ++-- core/primitives/src/views.rs | 9 +-- integration-tests/Cargo.toml | 6 -- .../src/tests/client/features.rs | 1 - integration-tests/src/user/mod.rs | 3 - nearcore/Cargo.toml | 6 -- neard/Cargo.toml | 4 -- runtime/runtime-params-estimator/Cargo.toml | 4 -- .../src/costs_to_runtime_config.rs | 1 - runtime/runtime/Cargo.toml | 1 - runtime/runtime/src/actions.rs | 63 ++++--------------- runtime/runtime/src/config.rs | 33 ---------- runtime/runtime/src/lib.rs | 1 - runtime/runtime/src/verifier.rs | 30 ++------- test-utils/testlib/Cargo.toml | 1 - test-utils/testlib/src/fees_utils.rs | 9 +-- tools/state-viewer/Cargo.toml | 3 +- tools/state-viewer/src/contract_accounts.rs | 2 - 29 files changed, 38 insertions(+), 233 deletions(-) diff --git a/chain/client/Cargo.toml b/chain/client/Cargo.toml index 21363ceae18..98ef7650e20 100644 --- a/chain/client/Cargo.toml +++ b/chain/client/Cargo.toml @@ -69,11 +69,9 @@ nightly = [ "nightly_protocol", "protocol_feature_flat_state", "near-chain/nightly", - "protocol_feature_nep366_delegate_action" ] sandbox = [ "near-client-primitives/sandbox", "near-chain/sandbox", ] protocol_feature_flat_state = ["near-store/protocol_feature_flat_state", "near-chain/protocol_feature_flat_state"] -protocol_feature_nep366_delegate_action = [] diff --git a/chain/client/src/test_utils.rs b/chain/client/src/test_utils.rs index e9e978ed4aa..1f7c8daec0e 100644 --- a/chain/client/src/test_utils.rs +++ b/chain/client/src/test_utils.rs @@ -36,9 +36,7 @@ use near_chunks::adapter::ShardsManagerRequestFromClient; use near_chunks::client::ShardsManagerResponse; use near_chunks::test_utils::{MockClientAdapterForShardsManager, SynchronousShardsManagerAdapter}; use near_client_primitives::types::Error; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use near_crypto::Signer; -use near_crypto::{InMemorySigner, KeyType, PublicKey}; +use near_crypto::{InMemorySigner, KeyType, PublicKey, Signer}; use near_network::test_utils::MockPeerManagerAdapter; use near_network::types::{ AccountOrPeerIdOrHash, HighestHeightPeerInfo, PartialEncodedChunkRequestMsg, @@ -54,7 +52,6 @@ use near_network::types::{ use near_o11y::testonly::TracingCapture; use near_o11y::WithSpanContextExt; use near_primitives::block::{ApprovalInner, Block, GenesisId}; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::delegate_action::{DelegateAction, NonDelegateAction, SignedDelegateAction}; use near_primitives::epoch_manager::RngSeed; use near_primitives::hash::{hash, CryptoHash}; @@ -1828,7 +1825,6 @@ impl TestEnv { } /// Wrap actions in a delegate action, put it in a transaction, sign. - #[cfg(feature = "protocol_feature_nep366_delegate_action")] pub fn meta_tx_from_actions( &mut self, actions: Vec, diff --git a/chain/rosetta-rpc/Cargo.toml b/chain/rosetta-rpc/Cargo.toml index 69f1129082f..b2e0bb02572 100644 --- a/chain/rosetta-rpc/Cargo.toml +++ b/chain/rosetta-rpc/Cargo.toml @@ -38,9 +38,4 @@ insta = "1" near-actix-test-utils = { path = "../../test-utils/actix-test-utils" } [features] -protocol_feature_nep366_delegate_action = [ - "near-primitives/protocol_feature_nep366_delegate_action" -] -nightly = [ - "protocol_feature_nep366_delegate_action" -] \ No newline at end of file +nightly = [] \ No newline at end of file diff --git a/chain/rosetta-rpc/src/adapters/mod.rs b/chain/rosetta-rpc/src/adapters/mod.rs index 65549bf7f56..6ce148bc197 100644 --- a/chain/rosetta-rpc/src/adapters/mod.rs +++ b/chain/rosetta-rpc/src/adapters/mod.rs @@ -419,8 +419,8 @@ impl From for Vec { ); operations.push(deploy_contract_operation); } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] - near_primitives::transaction::Action::Delegate(_) => todo!(), + // TODO(#8469): Implement delegate action support, for now they are ignored. + near_primitives::transaction::Action::Delegate(_) => (), } } operations diff --git a/core/primitives-core/Cargo.toml b/core/primitives-core/Cargo.toml index 5aa3bd25ae4..861e7203a9b 100644 --- a/core/primitives-core/Cargo.toml +++ b/core/primitives-core/Cargo.toml @@ -34,5 +34,4 @@ insta.workspace = true [features] default = [] -protocol_feature_nep366_delegate_action = [] -nightly = ["protocol_feature_nep366_delegate_action"] +nightly = [] diff --git a/core/primitives-core/src/config.rs b/core/primitives-core/src/config.rs index 00aa8182966..700123862a4 100644 --- a/core/primitives-core/src/config.rs +++ b/core/primitives-core/src/config.rs @@ -467,7 +467,6 @@ pub enum ActionCosts { new_action_receipt = 12, new_data_receipt_base = 13, new_data_receipt_byte = 14, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] delegate = 15, } diff --git a/core/primitives-core/src/parameter.rs b/core/primitives-core/src/parameter.rs index b5be54a0184..a521842837d 100644 --- a/core/primitives-core/src/parameter.rs +++ b/core/primitives-core/src/parameter.rs @@ -222,7 +222,6 @@ impl From for FeeParameter { match other { ActionCosts::create_account => Self::ActionCreateAccount, ActionCosts::delete_account => Self::ActionDeleteAccount, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] ActionCosts::delegate => Self::ActionDelegate, ActionCosts::deploy_contract_base => Self::ActionDeployContract, ActionCosts::deploy_contract_byte => Self::ActionDeployContractPerByte, diff --git a/core/primitives-core/src/runtime/fees.rs b/core/primitives-core/src/runtime/fees.rs index e95b4e6ee0e..ee268e5ff73 100644 --- a/core/primitives-core/src/runtime/fees.rs +++ b/core/primitives-core/src/runtime/fees.rs @@ -157,11 +157,10 @@ impl RuntimeFeesConfig { send_not_sir: 59357464, execution: 59357464, }, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] ActionCosts::delegate => Fee { - send_sir: 2319861500000, - send_not_sir: 2319861500000, - execution: 2319861500000, + send_sir: 200_000_000_000, + send_not_sir: 200_000_000_000, + execution: 200_000_000_000, }, }, } diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index 210ee397889..0b859d4b6aa 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -48,15 +48,11 @@ dump_errors_schema = ["near-rpc-error-macro/dump_errors_schema"] protocol_feature_fix_staking_threshold = [] protocol_feature_fix_contract_loading_cost = [] protocol_feature_reject_blocks_with_outdated_protocol_version = [] -protocol_feature_nep366_delegate_action = [ - "near-primitives-core/protocol_feature_nep366_delegate_action" -] nightly = [ "nightly_protocol", "protocol_feature_fix_staking_threshold", "protocol_feature_fix_contract_loading_cost", "protocol_feature_reject_blocks_with_outdated_protocol_version", - "protocol_feature_nep366_delegate_action", ] nightly_protocol = [] diff --git a/core/primitives/src/delegate_action.rs b/core/primitives/src/delegate_action.rs index 6e60d2f4c2f..52792ffedd0 100644 --- a/core/primitives/src/delegate_action.rs +++ b/core/primitives/src/delegate_action.rs @@ -38,20 +38,12 @@ pub struct DelegateAction { pub public_key: PublicKey, } -#[cfg_attr(feature = "protocol_feature_nep366_delegate_action", derive(BorshDeserialize))] -#[derive(BorshSerialize, Serialize, Deserialize, PartialEq, Eq, Clone, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Clone, Debug)] pub struct SignedDelegateAction { pub delegate_action: DelegateAction, pub signature: Signature, } -#[cfg(not(feature = "protocol_feature_nep366_delegate_action"))] -impl borsh::de::BorshDeserialize for SignedDelegateAction { - fn deserialize(_buf: &mut &[u8]) -> ::core::result::Result { - return Err(Error::new(ErrorKind::InvalidInput, "Delegate action isn't supported")); - } -} - impl SignedDelegateAction { pub fn verify(&self) -> bool { let delegate_action = &self.delegate_action; @@ -62,7 +54,6 @@ impl SignedDelegateAction { } } -#[cfg(feature = "protocol_feature_nep366_delegate_action")] impl From for Action { fn from(delegate_action: SignedDelegateAction) -> Self { Self::Delegate(delegate_action) @@ -112,7 +103,6 @@ mod private_non_delegate_action { #[error("attempted to construct NonDelegateAction from Action::Delegate")] pub struct IsDelegateAction; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] impl TryFrom for NonDelegateAction { type Error = IsDelegateAction; @@ -149,9 +139,7 @@ mod private_non_delegate_action { #[cfg(test)] mod tests { use super::*; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] use crate::transaction::CreateAccountAction; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_crypto::KeyType; /// A serialized `Action::Delegate(SignedDelegateAction)` for testing. @@ -167,7 +155,6 @@ mod tests { "0000000000000000000000000000000000000000000000000000000000" ); - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn create_delegate_action(actions: Vec) -> Action { Action::Delegate(SignedDelegateAction { delegate_action: DelegateAction { @@ -186,7 +173,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_deserialization() { // Expected an error. Buffer is empty assert_eq!( @@ -218,35 +204,9 @@ mod tests { ); } - /// Check that we will not accept delegate actions with the feature - /// disabled. - /// - /// This test is to ensure that while working on meta transactions, we don't - /// accientally start accepting delegate actions in receipts. Otherwise, a - /// malicious validator could create receipts that include delegate actions - /// and other nodes will accept such a receipt. - /// - /// TODO: Before stabilizing "protocol_feature_nep366_delegate_action" we - /// have to replace this rest with a test that checks that we discard - /// delegate actions for earlier versions somewhere in validation. - #[test] - #[cfg(not(feature = "protocol_feature_nep366_delegate_action"))] - fn test_delegate_action_deserialization() { - let serialized_delegate_action = hex::decode(DELEGATE_ACTION_HEX).expect("invalid hex"); - - // DelegateAction isn't supported - assert_eq!( - Action::try_from_slice(&serialized_delegate_action).map_err(|e| e.kind()), - Err(ErrorKind::InvalidInput) - ); - } - /// Check that the hard-coded delegate action is valid. #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_deserialization_hard_coded() { - use crate::transaction::CreateAccountAction; - let serialized_delegate_action = hex::decode(DELEGATE_ACTION_HEX).expect("invalid hex"); // The hex data is the same as the one we create below. let delegate_action = diff --git a/core/primitives/src/transaction.rs b/core/primitives/src/transaction.rs index 51910610955..d32e6e40c68 100644 --- a/core/primitives/src/transaction.rs +++ b/core/primitives/src/transaction.rs @@ -1,4 +1,5 @@ use crate::account::AccessKey; +use crate::delegate_action::SignedDelegateAction; use crate::errors::TxExecutionError; use crate::hash::{hash, CryptoHash}; use crate::merkle::MerklePath; @@ -12,9 +13,6 @@ use std::borrow::Borrow; use std::fmt; use std::hash::{Hash, Hasher}; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use crate::delegate_action::SignedDelegateAction; - pub type LogEntry = String; #[derive( @@ -76,7 +74,6 @@ pub enum Action { AddKey(AddKeyAction), DeleteKey(DeleteKeyAction), DeleteAccount(DeleteAccountAction), - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Delegate(SignedDelegateAction), } diff --git a/core/primitives/src/version.rs b/core/primitives/src/version.rs index 4cc8cff6efd..fa18ab570d7 100644 --- a/core/primitives/src/version.rs +++ b/core/primitives/src/version.rs @@ -134,6 +134,10 @@ pub enum ProtocolFeature { AccountIdInFunctionCallPermission, /// Zero Balance Account NEP 448: https://github.com/near/NEPs/pull/448 ZeroBalanceAccount, + /// Execute a set of actions on behalf of another account. + /// + /// Meta Transaction NEP-366: https://github.com/near/NEPs/blob/master/neps/nep-0366.md + DelegateAction, /// In case not all validator seats are occupied our algorithm provide incorrect minimal seat /// price - it reports as alpha * sum_stake instead of alpha * sum_stake / (1 - alpha), where @@ -146,8 +150,6 @@ pub enum ProtocolFeature { Ed25519Verify, #[cfg(feature = "protocol_feature_reject_blocks_with_outdated_protocol_version")] RejectBlocksWithOutdatedProtocolVersions, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] - DelegateAction, } /// Both, outgoing and incoming tcp connections to peers, will be rejected if `peer's` @@ -225,7 +227,9 @@ impl ProtocolFeature { ProtocolFeature::AltBn128 => 55, ProtocolFeature::ChunkOnlyProducers | ProtocolFeature::MaxKickoutStake => 56, ProtocolFeature::AccountIdInFunctionCallPermission => 57, - ProtocolFeature::Ed25519Verify | ProtocolFeature::ZeroBalanceAccount => 59, + ProtocolFeature::Ed25519Verify + | ProtocolFeature::ZeroBalanceAccount + | ProtocolFeature::DelegateAction => 59, // Nightly features #[cfg(feature = "protocol_feature_fix_staking_threshold")] @@ -234,8 +238,6 @@ impl ProtocolFeature { ProtocolFeature::FixContractLoadingCost => 129, #[cfg(feature = "protocol_feature_reject_blocks_with_outdated_protocol_version")] ProtocolFeature::RejectBlocksWithOutdatedProtocolVersions => 132, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] - ProtocolFeature::DelegateAction => 133, } } } diff --git a/core/primitives/src/views.rs b/core/primitives/src/views.rs index 0a0ed6fdeb4..b73c9e5c4ce 100644 --- a/core/primitives/src/views.rs +++ b/core/primitives/src/views.rs @@ -11,6 +11,7 @@ use crate::block_header::{ }; use crate::challenge::{Challenge, ChallengesResult}; use crate::contract::ContractCode; +use crate::delegate_action::{DelegateAction, SignedDelegateAction}; use crate::errors::TxExecutionError; use crate::hash::{hash, CryptoHash}; use crate::merkle::{combine_hash, MerklePath}; @@ -49,8 +50,6 @@ use std::sync::Arc; use strum::IntoEnumIterator; use validator_stake_view::ValidatorStakeView; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use crate::delegate_action::{DelegateAction, SignedDelegateAction}; /// A view of the account #[derive(serde::Serialize, serde::Deserialize, Debug, Eq, PartialEq, Clone)] pub struct AccountView { @@ -1137,7 +1136,6 @@ pub enum ActionView { DeleteAccount { beneficiary_id: AccountId, }, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Delegate { delegate_action: DelegateAction, signature: Signature, @@ -1170,7 +1168,6 @@ impl From for ActionView { Action::DeleteAccount(action) => { ActionView::DeleteAccount { beneficiary_id: action.beneficiary_id } } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Action::Delegate(action) => ActionView::Delegate { delegate_action: action.delegate_action, signature: action.signature, @@ -1204,7 +1201,6 @@ impl TryFrom for Action { ActionView::DeleteAccount { beneficiary_id } => { Action::DeleteAccount(DeleteAccountAction { beneficiary_id }) } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] ActionView::Delegate { delegate_action, signature } => { Action::Delegate(SignedDelegateAction { delegate_action: delegate_action, @@ -2326,7 +2322,6 @@ pub struct ActionCreationConfigView { /// Base cost for processing a delegate action. /// /// This is on top of the costs for the actions inside the delegate action. - #[cfg(feature = "protocol_feature_nep366_delegate_action")] pub delegate_cost: Fee, } @@ -2403,7 +2398,6 @@ impl From for RuntimeConfigView { }, delete_key_cost: config.fees.fee(ActionCosts::delete_key).clone(), delete_account_cost: config.fees.fee(ActionCosts::delete_account).clone(), - #[cfg(feature = "protocol_feature_nep366_delegate_action")] delegate_cost: config.fees.fee(ActionCosts::delegate).clone(), }, storage_usage_config: StorageUsageConfigView { @@ -2449,7 +2443,6 @@ impl From for RuntimeConfig { action_fees: enum_map::enum_map! { ActionCosts::create_account => config.transaction_costs.action_creation_config.create_account_cost.clone(), ActionCosts::delete_account => config.transaction_costs.action_creation_config.delete_account_cost.clone(), - #[cfg(feature = "protocol_feature_nep366_delegate_action")] ActionCosts::delegate => config.transaction_costs.action_creation_config.delegate_cost.clone(), ActionCosts::deploy_contract_base => config.transaction_costs.action_creation_config.deploy_contract_cost.clone(), ActionCosts::deploy_contract_byte => config.transaction_costs.action_creation_config.deploy_contract_cost_per_byte.clone(), diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index e8dde3c9d70..eab6572b3d5 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -76,11 +76,6 @@ protocol_feature_reject_blocks_with_outdated_protocol_version = [ "near-chain/protocol_feature_reject_blocks_with_outdated_protocol_version" ] protocol_feature_flat_state = ["nearcore/protocol_feature_flat_state"] -protocol_feature_nep366_delegate_action = [ - "nearcore/protocol_feature_nep366_delegate_action", - "testlib/protocol_feature_nep366_delegate_action", -] - nightly = [ "nightly_protocol", @@ -88,7 +83,6 @@ nightly = [ "protocol_feature_fix_contract_loading_cost", "protocol_feature_reject_blocks_with_outdated_protocol_version", "protocol_feature_flat_state", - "protocol_feature_nep366_delegate_action", ] nightly_protocol = ["nearcore/nightly_protocol"] sandbox = [ diff --git a/integration-tests/src/tests/client/features.rs b/integration-tests/src/tests/client/features.rs index a06c606ec50..dce0e03a2e8 100644 --- a/integration-tests/src/tests/client/features.rs +++ b/integration-tests/src/tests/client/features.rs @@ -5,7 +5,6 @@ mod account_id_in_function_call_permission; mod adversarial_behaviors; mod cap_max_gas_price; mod chunk_nodes_cache; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] mod delegate_action; #[cfg(feature = "protocol_feature_fix_contract_loading_cost")] mod fix_contract_loading_cost; diff --git a/integration-tests/src/user/mod.rs b/integration-tests/src/user/mod.rs index 11400d18abf..aae9390ae51 100644 --- a/integration-tests/src/user/mod.rs +++ b/integration-tests/src/user/mod.rs @@ -5,11 +5,9 @@ use futures::{future::LocalBoxFuture, FutureExt}; use near_crypto::{PublicKey, Signer}; use near_jsonrpc_primitives::errors::ServerError; use near_primitives::account::AccessKey; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::delegate_action::{DelegateAction, NonDelegateAction, SignedDelegateAction}; use near_primitives::hash::CryptoHash; use near_primitives::receipt::Receipt; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::test_utils::create_user_test_signer; use near_primitives::transaction::{ Action, AddKeyAction, CreateAccountAction, DeleteAccountAction, DeleteKeyAction, @@ -249,7 +247,6 @@ pub trait User { /// /// The signer signs the delegate action to be sent to the receiver. The /// relayer packs that in a transaction and signs it . - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn meta_tx( &self, signer_id: AccountId, diff --git a/nearcore/Cargo.toml b/nearcore/Cargo.toml index 223e8b366f1..a657e7be5b5 100644 --- a/nearcore/Cargo.toml +++ b/nearcore/Cargo.toml @@ -108,11 +108,6 @@ protocol_feature_fix_contract_loading_cost = [ "near-vm-runner/protocol_feature_fix_contract_loading_cost", ] protocol_feature_flat_state = ["near-store/protocol_feature_flat_state", "near-chain/protocol_feature_flat_state", "node-runtime/protocol_feature_flat_state"] -protocol_feature_nep366_delegate_action = [ - "node-runtime/protocol_feature_nep366_delegate_action", - "near-primitives/protocol_feature_nep366_delegate_action", - "near-rosetta-rpc/protocol_feature_nep366_delegate_action", -] nightly = [ "nightly_protocol", @@ -124,7 +119,6 @@ nightly = [ "protocol_feature_fix_staking_threshold", "protocol_feature_fix_contract_loading_cost", "protocol_feature_flat_state", - "protocol_feature_nep366_delegate_action", ] nightly_protocol = [ "near-primitives/nightly_protocol", diff --git a/neard/Cargo.toml b/neard/Cargo.toml index 9af29ad4772..bcee6476d71 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -63,10 +63,6 @@ rosetta_rpc = ["nearcore/rosetta_rpc"] json_rpc = ["nearcore/json_rpc"] protocol_feature_fix_staking_threshold = ["nearcore/protocol_feature_fix_staking_threshold"] protocol_feature_flat_state = ["nearcore/protocol_feature_flat_state"] -protocol_feature_nep366_delegate_action = [ - "nearcore/protocol_feature_nep366_delegate_action", - "near-state-viewer/protocol_feature_nep366_delegate_action", -] nightly = [ "nightly_protocol", diff --git a/runtime/runtime-params-estimator/Cargo.toml b/runtime/runtime-params-estimator/Cargo.toml index 2a09bec1eb2..5a02a916ff4 100644 --- a/runtime/runtime-params-estimator/Cargo.toml +++ b/runtime/runtime-params-estimator/Cargo.toml @@ -69,10 +69,6 @@ nightly = [ nightly_protocol = [ "near-primitives/nightly_protocol", "near-test-contracts/nightly", - "protocol_feature_nep366_delegate_action", -] -protocol_feature_nep366_delegate_action = [ - "nearcore/protocol_feature_nep366_delegate_action", ] protocol_feature_flat_state = [ "nearcore/protocol_feature_flat_state", 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 2109ed651a1..c24b9dc29ec 100644 --- a/runtime/runtime-params-estimator/src/costs_to_runtime_config.rs +++ b/runtime/runtime-params-estimator/src/costs_to_runtime_config.rs @@ -54,7 +54,6 @@ fn runtime_fees_config(cost_table: &CostTable) -> anyhow::Result fee(Cost::ActionCreateAccount)?, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] ActionCosts::delegate => fee(Cost::ActionDelegate)?, ActionCosts::delete_account => fee(Cost::ActionDeleteAccount)?, ActionCosts::deploy_contract_base => fee(Cost::ActionDeployContractBase)?, diff --git a/runtime/runtime/Cargo.toml b/runtime/runtime/Cargo.toml index d3756d224ee..39a55e42fa5 100644 --- a/runtime/runtime/Cargo.toml +++ b/runtime/runtime/Cargo.toml @@ -36,7 +36,6 @@ dump_errors_schema = ["near-vm-errors/dump_errors_schema"] protocol_feature_flat_state = ["near-store/protocol_feature_flat_state", "near-vm-logic/protocol_feature_flat_state"] nightly_protocol = ["near-primitives/nightly_protocol"] no_cpu_compatibility_checks = ["near-vm-runner/no_cpu_compatibility_checks"] -protocol_feature_nep366_delegate_action = [] no_cache = [ "near-vm-runner/no_cache", diff --git a/runtime/runtime/src/actions.rs b/runtime/runtime/src/actions.rs index 5414f984d35..7661118b59a 100644 --- a/runtime/runtime/src/actions.rs +++ b/runtime/runtime/src/actions.rs @@ -1,4 +1,7 @@ -use crate::config::{safe_add_gas, RuntimeConfig}; +use crate::config::{ + safe_add_gas, total_prepaid_exec_fees, total_prepaid_gas, total_prepaid_send_fees, + RuntimeConfig, +}; use crate::ext::{ExternalError, RuntimeExt}; use crate::{metrics, ActionResult, ApplyState}; use borsh::{BorshDeserialize, BorshSerialize}; @@ -7,7 +10,8 @@ use near_primitives::account::{AccessKey, AccessKeyPermission, Account}; use near_primitives::checked_feature; use near_primitives::config::ViewConfig; use near_primitives::contract::ContractCode; -use near_primitives::errors::{ActionError, ActionErrorKind, RuntimeError}; +use near_primitives::delegate_action::{DelegateAction, SignedDelegateAction}; +use near_primitives::errors::{ActionError, ActionErrorKind, InvalidAccessKeyError, RuntimeError}; use near_primitives::hash::CryptoHash; use near_primitives::receipt::{ActionReceipt, Receipt, ReceiptEnum}; use near_primitives::runtime::config::AccountCreationConfig; @@ -17,7 +21,7 @@ use near_primitives::transaction::{ FunctionCallAction, StakeAction, TransferAction, }; use near_primitives::types::validator_stake::ValidatorStake; -use near_primitives::types::{AccountId, BlockHeight, EpochInfoProvider, TrieCacheMode}; +use near_primitives::types::{AccountId, BlockHeight, EpochInfoProvider, Gas, TrieCacheMode}; use near_primitives::utils::create_random_seed; use near_primitives::version::{ is_implicit_account_creation_enabled, ProtocolFeature, ProtocolVersion, @@ -32,20 +36,9 @@ use near_vm_errors::{ VMRunnerError, }; use near_vm_logic::types::PromiseResult; -use near_vm_logic::{VMContext, VMOutcome}; +use near_vm_logic::{ActionCosts, VMContext, VMOutcome}; use near_vm_runner::precompile_contract; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use crate::config::{total_prepaid_exec_fees, total_prepaid_gas, total_prepaid_send_fees}; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use near_primitives::delegate_action::{DelegateAction, SignedDelegateAction}; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use near_primitives::errors::InvalidAccessKeyError; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use near_primitives::types::Gas; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use near_vm_logic::ActionCosts; - /// Runs given function call with given context / apply state. pub(crate) fn execute_function_call( apply_state: &ApplyState, @@ -635,7 +628,6 @@ pub(crate) fn action_add_key( Ok(()) } -#[cfg(feature = "protocol_feature_nep366_delegate_action")] pub(crate) fn apply_delegate_action( state_update: &mut TrieUpdate, apply_state: &ApplyState, @@ -710,7 +702,6 @@ pub(crate) fn apply_delegate_action( } /// Returns Gas amount is required to execute Receipt and all actions it contains -#[cfg(feature = "protocol_feature_nep366_delegate_action")] fn receipt_required_gas(apply_state: &ApplyState, receipt: &Receipt) -> Result { Ok(match &receipt.receipt { ReceiptEnum::Action(action_receipt) => { @@ -739,7 +730,6 @@ fn receipt_required_gas(apply_state: &ApplyState, receipt: &Receipt) -> Result (), - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Action::Delegate(_) => (), }; Ok(()) @@ -959,7 +948,6 @@ pub(crate) fn check_account_existence( .into()); } } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Action::Delegate(_) => { if account.is_none() { return Err(ActionErrorKind::AccountDoesNotExist { @@ -975,28 +963,18 @@ pub(crate) fn check_account_existence( #[cfg(test)] mod tests { - use near_primitives::hash::hash; - use near_primitives::trie_key::TrieKey; - use near_store::test_utils::create_tries; - use super::*; use crate::near_primitives::shard_layout::ShardUId; - - #[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::account::FunctionCallPermission; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::delegate_action::NonDelegateAction; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::errors::InvalidAccessKeyError; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] + use near_primitives::hash::hash; use near_primitives::runtime::migration_data::MigrationFlags; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::transaction::CreateAccountAction; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] + use near_primitives::trie_key::TrieKey; use near_primitives::types::{EpochId, StateChangeCause}; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_store::set_account; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] + use near_store::test_utils::create_tries; use std::sync::Arc; fn test_action_create_account( @@ -1177,7 +1155,6 @@ mod tests { ); } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn create_delegate_action_receipt() -> (ActionReceipt, SignedDelegateAction) { let signed_delegate_action = SignedDelegateAction { delegate_action: DelegateAction { @@ -1214,7 +1191,6 @@ mod tests { (action_receipt, signed_delegate_action) } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn create_apply_state(block_height: BlockHeight) -> ApplyState { ApplyState { block_height, @@ -1235,7 +1211,6 @@ mod tests { } } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn setup_account( account_id: &AccountId, public_key: &PublicKey, @@ -1256,14 +1231,12 @@ mod tests { tries.new_trie_update(ShardUId::single_shard(), root) } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn non_delegate_action(action: Action) -> NonDelegateAction { NonDelegateAction::try_from(action) .expect("cannot violate type invariants, not even in test") } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action() { let mut result = ActionResult::default(); let (action_receipt, signed_delegate_action) = create_delegate_action_receipt(); @@ -1305,7 +1278,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_signature_verification() { let mut result = ActionResult::default(); let (action_receipt, mut signed_delegate_action) = create_delegate_action_receipt(); @@ -1334,7 +1306,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_max_height() { let mut result = ActionResult::default(); let (action_receipt, signed_delegate_action) = create_delegate_action_receipt(); @@ -1361,7 +1332,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_validate_sender_account() { let mut result = ActionResult::default(); let (action_receipt, signed_delegate_action) = create_delegate_action_receipt(); @@ -1408,7 +1378,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_validate_delegate_action_key_update_nonce() { let (_, signed_delegate_action) = create_delegate_action_receipt(); let sender_id = signed_delegate_action.delegate_action.sender_id.clone(); @@ -1463,7 +1432,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_doesnt_exist() { let mut result = ActionResult::default(); let (_, signed_delegate_action) = create_delegate_action_receipt(); @@ -1499,7 +1467,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_incorrect_nonce() { let mut result = ActionResult::default(); let (_, signed_delegate_action) = create_delegate_action_receipt(); @@ -1532,7 +1499,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_nonce_too_large() { let mut result = ActionResult::default(); let (_, signed_delegate_action) = create_delegate_action_receipt(); @@ -1560,7 +1526,6 @@ mod tests { ); } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_permissions( access_key: &AccessKey, delegate_action: &DelegateAction, @@ -1584,7 +1549,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_permissions_fncall() { let (_, signed_delegate_action) = create_delegate_action_receipt(); let access_key = AccessKey { @@ -1609,7 +1573,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_permissions_incorrect_action() { let (_, signed_delegate_action) = create_delegate_action_receipt(); let access_key = AccessKey { @@ -1637,7 +1600,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_permissions_actions_number() { let (_, signed_delegate_action) = create_delegate_action_receipt(); let access_key = AccessKey { @@ -1677,7 +1639,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_permissions_fncall_deposit() { let (_, signed_delegate_action) = create_delegate_action_receipt(); let access_key = AccessKey { @@ -1710,7 +1671,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_permissions_receiver_id() { let (_, signed_delegate_action) = create_delegate_action_receipt(); let access_key = AccessKey { @@ -1746,7 +1706,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_key_permissions_method() { let (_, signed_delegate_action) = create_delegate_action_receipt(); let access_key = AccessKey { diff --git a/runtime/runtime/src/config.rs b/runtime/runtime/src/config.rs index fbf655a46ff..2d4228d2a32 100644 --- a/runtime/runtime/src/config.rs +++ b/runtime/runtime/src/config.rs @@ -125,7 +125,6 @@ pub fn total_send_fees( DeleteAccount(_) => { config.fee(ActionCosts::delete_account).send_fee(sender_is_receiver) } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Delegate(signed_delegate_action) => { let delegate_cost = config.fee(ActionCosts::delegate).send_fee(sender_is_receiver); let delegate_action = &signed_delegate_action.delegate_action; @@ -150,7 +149,6 @@ pub fn total_send_fees( /// This is only relevant for DelegateAction, where the send fees of the inner actions /// need to be prepaid. All other actions burn send fees directly, so calling this function /// with other actions will return 0. -#[cfg(feature = "protocol_feature_nep366_delegate_action")] pub fn total_prepaid_send_fees( config: &RuntimeFeesConfig, actions: &[Action], @@ -180,20 +178,6 @@ pub fn total_prepaid_send_fees( Ok(result) } -/// Total sum of gas that needs to be burnt to send the inner actions of DelegateAction -/// -/// This is only relevant for DelegateAction, where the send fees of the inner actions -/// need to be prepaid. All other actions burn send fees directly, so calling this function -/// with other actions will return 0. -#[cfg(not(feature = "protocol_feature_nep366_delegate_action"))] -pub fn total_prepaid_send_fees( - _config: &RuntimeFeesConfig, - _actions: &[Action], - _current_protocol_version: ProtocolVersion, -) -> Result { - Ok(0) -} - pub fn exec_fee( config: &RuntimeFeesConfig, action: &Action, @@ -239,7 +223,6 @@ pub fn exec_fee( }, DeleteKey(_) => config.fee(ActionCosts::delete_key).exec_fee(), DeleteAccount(_) => config.fee(ActionCosts::delete_account).exec_fee(), - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Delegate(_) => config.fee(ActionCosts::delegate).exec_fee(), } } @@ -314,10 +297,8 @@ pub fn total_prepaid_exec_fees( ) -> Result { let mut result = 0; for action in actions { - #[cfg_attr(not(feature = "protocol_feature_nep366_delegate_action"), allow(unused_mut))] let mut delta; // In case of Action::Delegate it's needed to add Gas which is required for the inner actions. - #[cfg(feature = "protocol_feature_nep366_delegate_action")] if let Action::Delegate(signed_delegate_action) = action { let actions = signed_delegate_action.delegate_action.get_actions(); delta = total_prepaid_exec_fees( @@ -339,10 +320,6 @@ pub fn total_prepaid_exec_fees( } else { delta = exec_fee(config, action, receiver_id, current_protocol_version); } - #[cfg(not(feature = "protocol_feature_nep366_delegate_action"))] - { - delta = exec_fee(config, action, receiver_id, current_protocol_version); - } result = safe_add_gas(result, delta)?; } @@ -353,7 +330,6 @@ pub fn total_deposit(actions: &[Action]) -> Result Result Result { apply_delegate_action( state_update, diff --git a/runtime/runtime/src/verifier.rs b/runtime/runtime/src/verifier.rs index 28b8efa87a6..624cf70dfbf 100644 --- a/runtime/runtime/src/verifier.rs +++ b/runtime/runtime/src/verifier.rs @@ -1,8 +1,8 @@ use near_crypto::key_conversion::is_valid_staking_key; use near_primitives::checked_feature; +use near_primitives::delegate_action::SignedDelegateAction; use near_primitives::runtime::config::RuntimeConfig; -use near_primitives::types::BlockHeight; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] +use near_primitives::types::{BlockHeight, StorageUsage}; use near_primitives::version::ProtocolFeature; use near_primitives::{ account::AccessKeyPermission, @@ -83,10 +83,6 @@ fn is_zero_balance_account(account: &Account) -> bool { account.storage_usage() <= ZERO_BALANCE_ACCOUNT_STORAGE_LIMIT } -use crate::near_primitives::types::StorageUsage; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use near_primitives::delegate_action::SignedDelegateAction; - /// Validates the transaction without using the state. It allows any node to validate a /// transaction before forwarding it to the node that tracks the `signer_id` account. pub fn validate_transaction( @@ -357,7 +353,6 @@ pub(crate) fn validate_actions( }); } - #[cfg(feature = "protocol_feature_nep366_delegate_action")] let mut found_delegate_action = false; let mut iter = actions.iter().peekable(); while let Some(action) = iter.next() { @@ -366,13 +361,8 @@ pub(crate) fn validate_actions( return Err(ActionsValidationError::DeleteActionMustBeFinal); } } else { - #[cfg(feature = "protocol_feature_nep366_delegate_action")] if let Action::Delegate(_) = action { - if !checked_feature!( - "protocol_feature_nep366_delegate_action", - DelegateAction, - current_protocol_version - ) { + if !checked_feature!("stable", DelegateAction, current_protocol_version) { return Err(ActionsValidationError::UnsupportedProtocolFeature { protocol_feature: String::from("DelegateAction"), version: ProtocolFeature::DelegateAction.protocol_version(), @@ -403,7 +393,6 @@ pub(crate) fn validate_actions( pub fn validate_action( limit_config: &VMLimitConfig, action: &Action, - #[cfg_attr(not(feature = "protocol_feature_nep366_delegate_action"), allow(unused))] current_protocol_version: ProtocolVersion, ) -> Result<(), ActionsValidationError> { match action { @@ -415,12 +404,10 @@ pub fn validate_action( Action::AddKey(a) => validate_add_key_action(limit_config, a), Action::DeleteKey(_) => Ok(()), Action::DeleteAccount(_) => Ok(()), - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Action::Delegate(a) => validate_delegate_action(limit_config, a, current_protocol_version), } } -#[cfg(feature = "protocol_feature_nep366_delegate_action")] fn validate_delegate_action( limit_config: &VMLimitConfig, signed_delegate_action: &SignedDelegateAction, @@ -558,8 +545,10 @@ fn test_truncate_string() { mod tests { use std::sync::Arc; - use near_crypto::{InMemorySigner, KeyType, PublicKey, Signer}; + use crate::near_primitives::borsh::BorshSerialize; + use near_crypto::{InMemorySigner, KeyType, PublicKey, Signature, Signer}; use near_primitives::account::{AccessKey, FunctionCallPermission}; + use near_primitives::delegate_action::{DelegateAction, NonDelegateAction}; use near_primitives::hash::{hash, CryptoHash}; use near_primitives::test_utils::account_new; use near_primitives::transaction::{ @@ -577,12 +566,6 @@ mod tests { use crate::near_primitives::trie_key::TrieKey; use near_store::{set, set_code}; - use crate::near_primitives::borsh::BorshSerialize; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] - use near_crypto::Signature; - #[cfg(feature = "protocol_feature_nep366_delegate_action")] - use near_primitives::delegate_action::{DelegateAction, NonDelegateAction}; - /// Initial balance used in tests. const TESTING_INIT_BALANCE: Balance = 1_000_000_000 * NEAR_BASE; @@ -1845,7 +1828,6 @@ mod tests { } #[test] - #[cfg(feature = "protocol_feature_nep366_delegate_action")] fn test_delegate_action_must_be_only_one() { let signed_delegate_action = SignedDelegateAction { delegate_action: DelegateAction { diff --git a/test-utils/testlib/Cargo.toml b/test-utils/testlib/Cargo.toml index a991f382401..d9208dbe410 100644 --- a/test-utils/testlib/Cargo.toml +++ b/test-utils/testlib/Cargo.toml @@ -17,4 +17,3 @@ node-runtime = { path = "../../runtime/runtime" } [features] default = [] -protocol_feature_nep366_delegate_action = [] diff --git a/test-utils/testlib/src/fees_utils.rs b/test-utils/testlib/src/fees_utils.rs index 0e0b3ed76a0..18d6f9a91ff 100644 --- a/test-utils/testlib/src/fees_utils.rs +++ b/test-utils/testlib/src/fees_utils.rs @@ -2,11 +2,9 @@ //! actions in the transaction batch. use near_primitives::config::ActionCosts; use near_primitives::runtime::fees::RuntimeFeesConfig; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] use near_primitives::transaction::Action; -#[cfg(feature = "protocol_feature_nep366_delegate_action")] -use near_primitives::types::AccountId; -use near_primitives::types::{Balance, Gas}; +use near_primitives::types::{AccountId, Balance, Gas}; +use near_primitives::version::PROTOCOL_VERSION; pub struct FeeHelper { pub cfg: RuntimeFeesConfig, @@ -171,11 +169,8 @@ impl FeeHelper { /// The overhead consists of: /// - The base cost of the delegate action (send and exec). /// - The additional send cost for all inner actions. - #[cfg(feature = "protocol_feature_nep366_delegate_action")] pub fn meta_tx_overhead_cost(&self, actions: &[Action], receiver: &AccountId) -> Balance { // for tests, we assume sender != receiver - - use near_primitives::version::PROTOCOL_VERSION; let sir = false; let base = self.cfg.fee(ActionCosts::delegate); let receipt = self.cfg.fee(ActionCosts::new_action_receipt); diff --git a/tools/state-viewer/Cargo.toml b/tools/state-viewer/Cargo.toml index 52b4500be6c..677dd350305 100644 --- a/tools/state-viewer/Cargo.toml +++ b/tools/state-viewer/Cargo.toml @@ -49,6 +49,5 @@ nightly = [ "nightly_protocol", "nearcore/nightly" ] -nightly_protocol = ["nearcore/nightly_protocol", "protocol_feature_nep366_delegate_action"] +nightly_protocol = ["nearcore/nightly_protocol"] protocol_feature_flat_state = ["nearcore/protocol_feature_flat_state"] -protocol_feature_nep366_delegate_action = ["nearcore/protocol_feature_nep366_delegate_action"] diff --git a/tools/state-viewer/src/contract_accounts.rs b/tools/state-viewer/src/contract_accounts.rs index 5233a99e249..540227fc6a3 100644 --- a/tools/state-viewer/src/contract_accounts.rs +++ b/tools/state-viewer/src/contract_accounts.rs @@ -133,7 +133,6 @@ pub(crate) enum ActionType { DeleteKey, DeleteAccount, DataReceipt, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Delegate, } @@ -339,7 +338,6 @@ fn try_find_actions_spawned_by_receipt( Action::AddKey(_) => ActionType::AddKey, Action::DeleteKey(_) => ActionType::DeleteKey, Action::DeleteAccount(_) => ActionType::DeleteAccount, - #[cfg(feature = "protocol_feature_nep366_delegate_action")] Action::Delegate(_) => ActionType::Delegate, }; entry From 360b17f34c4b5281c0875be0838a77c138d498e9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 20 Feb 2023 13:07:48 +0100 Subject: [PATCH 2/2] update snapshots --- ...r_primitives_core__profile__test__profile_data_debug.snap | 3 ++- ...ear_primitives__runtime__config_store__tests__0.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__42.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__48.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__49.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__50.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__52.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__53.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__57.json.snap | 5 +++++ ...ar_primitives__runtime__config_store__tests__59.json.snap | 5 +++++ ...itives__runtime__config_store__tests__testnet_0.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_42.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_48.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_49.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_50.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_52.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_53.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_57.json.snap | 5 +++++ ...tives__runtime__config_store__tests__testnet_59.json.snap | 5 +++++ ...near_primitives__views__tests__exec_metadata_v3_view.snap | 5 +++++ .../near_primitives__views__tests__runtime_config_view.snap | 5 +++++ 21 files changed, 102 insertions(+), 1 deletion(-) diff --git a/core/primitives-core/src/snapshots/near_primitives_core__profile__test__profile_data_debug.snap b/core/primitives-core/src/snapshots/near_primitives_core__profile__test__profile_data_debug.snap index 8fabecf977b..b9ea2b19bf2 100644 --- a/core/primitives-core/src/snapshots/near_primitives_core__profile__test__profile_data_debug.snap +++ b/core/primitives-core/src/snapshots/near_primitives_core__profile__test__profile_data_debug.snap @@ -3,7 +3,7 @@ source: core/primitives-core/src/profile.rs expression: pretty_debug_str --- ------------------------------ -Action gas: 15105 +Action gas: 16120 ------ Host functions -------- contract_loading_base -> 1 [0% host] contract_loading_bytes -> 2 [0% host] @@ -81,5 +81,6 @@ delete_key -> 1011 new_action_receipt -> 1012 new_data_receipt_base -> 1013 new_data_receipt_byte -> 1014 +delegate -> 1015 ------------------------------ 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 621fafd0e1b..7eb7db3e1f8 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 5160685a8c3..a4a76e4ff1d 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 75e7b380fc6..d2488304360 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 78399319f70..a51be6994e9 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 8a6baa7e965..d5f88a20ed7 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 7d7c2a13a0e..0c25d9dcd77 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 c6d2c0e67a1..e7740154843 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__57.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__57.json.snap index 98f1956825f..af8908499fc 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__57.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__57.json.snap @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__59.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__59.json.snap index 2135e028da3..c7c520df601 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__59.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__59.json.snap @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 621fafd0e1b..7eb7db3e1f8 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 5160685a8c3..a4a76e4ff1d 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 75e7b380fc6..d2488304360 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 78399319f70..a51be6994e9 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 8a6baa7e965..d5f88a20ed7 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 7d7c2a13a0e..0c25d9dcd77 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { 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 c6d2c0e67a1..e7740154843 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 @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_57.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_57.json.snap index 98f1956825f..af8908499fc 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_57.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_57.json.snap @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { diff --git a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_59.json.snap b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_59.json.snap index 2135e028da3..c7c520df601 100644 --- a/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_59.json.snap +++ b/core/primitives/src/runtime/snapshots/near_primitives__runtime__config_store__tests__testnet_59.json.snap @@ -84,6 +84,11 @@ expression: config_view "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": { diff --git a/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap b/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap index 261c6a695be..5f09da2d3ed 100644 --- a/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap +++ b/core/primitives/src/snapshots/near_primitives__views__tests__exec_metadata_v3_view.snap @@ -25,6 +25,11 @@ expression: view "cost": "CREATE_ACCOUNT", "gas_used": "1000" }, + { + "cost_category": "ACTION_COST", + "cost": "DELEGATE", + "gas_used": "1015" + }, { "cost_category": "ACTION_COST", "cost": "DELETE_ACCOUNT", diff --git a/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap b/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap index cf80e273ce8..ae38adf7a6d 100644 --- a/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap +++ b/core/primitives/src/snapshots/near_primitives__views__tests__runtime_config_view.snap @@ -84,6 +84,11 @@ expression: "&view" "send_sir": 147489000000, "send_not_sir": 147489000000, "execution": 147489000000 + }, + "delegate_cost": { + "send_sir": 200000000000, + "send_not_sir": 200000000000, + "execution": 200000000000 } }, "storage_usage_config": {