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 ;
3
6
use {
4
7
crate :: system_instruction_processor,
5
8
solana_program_runtime:: {
@@ -104,7 +107,7 @@ pub enum BuiltinAction {
104
107
/// State transition enum used for adding and removing builtin programs through
105
108
/// feature activations.
106
109
#[ derive( Debug , Clone , AbiExample ) ]
107
- pub enum BuiltinFeatureTransition {
110
+ enum InnerBuiltinFeatureTransition {
108
111
/// Add a builtin program if a feature is activated.
109
112
Add {
110
113
builtin : Builtin ,
@@ -119,6 +122,13 @@ pub enum BuiltinFeatureTransition {
119
122
} ,
120
123
}
121
124
125
+ #[ allow( deprecated) ]
126
+ #[ cfg( debug_assertions) ]
127
+ impl AutoTraitBreakSendSync for InnerBuiltinFeatureTransition { }
128
+
129
+ #[ derive( AbiExample , Clone , Debug ) ]
130
+ pub struct BuiltinFeatureTransition ( InnerBuiltinFeatureTransition ) ;
131
+
122
132
// https://github.com/solana-labs/solana/pull/23233 added `BuiltinFeatureTransition`
123
133
// to `Bank` which triggers https://github.com/rust-lang/rust/issues/92987 while
124
134
// attempting to resolve `Sync` on `BankRc` in `AccountsBackgroundService::new` ala,
@@ -142,21 +152,21 @@ impl BuiltinFeatureTransition {
142
152
& self ,
143
153
should_apply_action_for_feature : & impl Fn ( & Pubkey ) -> bool ,
144
154
) -> Option < BuiltinAction > {
145
- match self {
146
- Self :: Add {
155
+ match & self . 0 {
156
+ InnerBuiltinFeatureTransition :: Add {
147
157
builtin,
148
- feature_id,
158
+ ref feature_id,
149
159
} => {
150
160
if should_apply_action_for_feature ( feature_id) {
151
161
Some ( BuiltinAction :: Add ( builtin. clone ( ) ) )
152
162
} else {
153
163
None
154
164
}
155
165
}
156
- Self :: RemoveOrRetain {
166
+ InnerBuiltinFeatureTransition :: RemoveOrRetain {
157
167
previously_added_builtin,
158
- addition_feature_id,
159
- removal_feature_id,
168
+ ref addition_feature_id,
169
+ ref removal_feature_id,
160
170
} => {
161
171
if should_apply_action_for_feature ( removal_feature_id) {
162
172
Some ( BuiltinAction :: Remove ( previously_added_builtin. id ) )
@@ -209,40 +219,40 @@ fn dummy_process_instruction(
209
219
/// Dynamic feature transitions for builtin programs
210
220
fn builtin_feature_transitions ( ) -> Vec < BuiltinFeatureTransition > {
211
221
vec ! [
212
- BuiltinFeatureTransition :: Add {
222
+ BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
213
223
builtin: Builtin :: new(
214
224
"compute_budget_program" ,
215
225
solana_sdk:: compute_budget:: id( ) ,
216
226
solana_compute_budget_program:: process_instruction,
217
227
) ,
218
228
feature_id: feature_set:: add_compute_budget_program:: id( ) ,
219
- } ,
220
- BuiltinFeatureTransition :: RemoveOrRetain {
229
+ } ) ,
230
+ BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: RemoveOrRetain {
221
231
previously_added_builtin: Builtin :: new(
222
232
"secp256k1_program" ,
223
233
solana_sdk:: secp256k1_program:: id( ) ,
224
234
dummy_process_instruction,
225
235
) ,
226
236
addition_feature_id: feature_set:: secp256k1_program_enabled:: id( ) ,
227
237
removal_feature_id: feature_set:: prevent_calling_precompiles_as_programs:: id( ) ,
228
- } ,
229
- BuiltinFeatureTransition :: RemoveOrRetain {
238
+ } ) ,
239
+ BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: RemoveOrRetain {
230
240
previously_added_builtin: Builtin :: new(
231
241
"ed25519_program" ,
232
242
solana_sdk:: ed25519_program:: id( ) ,
233
243
dummy_process_instruction,
234
244
) ,
235
245
addition_feature_id: feature_set:: ed25519_program_enabled:: id( ) ,
236
246
removal_feature_id: feature_set:: prevent_calling_precompiles_as_programs:: id( ) ,
237
- } ,
238
- BuiltinFeatureTransition :: Add {
247
+ } ) ,
248
+ BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
239
249
builtin: Builtin :: new(
240
250
"address_lookup_table_program" ,
241
251
solana_address_lookup_table_program:: id( ) ,
242
252
solana_address_lookup_table_program:: processor:: process_instruction,
243
253
) ,
244
254
feature_id: feature_set:: versioned_tx_message_enabled:: id( ) ,
245
- } ,
255
+ } ) ,
246
256
]
247
257
}
248
258
0 commit comments