From eb6a722ebac60456b9a030ab803fee5f4e616700 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Thu, 7 Jul 2022 15:45:19 +0100 Subject: [PATCH] Clean up `nonce_must_be_writable` feature (#26444) Clean up nonce_must_be_writable feature --- rpc/src/rpc.rs | 8 ++------ runtime/src/bank.rs | 8 ++------ runtime/src/nonce_keyed_account.rs | 26 +++++--------------------- sdk/program/src/message/sanitized.rs | 4 ++-- sdk/src/transaction/sanitized.rs | 4 ++-- 5 files changed, 13 insertions(+), 37 deletions(-) diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 62e163575..330e8ceef 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -61,7 +61,7 @@ use { epoch_info::EpochInfo, epoch_schedule::EpochSchedule, exit::Exit, - feature_set::{self, nonce_must_be_writable}, + feature_set, fee_calculator::FeeCalculator, hash::Hash, message::{Message, SanitizedMessage}, @@ -3614,11 +3614,7 @@ pub mod rpc_full { .unwrap_or(0); let durable_nonce_info = transaction - .get_durable_nonce( - preflight_bank - .feature_set - .is_active(&nonce_must_be_writable::id()), - ) + .get_durable_nonce() .map(|&pubkey| (pubkey, *transaction.message().recent_blockhash())); if durable_nonce_info.is_some() { // While it uses a defined constant, this last_valid_block_height value is chosen arbitrarily. diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index d6402d12e..15512c23d 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -109,7 +109,7 @@ use { feature, feature_set::{ self, add_set_compute_unit_price_ix, default_units_per_instruction, - disable_fee_calculator, nonce_must_be_writable, FeatureSet, + disable_fee_calculator, FeatureSet, }, fee::FeeStructure, fee_calculator::{FeeCalculator, FeeRateGovernor}, @@ -4134,8 +4134,7 @@ impl Bank { } fn check_message_for_nonce(&self, message: &SanitizedMessage) -> Option { - let nonce_address = - message.get_durable_nonce(self.feature_set.is_active(&nonce_must_be_writable::id()))?; + let nonce_address = message.get_durable_nonce()?; let nonce_account = self.get_account_with_fixed_root(nonce_address)?; let nonce_data = nonce_account::verify_nonce_account(&nonce_account, message.recent_blockhash())?; @@ -13616,9 +13615,6 @@ pub(crate) mod tests { FeatureSet::all_enabled(), ) .unwrap(); - Arc::get_mut(&mut bank) - .unwrap() - .activate_feature(&feature_set::nonce_must_be_writable::id()); let custodian_pubkey = custodian_keypair.pubkey(); let nonce_pubkey = nonce_keypair.pubkey(); diff --git a/runtime/src/nonce_keyed_account.rs b/runtime/src/nonce_keyed_account.rs index f6f022253..59ce1a808 100644 --- a/runtime/src/nonce_keyed_account.rs +++ b/runtime/src/nonce_keyed_account.rs @@ -1,7 +1,7 @@ use { solana_program_runtime::{ic_msg, invoke_context::InvokeContext}, solana_sdk::{ - feature_set::{self, nonce_must_be_writable}, + feature_set, instruction::{checked_add, InstructionError}, nonce::{ self, @@ -25,11 +25,7 @@ pub fn advance_nonce_account( .feature_set .is_active(&feature_set::merge_nonce_error_into_system_error::id()); - if invoke_context - .feature_set - .is_active(&nonce_must_be_writable::id()) - && !account.is_writable() - { + if !account.is_writable() { ic_msg!( invoke_context, "Advance nonce account: Account {} must be writeable", @@ -98,11 +94,7 @@ pub fn withdraw_nonce_account( .feature_set .is_active(&feature_set::merge_nonce_error_into_system_error::id()); - if invoke_context - .feature_set - .is_active(&nonce_must_be_writable::id()) - && !from.is_writable() - { + if !from.is_writable() { ic_msg!( invoke_context, "Withdraw nonce account: Account {} must be writeable", @@ -184,11 +176,7 @@ pub fn initialize_nonce_account( .feature_set .is_active(&feature_set::merge_nonce_error_into_system_error::id()); - if invoke_context - .feature_set - .is_active(&nonce_must_be_writable::id()) - && !account.is_writable() - { + if !account.is_writable() { ic_msg!( invoke_context, "Initialize nonce account: Account {} must be writeable", @@ -242,11 +230,7 @@ pub fn authorize_nonce_account( .feature_set .is_active(&feature_set::merge_nonce_error_into_system_error::id()); - if invoke_context - .feature_set - .is_active(&nonce_must_be_writable::id()) - && !account.is_writable() - { + if !account.is_writable() { ic_msg!( invoke_context, "Authorize nonce account: Account {} must be writeable", diff --git a/sdk/program/src/message/sanitized.rs b/sdk/program/src/message/sanitized.rs index 593a4ac90..5fc64cd05 100644 --- a/sdk/program/src/message/sanitized.rs +++ b/sdk/program/src/message/sanitized.rs @@ -241,7 +241,7 @@ impl SanitizedMessage { } /// If the message uses a durable nonce, return the pubkey of the nonce account - pub fn get_durable_nonce(&self, nonce_must_be_writable: bool) -> Option<&Pubkey> { + pub fn get_durable_nonce(&self) -> Option<&Pubkey> { self.instructions() .get(NONCED_TX_MARKER_IX_INDEX as usize) .filter( @@ -259,7 +259,7 @@ impl SanitizedMessage { .and_then(|ix| { ix.accounts.first().and_then(|idx| { let idx = *idx as usize; - if nonce_must_be_writable && !self.is_writable(idx) { + if !self.is_writable(idx) { None } else { self.account_keys().get(idx) diff --git a/sdk/src/transaction/sanitized.rs b/sdk/src/transaction/sanitized.rs index 4c813e6b7..35a379f72 100644 --- a/sdk/src/transaction/sanitized.rs +++ b/sdk/src/transaction/sanitized.rs @@ -250,8 +250,8 @@ impl SanitizedTransaction { } /// If the transaction uses a durable nonce, return the pubkey of the nonce account - pub fn get_durable_nonce(&self, nonce_must_be_writable: bool) -> Option<&Pubkey> { - self.message.get_durable_nonce(nonce_must_be_writable) + pub fn get_durable_nonce(&self) -> Option<&Pubkey> { + self.message.get_durable_nonce() } /// Return the serialized message data to sign.