From 70b446105cef76fd5da0a8d87890adbc9f00787a Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Tue, 21 Jun 2022 10:39:10 -0500 Subject: [PATCH 1/2] Remove auto traits from ICE work-around --- runtime/src/builtins.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/runtime/src/builtins.rs b/runtime/src/builtins.rs index dca956be84971c..b08c8a9edc42e5 100644 --- a/runtime/src/builtins.rs +++ b/runtime/src/builtins.rs @@ -91,24 +91,6 @@ impl AutoTraitBreakSendSync for InnerBuiltinFeatureTransition {} #[derive(AbiExample, Clone, Debug)] pub struct BuiltinFeatureTransition(InnerBuiltinFeatureTransition); -// https://github.com/solana-labs/solana/pull/23233 added `BuiltinFeatureTransition` -// to `Bank` which triggers https://github.com/rust-lang/rust/issues/92987 while -// attempting to resolve `Sync` on `BankRc` in `AccountsBackgroundService::new` ala, -// -// query stack during panic: -// #0 [evaluate_obligation] evaluating trait selection obligation `bank::BankRc: core::marker::Sync` -// #1 [typeck] type-checking `accounts_background_service::::new` -// #2 [typeck_item_bodies] type-checking all item bodies -// #3 [analysis] running analysis passes on this crate -// end of query stack -// -// Yoloing a `Sync` onto it avoids the auto trait evaluation and thus the ICE. -// -// We should remove this when upgrading to Rust 1.60.0, where the bug has been -// fixed by https://github.com/rust-lang/rust/pull/93064 -unsafe impl Send for BuiltinFeatureTransition {} -unsafe impl Sync for BuiltinFeatureTransition {} - impl BuiltinFeatureTransition { pub fn to_action( &self, From 2874ef53a02ec449cc2c6f43274f95e6d8207e02 Mon Sep 17 00:00:00 2001 From: Brooks Prumo Date: Tue, 21 Jun 2022 11:17:34 -0500 Subject: [PATCH 2/2] Revert "followup safety checks for #23295" This reverts commit 5e0086c1eea855f87d282fa91d4928b02f3aed8a. --- runtime/src/builtins.rs | 44 ++++++++++++++++------------------------- sdk/src/lib.rs | 8 -------- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/runtime/src/builtins.rs b/runtime/src/builtins.rs index b08c8a9edc42e5..b898c10aef339f 100644 --- a/runtime/src/builtins.rs +++ b/runtime/src/builtins.rs @@ -1,8 +1,5 @@ #[cfg(RUSTC_WITH_SPECIALIZATION)] use solana_frozen_abi::abi_example::AbiExample; -#[cfg(debug_assertions)] -#[allow(deprecated)] -use solana_sdk::AutoTraitBreakSendSync; use { crate::system_instruction_processor, solana_program_runtime::invoke_context::{InvokeContext, ProcessInstructionWithContext}, @@ -69,7 +66,7 @@ pub enum BuiltinAction { /// State transition enum used for adding and removing builtin programs through /// feature activations. #[derive(Debug, Clone, AbiExample)] -enum InnerBuiltinFeatureTransition { +pub enum BuiltinFeatureTransition { /// Add a builtin program if a feature is activated. Add { builtin: Builtin, @@ -84,22 +81,15 @@ enum InnerBuiltinFeatureTransition { }, } -#[allow(deprecated)] -#[cfg(debug_assertions)] -impl AutoTraitBreakSendSync for InnerBuiltinFeatureTransition {} - -#[derive(AbiExample, Clone, Debug)] -pub struct BuiltinFeatureTransition(InnerBuiltinFeatureTransition); - impl BuiltinFeatureTransition { pub fn to_action( &self, should_apply_action_for_feature: &impl Fn(&Pubkey) -> bool, ) -> Option { - match &self.0 { - InnerBuiltinFeatureTransition::Add { + match self { + Self::Add { builtin, - ref feature_id, + feature_id, } => { if should_apply_action_for_feature(feature_id) { Some(BuiltinAction::Add(builtin.clone())) @@ -107,10 +97,10 @@ impl BuiltinFeatureTransition { None } } - InnerBuiltinFeatureTransition::RemoveOrRetain { + Self::RemoveOrRetain { previously_added_builtin, - ref addition_feature_id, - ref removal_feature_id, + addition_feature_id, + removal_feature_id, } => { if should_apply_action_for_feature(removal_feature_id) { Some(BuiltinAction::Remove(previously_added_builtin.id)) @@ -162,15 +152,15 @@ fn dummy_process_instruction( /// Dynamic feature transitions for builtin programs fn builtin_feature_transitions() -> Vec { vec![ - BuiltinFeatureTransition(InnerBuiltinFeatureTransition::Add { + BuiltinFeatureTransition::Add { builtin: Builtin::new( "compute_budget_program", solana_sdk::compute_budget::id(), solana_compute_budget_program::process_instruction, ), feature_id: feature_set::add_compute_budget_program::id(), - }), - BuiltinFeatureTransition(InnerBuiltinFeatureTransition::RemoveOrRetain { + }, + BuiltinFeatureTransition::RemoveOrRetain { previously_added_builtin: Builtin::new( "secp256k1_program", solana_sdk::secp256k1_program::id(), @@ -178,8 +168,8 @@ fn builtin_feature_transitions() -> Vec { ), addition_feature_id: feature_set::secp256k1_program_enabled::id(), removal_feature_id: feature_set::prevent_calling_precompiles_as_programs::id(), - }), - BuiltinFeatureTransition(InnerBuiltinFeatureTransition::RemoveOrRetain { + }, + BuiltinFeatureTransition::RemoveOrRetain { previously_added_builtin: Builtin::new( "ed25519_program", solana_sdk::ed25519_program::id(), @@ -187,23 +177,23 @@ fn builtin_feature_transitions() -> Vec { ), addition_feature_id: feature_set::ed25519_program_enabled::id(), removal_feature_id: feature_set::prevent_calling_precompiles_as_programs::id(), - }), - BuiltinFeatureTransition(InnerBuiltinFeatureTransition::Add { + }, + BuiltinFeatureTransition::Add { builtin: Builtin::new( "address_lookup_table_program", solana_address_lookup_table_program::id(), solana_address_lookup_table_program::processor::process_instruction, ), feature_id: feature_set::versioned_tx_message_enabled::id(), - }), - BuiltinFeatureTransition(InnerBuiltinFeatureTransition::Add { + }, + BuiltinFeatureTransition::Add { builtin: Builtin::new( "zk_token_proof_program", solana_zk_token_sdk::zk_token_proof_program::id(), solana_zk_token_proof_program::process_instruction, ), feature_id: feature_set::zk_token_sdk_enabled::id(), - }), + }, ] } diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 019cd40ed149d6..bc3c65dcbd289a 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -97,14 +97,6 @@ pub use solana_sdk_macro::pubkeys; #[rustversion::since(1.46.0)] pub use solana_sdk_macro::respan; -#[deprecated( - since = "1.9.0", - note = "use only to break https://github.com/rust-lang/rust/issues/92987. remove when we move to Rust 1.60.0" -)] -#[doc(hidden)] -#[cfg(debug_assertions)] -pub trait AutoTraitBreakSendSync: Send + Sync {} - // Unused `solana_sdk::program_stubs!()` macro retained for source backwards compatibility with older programs #[macro_export] #[deprecated(