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 ) )
@@ -180,48 +152,48 @@ fn dummy_process_instruction(
180
152
/// Dynamic feature transitions for builtin programs
181
153
fn builtin_feature_transitions ( ) -> Vec < BuiltinFeatureTransition > {
182
154
vec ! [
183
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
155
+ BuiltinFeatureTransition :: Add {
184
156
builtin: Builtin :: new(
185
157
"compute_budget_program" ,
186
158
solana_sdk:: compute_budget:: id( ) ,
187
159
solana_compute_budget_program:: process_instruction,
188
160
) ,
189
161
feature_id: feature_set:: add_compute_budget_program:: id( ) ,
190
- } ) ,
191
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: RemoveOrRetain {
162
+ } ,
163
+ BuiltinFeatureTransition :: RemoveOrRetain {
192
164
previously_added_builtin: Builtin :: new(
193
165
"secp256k1_program" ,
194
166
solana_sdk:: secp256k1_program:: id( ) ,
195
167
dummy_process_instruction,
196
168
) ,
197
169
addition_feature_id: feature_set:: secp256k1_program_enabled:: id( ) ,
198
170
removal_feature_id: feature_set:: prevent_calling_precompiles_as_programs:: id( ) ,
199
- } ) ,
200
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: RemoveOrRetain {
171
+ } ,
172
+ BuiltinFeatureTransition :: RemoveOrRetain {
201
173
previously_added_builtin: Builtin :: new(
202
174
"ed25519_program" ,
203
175
solana_sdk:: ed25519_program:: id( ) ,
204
176
dummy_process_instruction,
205
177
) ,
206
178
addition_feature_id: feature_set:: ed25519_program_enabled:: id( ) ,
207
179
removal_feature_id: feature_set:: prevent_calling_precompiles_as_programs:: id( ) ,
208
- } ) ,
209
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
180
+ } ,
181
+ BuiltinFeatureTransition :: Add {
210
182
builtin: Builtin :: new(
211
183
"address_lookup_table_program" ,
212
184
solana_address_lookup_table_program:: id( ) ,
213
185
solana_address_lookup_table_program:: processor:: process_instruction,
214
186
) ,
215
187
feature_id: feature_set:: versioned_tx_message_enabled:: id( ) ,
216
- } ) ,
217
- BuiltinFeatureTransition ( InnerBuiltinFeatureTransition :: Add {
188
+ } ,
189
+ BuiltinFeatureTransition :: Add {
218
190
builtin: Builtin :: new(
219
191
"zk_token_proof_program" ,
220
192
solana_zk_token_sdk:: zk_token_proof_program:: id( ) ,
221
193
solana_zk_token_proof_program:: process_instruction,
222
194
) ,
223
195
feature_id: feature_set:: zk_token_sdk_enabled:: id( ) ,
224
- } ) ,
196
+ } ,
225
197
]
226
198
}
227
199
0 commit comments