@@ -51,63 +51,6 @@ macro_rules! with_program_logging {
51
51
} ;
52
52
}
53
53
54
- /// State transition enum used for adding and removing builtin programs through
55
- /// feature activations.
56
- #[ derive( Debug , Clone ) ]
57
- pub enum BuiltinFeatureTransition {
58
- /// Add a builtin program if a feature is activated.
59
- Add {
60
- builtin : Builtin ,
61
- feature_id : Pubkey ,
62
- } ,
63
- /// Remove a builtin program if a feature is activated or
64
- /// retain a previously added builtin.
65
- RemoveOrRetain {
66
- previous_builtin : Builtin ,
67
- removal_feature_id : Pubkey ,
68
- } ,
69
- }
70
-
71
- /// Actions taken by a bank when managing the list of active builtin programs.
72
- #[ derive( Debug , Clone ) ]
73
- pub enum BuiltinAction {
74
- Add ( Builtin ) ,
75
- Remove { program_id : Pubkey } ,
76
- }
77
-
78
- impl BuiltinFeatureTransition {
79
- pub fn to_action (
80
- & self ,
81
- should_apply_action_for_feature : & impl Fn ( & Pubkey ) -> bool ,
82
- ) -> Option < BuiltinAction > {
83
- match self {
84
- Self :: Add {
85
- builtin,
86
- feature_id,
87
- } => {
88
- if should_apply_action_for_feature ( feature_id) {
89
- Some ( BuiltinAction :: Add ( builtin. clone ( ) ) )
90
- } else {
91
- None
92
- }
93
- }
94
- Self :: RemoveOrRetain {
95
- previous_builtin,
96
- removal_feature_id,
97
- } => {
98
- if should_apply_action_for_feature ( removal_feature_id) {
99
- Some ( BuiltinAction :: Remove {
100
- program_id : previous_builtin. id ,
101
- } )
102
- } else {
103
- // Retaining is no different from adding a new builtin.
104
- Some ( BuiltinAction :: Add ( previous_builtin. clone ( ) ) )
105
- }
106
- }
107
- }
108
- }
109
- }
110
-
111
54
#[ derive( Clone ) ]
112
55
pub struct Builtin {
113
56
pub name : String ,
@@ -155,6 +98,61 @@ pub struct Builtins {
155
98
pub feature_transitions : Vec < BuiltinFeatureTransition > ,
156
99
}
157
100
101
+ /// Actions taken by a bank when managing the list of active builtin programs.
102
+ #[ derive( Debug , Clone ) ]
103
+ pub enum BuiltinAction {
104
+ Add ( Builtin ) ,
105
+ Remove ( Pubkey ) ,
106
+ }
107
+
108
+ /// State transition enum used for adding and removing builtin programs through
109
+ /// feature activations.
110
+ #[ derive( Debug , Clone ) ]
111
+ pub enum BuiltinFeatureTransition {
112
+ /// Add a builtin program if a feature is activated.
113
+ Add {
114
+ builtin : Builtin ,
115
+ feature_id : Pubkey ,
116
+ } ,
117
+ /// Remove a builtin program if a feature is activated or
118
+ /// retain a previously added builtin.
119
+ RemoveOrRetain {
120
+ previous_builtin : Builtin ,
121
+ removal_feature_id : Pubkey ,
122
+ } ,
123
+ }
124
+
125
+ impl BuiltinFeatureTransition {
126
+ pub fn to_action (
127
+ & self ,
128
+ should_apply_action_for_feature : & impl Fn ( & Pubkey ) -> bool ,
129
+ ) -> Option < BuiltinAction > {
130
+ match self {
131
+ Self :: Add {
132
+ builtin,
133
+ feature_id,
134
+ } => {
135
+ if should_apply_action_for_feature ( feature_id) {
136
+ Some ( BuiltinAction :: Add ( builtin. clone ( ) ) )
137
+ } else {
138
+ None
139
+ }
140
+ }
141
+ Self :: RemoveOrRetain {
142
+ previous_builtin,
143
+ removal_feature_id,
144
+ } => {
145
+ if should_apply_action_for_feature ( removal_feature_id) {
146
+ Some ( BuiltinAction :: Remove ( previous_builtin. id ) )
147
+ } else {
148
+ // Retaining is no different from adding a new builtin.
149
+ Some ( BuiltinAction :: Add ( previous_builtin. clone ( ) ) )
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+
158
156
/// Builtin programs that are always available
159
157
fn genesis_builtins ( ) -> Vec < Builtin > {
160
158
vec ! [
@@ -201,9 +199,6 @@ fn builtin_feature_transitions() -> Vec<BuiltinFeatureTransition> {
201
199
) ,
202
200
feature_id: feature_set:: add_compute_budget_program:: id( ) ,
203
201
} ,
204
- // TODO when feature `prevent_calling_precompiles_as_programs` is
205
- // cleaned up also remove "secp256k1_program" from the main builtins
206
- // list
207
202
BuiltinFeatureTransition :: RemoveOrRetain {
208
203
previous_builtin: Builtin :: new(
209
204
"secp256k1_program" ,
@@ -212,9 +207,6 @@ fn builtin_feature_transitions() -> Vec<BuiltinFeatureTransition> {
212
207
) ,
213
208
removal_feature_id: feature_set:: prevent_calling_precompiles_as_programs:: id( ) ,
214
209
} ,
215
- // TODO when feature `prevent_calling_precompiles_as_programs` is
216
- // cleaned up also remove "ed25519_program" from the main builtins
217
- // list
218
210
BuiltinFeatureTransition :: RemoveOrRetain {
219
211
previous_builtin: Builtin :: new(
220
212
"ed25519_program" ,
0 commit comments