1
1
#[ cfg( RUSTC_WITH_SPECIALIZATION ) ]
2
2
use solana_frozen_abi:: abi_example:: AbiExample ;
3
- #[ cfg( debug_assertions) ]
4
- #[ allow( deprecated) ]
5
- use solana_sdk:: AutoTraitBreakSendSync ;
6
3
use {
7
4
crate :: system_instruction_processor,
8
5
solana_program_runtime:: invoke_context:: { InvokeContext , ProcessInstructionWithContext } ,
@@ -69,7 +66,7 @@ pub enum BuiltinAction {
69
66
/// State transition enum used for adding and removing builtin programs through
70
67
/// feature activations.
71
68
#[ derive( Debug , Clone , AbiExample ) ]
72
- enum InnerBuiltinFeatureTransition {
69
+ pub enum BuiltinFeatureTransition {
73
70
/// Add a builtin program if a feature is activated.
74
71
Add {
75
72
builtin : Builtin ,
@@ -84,51 +81,26 @@ enum InnerBuiltinFeatureTransition {
84
81
} ,
85
82
}
86
83
87
- #[ allow( deprecated) ]
88
- #[ cfg( debug_assertions) ]
89
- impl AutoTraitBreakSendSync for InnerBuiltinFeatureTransition { }
90
-
91
- #[ derive( AbiExample , Clone , Debug ) ]
92
- pub struct BuiltinFeatureTransition ( InnerBuiltinFeatureTransition ) ;
93
-
94
- // https://github.com/solana-labs/solana/pull/23233 added `BuiltinFeatureTransition`
95
- // to `Bank` which triggers https://github.com/rust-lang/rust/issues/92987 while
96
- // attempting to resolve `Sync` on `BankRc` in `AccountsBackgroundService::new` ala,
97
- //
98
- // query stack during panic:
99
- // #0 [evaluate_obligation] evaluating trait selection obligation `bank::BankRc: core::marker::Sync`
100
- // #1 [typeck] type-checking `accounts_background_service::<impl at runtime/src/accounts_background_service.rs:358:1: 520:2>::new`
101
- // #2 [typeck_item_bodies] type-checking all item bodies
102
- // #3 [analysis] running analysis passes on this crate
103
- // end of query stack
104
- //
105
- // Yoloing a `Sync` onto it avoids the auto trait evaluation and thus the ICE.
106
- //
107
- // We should remove this when upgrading to Rust 1.60.0, where the bug has been
108
- // fixed by https://github.com/rust-lang/rust/pull/93064
109
- unsafe impl Send for BuiltinFeatureTransition { }
110
- unsafe impl Sync for BuiltinFeatureTransition { }
111
-
112
84
impl BuiltinFeatureTransition {
113
85
pub fn to_action (
114
86
& self ,
115
87
should_apply_action_for_feature : & impl Fn ( & Pubkey ) -> bool ,
116
88
) -> Option < BuiltinAction > {
117
- match & self . 0 {
118
- InnerBuiltinFeatureTransition :: Add {
89
+ match self {
90
+ Self :: Add {
119
91
builtin,
120
- ref feature_id,
92
+ feature_id,
121
93
} => {
122
94
if should_apply_action_for_feature ( feature_id) {
123
95
Some ( BuiltinAction :: Add ( builtin. clone ( ) ) )
124
96
} else {
125
97
None
126
98
}
127
99
}
128
- InnerBuiltinFeatureTransition :: RemoveOrRetain {
100
+ Self :: RemoveOrRetain {
129
101
previously_added_builtin,
130
- ref addition_feature_id,
131
- ref removal_feature_id,
102
+ addition_feature_id,
103
+ removal_feature_id,
132
104
} => {
133
105
if should_apply_action_for_feature ( removal_feature_id) {
134
106
Some ( BuiltinAction :: Remove ( previously_added_builtin. id ) )
@@ -181,48 +153,48 @@ fn dummy_process_instruction(
181
153
/// Dynamic feature transitions for builtin programs
182
154
fn builtin_feature_transitions ( ) -> Vec < BuiltinFeatureTransition > {
183
155
vec ! [
184
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
156
+ BuiltinFeatureTransition :: Add {
185
157
builtin: Builtin :: new(
186
158
"compute_budget_program" ,
187
159
solana_sdk:: compute_budget:: id( ) ,
188
160
solana_compute_budget_program:: process_instruction,
189
161
) ,
190
162
feature_id: feature_set:: add_compute_budget_program:: id( ) ,
191
- } ) ,
192
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: RemoveOrRetain {
163
+ } ,
164
+ BuiltinFeatureTransition :: RemoveOrRetain {
193
165
previously_added_builtin: Builtin :: new(
194
166
"secp256k1_program" ,
195
167
solana_sdk:: secp256k1_program:: id( ) ,
196
168
dummy_process_instruction,
197
169
) ,
198
170
addition_feature_id: feature_set:: secp256k1_program_enabled:: id( ) ,
199
171
removal_feature_id: feature_set:: prevent_calling_precompiles_as_programs:: id( ) ,
200
- } ) ,
201
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: RemoveOrRetain {
172
+ } ,
173
+ BuiltinFeatureTransition :: RemoveOrRetain {
202
174
previously_added_builtin: Builtin :: new(
203
175
"ed25519_program" ,
204
176
solana_sdk:: ed25519_program:: id( ) ,
205
177
dummy_process_instruction,
206
178
) ,
207
179
addition_feature_id: feature_set:: ed25519_program_enabled:: id( ) ,
208
180
removal_feature_id: feature_set:: prevent_calling_precompiles_as_programs:: id( ) ,
209
- } ) ,
210
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
181
+ } ,
182
+ BuiltinFeatureTransition :: Add {
211
183
builtin: Builtin :: new(
212
184
"address_lookup_table_program" ,
213
185
solana_address_lookup_table_program:: id( ) ,
214
186
solana_address_lookup_table_program:: processor:: process_instruction,
215
187
) ,
216
188
feature_id: feature_set:: versioned_tx_message_enabled:: id( ) ,
217
- } ) ,
218
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
189
+ } ,
190
+ BuiltinFeatureTransition :: Add {
219
191
builtin: Builtin :: new(
220
192
"zk_token_proof_program" ,
221
193
solana_zk_token_sdk:: zk_token_proof_program:: id( ) ,
222
194
solana_zk_token_proof_program:: process_instruction,
223
195
) ,
224
196
feature_id: feature_set:: zk_token_sdk_enabled:: id( ) ,
225
- } ) ,
197
+ } ,
226
198
]
227
199
}
228
200
0 commit comments