Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup - Various feature gates #31750

Closed
2 changes: 0 additions & 2 deletions banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ fn simulate_transaction(
MessageHash::Compute,
Some(false), // is_simple_vote_tx
bank,
true, // require_static_program_ids
) {
Err(err) => {
return BanksTransactionResultWithSimulation {
Expand Down Expand Up @@ -330,7 +329,6 @@ impl Banks for BanksServer {
MessageHash::Compute,
Some(false), // is_simple_vote_tx
bank.as_ref(),
true, // require_static_program_ids
) {
Ok(tx) => tx,
Err(err) => return Some(Err(err)),
Expand Down
102 changes: 10 additions & 92 deletions cli/src/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ use {
crate::{
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
cli::{
log_instruction_custom_error, log_instruction_custom_error_ex, CliCommand,
CliCommandInfo, CliConfig, CliError, ProcessResult,
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
ProcessResult,
},
compute_unit_price::WithComputeUnitPrice,
feature::get_feature_is_active,
memo::WithMemo,
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
},
Expand All @@ -25,19 +24,17 @@ use {
solana_rpc_client_nonce_utils::*,
solana_sdk::{
account::Account,
feature_set::merge_nonce_error_into_system_error,
hash::Hash,
instruction::InstructionError,
message::Message,
nonce::{self, State},
pubkey::Pubkey,
system_instruction::{
advance_nonce_account, authorize_nonce_account, create_nonce_account,
create_nonce_account_with_seed, instruction_to_nonce_error, upgrade_nonce_account,
withdraw_nonce_account, NonceError, SystemError,
create_nonce_account_with_seed, upgrade_nonce_account, withdraw_nonce_account,
SystemError,
},
system_program,
transaction::{Transaction, TransactionError},
transaction::Transaction,
},
std::sync::Arc,
};
Expand Down Expand Up @@ -427,21 +424,9 @@ pub fn process_authorize_nonce_account(
&tx.message,
config.commitment,
)?;
let merge_errors =
get_feature_is_active(rpc_client, &merge_nonce_error_into_system_error::id())?;
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);

if merge_errors {
log_instruction_custom_error::<SystemError>(result, config)
} else {
log_instruction_custom_error_ex::<NonceError, _>(result, config, |ix_error| {
if let InstructionError::Custom(_) = ix_error {
instruction_to_nonce_error(ix_error, merge_errors)
} else {
None
}
})
}
log_instruction_custom_error::<SystemError>(result, config)
}

pub fn process_create_nonce_account(
Expand Down Expand Up @@ -524,40 +509,9 @@ pub fn process_create_nonce_account(

let mut tx = Transaction::new_unsigned(message);
tx.try_sign(&config.signers, latest_blockhash)?;
let merge_errors =
get_feature_is_active(rpc_client, &merge_nonce_error_into_system_error::id())?;
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);

let err_ix_index = if let Err(err) = &result {
err.get_transaction_error().and_then(|tx_err| {
if let TransactionError::InstructionError(ix_index, _) = tx_err {
Some(ix_index)
} else {
None
}
})
} else {
None
};

match err_ix_index {
// SystemInstruction::InitializeNonceAccount failed
Some(1) => {
if merge_errors {
log_instruction_custom_error::<SystemError>(result, config)
} else {
log_instruction_custom_error_ex::<NonceError, _>(result, config, |ix_error| {
if let InstructionError::Custom(_) = ix_error {
instruction_to_nonce_error(ix_error, merge_errors)
} else {
None
}
})
}
}
// SystemInstruction::CreateAccount{,WithSeed} failed
_ => log_instruction_custom_error::<SystemError>(result, config),
}
log_instruction_custom_error::<SystemError>(result, config)
}

pub fn process_get_nonce(
Expand Down Expand Up @@ -611,21 +565,9 @@ pub fn process_new_nonce(
&tx.message,
config.commitment,
)?;
let merge_errors =
get_feature_is_active(rpc_client, &merge_nonce_error_into_system_error::id())?;
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);

if merge_errors {
log_instruction_custom_error::<SystemError>(result, config)
} else {
log_instruction_custom_error_ex::<NonceError, _>(result, config, |ix_error| {
if let InstructionError::Custom(_) = ix_error {
instruction_to_nonce_error(ix_error, merge_errors)
} else {
None
}
})
}
log_instruction_custom_error::<SystemError>(result, config)
}

pub fn process_show_nonce_account(
Expand Down Expand Up @@ -688,21 +630,9 @@ pub fn process_withdraw_from_nonce_account(
&tx.message,
config.commitment,
)?;
let merge_errors =
get_feature_is_active(rpc_client, &merge_nonce_error_into_system_error::id())?;
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);

if merge_errors {
log_instruction_custom_error::<SystemError>(result, config)
} else {
log_instruction_custom_error_ex::<NonceError, _>(result, config, |ix_error| {
if let InstructionError::Custom(_) = ix_error {
instruction_to_nonce_error(ix_error, merge_errors)
} else {
None
}
})
}
log_instruction_custom_error::<SystemError>(result, config)
}

pub(crate) fn process_upgrade_nonce_account(
Expand All @@ -725,20 +655,8 @@ pub(crate) fn process_upgrade_nonce_account(
&tx.message,
config.commitment,
)?;
let merge_errors =
get_feature_is_active(rpc_client, &merge_nonce_error_into_system_error::id())?;
let result = rpc_client.send_and_confirm_transaction_with_spinner(&tx);
if merge_errors {
log_instruction_custom_error::<SystemError>(result, config)
} else {
log_instruction_custom_error_ex::<NonceError, _>(result, config, |ix_error| {
if let InstructionError::Custom(_) = ix_error {
instruction_to_nonce_error(ix_error, merge_errors)
} else {
None
}
})
}
log_instruction_custom_error::<SystemError>(result, config)
}

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,6 @@ mod tests {
MessageHash::Compute,
Some(false),
bank.as_ref(),
true, // require_static_program_ids
)
.unwrap();

Expand Down
1 change: 0 additions & 1 deletion core/src/read_write_account_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ mod tests {
MessageHash::Compute,
Some(false),
bank,
true, // require_static_program_ids
)
.unwrap()
}
Expand Down
2 changes: 0 additions & 2 deletions entry/benches/entry_sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ fn bench_gpusigverify(bencher: &mut Bencher) {
message_hash,
None,
SimpleAddressLoader::Disabled,
true, // require_static_program_ids
)
}?;

