Clean up `nonce_must_be_writable` feature (#26444)
Clean up nonce_must_be_writable feature
This commit is contained in:
parent
b3a47de1ce
commit
eb6a722eba
|
@ -61,7 +61,7 @@ use {
|
||||||
epoch_info::EpochInfo,
|
epoch_info::EpochInfo,
|
||||||
epoch_schedule::EpochSchedule,
|
epoch_schedule::EpochSchedule,
|
||||||
exit::Exit,
|
exit::Exit,
|
||||||
feature_set::{self, nonce_must_be_writable},
|
feature_set,
|
||||||
fee_calculator::FeeCalculator,
|
fee_calculator::FeeCalculator,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
message::{Message, SanitizedMessage},
|
message::{Message, SanitizedMessage},
|
||||||
|
@ -3614,11 +3614,7 @@ pub mod rpc_full {
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
|
||||||
let durable_nonce_info = transaction
|
let durable_nonce_info = transaction
|
||||||
.get_durable_nonce(
|
.get_durable_nonce()
|
||||||
preflight_bank
|
|
||||||
.feature_set
|
|
||||||
.is_active(&nonce_must_be_writable::id()),
|
|
||||||
)
|
|
||||||
.map(|&pubkey| (pubkey, *transaction.message().recent_blockhash()));
|
.map(|&pubkey| (pubkey, *transaction.message().recent_blockhash()));
|
||||||
if durable_nonce_info.is_some() {
|
if durable_nonce_info.is_some() {
|
||||||
// While it uses a defined constant, this last_valid_block_height value is chosen arbitrarily.
|
// While it uses a defined constant, this last_valid_block_height value is chosen arbitrarily.
|
||||||
|
|
|
@ -109,7 +109,7 @@ use {
|
||||||
feature,
|
feature,
|
||||||
feature_set::{
|
feature_set::{
|
||||||
self, add_set_compute_unit_price_ix, default_units_per_instruction,
|
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::FeeStructure,
|
||||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||||
|
@ -4134,8 +4134,7 @@ impl Bank {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_message_for_nonce(&self, message: &SanitizedMessage) -> Option<TransactionAccount> {
|
fn check_message_for_nonce(&self, message: &SanitizedMessage) -> Option<TransactionAccount> {
|
||||||
let nonce_address =
|
let nonce_address = message.get_durable_nonce()?;
|
||||||
message.get_durable_nonce(self.feature_set.is_active(&nonce_must_be_writable::id()))?;
|
|
||||||
let nonce_account = self.get_account_with_fixed_root(nonce_address)?;
|
let nonce_account = self.get_account_with_fixed_root(nonce_address)?;
|
||||||
let nonce_data =
|
let nonce_data =
|
||||||
nonce_account::verify_nonce_account(&nonce_account, message.recent_blockhash())?;
|
nonce_account::verify_nonce_account(&nonce_account, message.recent_blockhash())?;
|
||||||
|
@ -13616,9 +13615,6 @@ pub(crate) mod tests {
|
||||||
FeatureSet::all_enabled(),
|
FeatureSet::all_enabled(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
Arc::get_mut(&mut bank)
|
|
||||||
.unwrap()
|
|
||||||
.activate_feature(&feature_set::nonce_must_be_writable::id());
|
|
||||||
let custodian_pubkey = custodian_keypair.pubkey();
|
let custodian_pubkey = custodian_keypair.pubkey();
|
||||||
let nonce_pubkey = nonce_keypair.pubkey();
|
let nonce_pubkey = nonce_keypair.pubkey();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
solana_program_runtime::{ic_msg, invoke_context::InvokeContext},
|
solana_program_runtime::{ic_msg, invoke_context::InvokeContext},
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
feature_set::{self, nonce_must_be_writable},
|
feature_set,
|
||||||
instruction::{checked_add, InstructionError},
|
instruction::{checked_add, InstructionError},
|
||||||
nonce::{
|
nonce::{
|
||||||
self,
|
self,
|
||||||
|
@ -25,11 +25,7 @@ pub fn advance_nonce_account(
|
||||||
.feature_set
|
.feature_set
|
||||||
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||||
|
|
||||||
if invoke_context
|
if !account.is_writable() {
|
||||||
.feature_set
|
|
||||||
.is_active(&nonce_must_be_writable::id())
|
|
||||||
&& !account.is_writable()
|
|
||||||
{
|
|
||||||
ic_msg!(
|
ic_msg!(
|
||||||
invoke_context,
|
invoke_context,
|
||||||
"Advance nonce account: Account {} must be writeable",
|
"Advance nonce account: Account {} must be writeable",
|
||||||
|
@ -98,11 +94,7 @@ pub fn withdraw_nonce_account(
|
||||||
.feature_set
|
.feature_set
|
||||||
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||||
|
|
||||||
if invoke_context
|
if !from.is_writable() {
|
||||||
.feature_set
|
|
||||||
.is_active(&nonce_must_be_writable::id())
|
|
||||||
&& !from.is_writable()
|
|
||||||
{
|
|
||||||
ic_msg!(
|
ic_msg!(
|
||||||
invoke_context,
|
invoke_context,
|
||||||
"Withdraw nonce account: Account {} must be writeable",
|
"Withdraw nonce account: Account {} must be writeable",
|
||||||
|
@ -184,11 +176,7 @@ pub fn initialize_nonce_account(
|
||||||
.feature_set
|
.feature_set
|
||||||
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||||
|
|
||||||
if invoke_context
|
if !account.is_writable() {
|
||||||
.feature_set
|
|
||||||
.is_active(&nonce_must_be_writable::id())
|
|
||||||
&& !account.is_writable()
|
|
||||||
{
|
|
||||||
ic_msg!(
|
ic_msg!(
|
||||||
invoke_context,
|
invoke_context,
|
||||||
"Initialize nonce account: Account {} must be writeable",
|
"Initialize nonce account: Account {} must be writeable",
|
||||||
|
@ -242,11 +230,7 @@ pub fn authorize_nonce_account(
|
||||||
.feature_set
|
.feature_set
|
||||||
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
.is_active(&feature_set::merge_nonce_error_into_system_error::id());
|
||||||
|
|
||||||
if invoke_context
|
if !account.is_writable() {
|
||||||
.feature_set
|
|
||||||
.is_active(&nonce_must_be_writable::id())
|
|
||||||
&& !account.is_writable()
|
|
||||||
{
|
|
||||||
ic_msg!(
|
ic_msg!(
|
||||||
invoke_context,
|
invoke_context,
|
||||||
"Authorize nonce account: Account {} must be writeable",
|
"Authorize nonce account: Account {} must be writeable",
|
||||||
|
|
|
@ -241,7 +241,7 @@ impl SanitizedMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the message uses a durable nonce, return the pubkey of the nonce account
|
/// 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()
|
self.instructions()
|
||||||
.get(NONCED_TX_MARKER_IX_INDEX as usize)
|
.get(NONCED_TX_MARKER_IX_INDEX as usize)
|
||||||
.filter(
|
.filter(
|
||||||
|
@ -259,7 +259,7 @@ impl SanitizedMessage {
|
||||||
.and_then(|ix| {
|
.and_then(|ix| {
|
||||||
ix.accounts.first().and_then(|idx| {
|
ix.accounts.first().and_then(|idx| {
|
||||||
let idx = *idx as usize;
|
let idx = *idx as usize;
|
||||||
if nonce_must_be_writable && !self.is_writable(idx) {
|
if !self.is_writable(idx) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
self.account_keys().get(idx)
|
self.account_keys().get(idx)
|
||||||
|
|
|
@ -250,8 +250,8 @@ impl SanitizedTransaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If the transaction uses a durable nonce, return the pubkey of the nonce account
|
/// 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> {
|
pub fn get_durable_nonce(&self) -> Option<&Pubkey> {
|
||||||
self.message.get_durable_nonce(nonce_must_be_writable)
|
self.message.get_durable_nonce()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the serialized message data to sign.
|
/// Return the serialized message data to sign.
|
||||||
|
|
Loading…
Reference in New Issue