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