Expand Down Expand Up @@ -82,7 +81,6 @@ fn bench_cpusigverify(bencher: &mut Bencher) {
message_hash,
None,
SimpleAddressLoader::Disabled,
true, // require_static_program_ids
)
}?;

Expand Down
1 change: 0 additions & 1 deletion entry/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,6 @@ mod tests {
message_hash,
None,
SimpleAddressLoader::Disabled,
true, // require_static_program_ids
)
}?;

Expand Down
1 change: 0 additions & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,6 @@ fn compute_slot_cost(blockstore: &Blockstore, slot: Slot) -> Result<(), String>
MessageHash::Compute,
None,
SimpleAddressLoader::Disabled,
true, // require_static_program_ids
)
.map_err(|err| {
warn!("Failed to compute cost of transaction: {:?}", err);
Expand Down
11 changes: 2 additions & 9 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1984,12 +1984,7 @@ impl Blockstore {
.into_iter()
.flat_map(|entry| entry.transactions)
.map(|transaction| {
if let Err(err) = transaction.sanitize(
// Don't enable additional sanitization checks until
// all clusters have activated the static program id
// feature gate so that bigtable upload isn't affected
false, // require_static_program_ids
) {
if let Err(err) = transaction.sanitize() {
warn!(
"Blockstore::get_block sanitize failed: {:?}, \
slot: {:?}, \
Expand Down Expand Up @@ -2376,9 +2371,7 @@ impl Blockstore {
.cloned()
.flat_map(|entry| entry.transactions)
.map(|transaction| {
if let Err(err) = transaction.sanitize(
true, // require_static_program_ids
) {
if let Err(err) = transaction.sanitize() {
warn!(
"Blockstore::find_transaction_in_slot sanitize failed: {:?}, \
slot: {:?}, \
Expand Down
45 changes: 14 additions & 31 deletions programs/bpf_loader/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ use {
feature_set::bpf_account_data_direct_mapping,
feature_set::FeatureSet,
feature_set::{
self, blake3_syscall_enabled, check_syscall_outputs_do_not_overlap,
curve25519_syscall_enabled, disable_cpi_setting_executable_and_rent_epoch,
disable_deploy_of_alloc_free_syscall, disable_fees_sysvar, enable_alt_bn128_syscall,
enable_big_mod_exp_syscall, enable_early_verification_of_account_modifications,
self, blake3_syscall_enabled, curve25519_syscall_enabled,
disable_cpi_setting_executable_and_rent_epoch, disable_deploy_of_alloc_free_syscall,
disable_fees_sysvar, enable_alt_bn128_syscall, enable_big_mod_exp_syscall,
enable_early_verification_of_account_modifications,
error_on_syscall_bpf_function_hash_collisions, libsecp256k1_0_5_upgrade_enabled,
limit_secp256k1_recovery_id, reject_callx_r10,
stop_sibling_instruction_search_at_parent, stop_truncating_strings_in_syscalls,
switch_to_new_elf_parser,
reject_callx_r10, stop_sibling_instruction_search_at_parent,
stop_truncating_strings_in_syscalls, switch_to_new_elf_parser,
},
hash::{Hasher, HASH_BYTES},
instruction::{
Expand Down Expand Up @@ -686,10 +685,7 @@ declare_syscall!(
std::mem::size_of_val(bump_seed_ref),
address.as_ptr() as usize,
std::mem::size_of::<Pubkey>(),
) && invoke_context
.feature_set
.is_active(&check_syscall_outputs_do_not_overlap::id())
{
) {
return Err(SyscallError::CopyOverlapping.into());
}
*bump_seed_ref = bump_seed[0];
Expand Down Expand Up @@ -873,18 +869,11 @@ declare_syscall!(
return Ok(Secp256k1RecoverError::InvalidHash.into());
}
};
let adjusted_recover_id_val = if invoke_context
.feature_set
.is_active(&limit_secp256k1_recovery_id::id())
{
match recovery_id_val.try_into() {
Ok(adjusted_recover_id_val) => adjusted_recover_id_val,
Err(_) => {
return Ok(Secp256k1RecoverError::InvalidRecoveryId.into());
}
let adjusted_recover_id_val = match recovery_id_val.try_into() {
Ok(adjusted_recover_id_val) => adjusted_recover_id_val,
Err(_) => {
return Ok(Secp256k1RecoverError::InvalidRecoveryId.into());
}
} else {
recovery_id_val as u8
};
let recovery_id = match libsecp256k1::RecoveryId::parse(adjusted_recover_id_val) {
Ok(id) => id,
Expand Down Expand Up @@ -1446,10 +1435,7 @@ declare_syscall!(
length as usize,
program_id_result as *const _ as usize,
std::mem::size_of::<Pubkey>(),
) && invoke_context
.feature_set
.is_active(&check_syscall_outputs_do_not_overlap::id())
{
) {
return Err(SyscallError::CopyOverlapping.into());
}

Expand Down Expand Up @@ -1538,7 +1524,7 @@ declare_syscall!(
invoke_context.get_check_size(),
)?;

if (!is_nonoverlapping(
if !is_nonoverlapping(
result_header as *const _ as usize,
std::mem::size_of::<ProcessedSiblingInstruction>(),
program_id as *const _ as usize,
Expand Down Expand Up @@ -1571,10 +1557,7 @@ declare_syscall!(
accounts.as_ptr() as usize,
std::mem::size_of::<AccountMeta>()
.saturating_mul(result_header.accounts_len as usize),
)) && invoke_context
.feature_set
.is_active(&check_syscall_outputs_do_not_overlap::id())
{
) {
return Err(SyscallError::CopyOverlapping.into());
}

Expand Down
Loading