Clean up `nonce_must_be_writable` feature (#26444)

Clean up nonce_must_be_writable feature
This commit is contained in:
Justin Starry 2022-07-07 15:45:19 +01:00 committed by GitHub
parent b3a47de1ce
commit eb6a722eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 37 deletions

View File

@ -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.

View File

@ -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<TransactionAccount> {
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();

View File

@ -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",

View File

@ -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)

View File

@ -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.