1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
use lazy_static::lazy_static;
use solana_sdk::{
clock::Slot,
hash::{Hash, Hasher},
pubkey::Pubkey,
};
use std::collections::{HashMap, HashSet};
pub mod instructions_sysvar_enabled {
solana_sdk::declare_id!("7TfFp6Tf2XqXQQfx16qvXbjekXtn68kiQj9pPfXZ5Bua");
}
pub mod secp256k1_program_enabled {
solana_sdk::declare_id!("3tF9nXQrHzTV5jdDqzn6LVWMoJagN1zRgr4APfY6qmpi");
}
pub mod consistent_recent_blockhashes_sysvar {
solana_sdk::declare_id!("ApdySrEmykK3PBLExdN2ehGCRPyVT6athFgu4H7H8e9J");
}
pub mod deprecate_rewards_sysvar {
solana_sdk::declare_id!("GVriKcZATdgSzmhmu9PtimfheaKYksK5mhgoN5fbRhXg");
}
pub mod pico_inflation {
solana_sdk::declare_id!("4RWNif6C2WCNiKVW7otP4G7dkmkHGyKQWRpuZ1pxKU5m");
}
pub mod full_inflation {
pub mod devnet_and_testnet {
solana_sdk::declare_id!("JC1GQujpgHz92Am65FxcxByqqDGTdYJs6jLjgebnDpJF");
}
pub mod mainnet {
pub mod certusone {
pub mod vote {
solana_sdk::declare_id!("7Ra6gKzEBFyYJ7fdsrCuzihZcxKu7AbmDy2FBEQFzap2");
}
pub mod enable {
solana_sdk::declare_id!("54ZqXvMyCKShnBrGj2ni6m4kXTjRUrkc21dFoT9npJZk");
}
}
}
}
pub mod spl_token_v2_multisig_fix {
solana_sdk::declare_id!("EwSWSBRpzYZSEqdZ215WMmnce6WiEsk57rSEB3e7ghh6");
}
pub mod no_overflow_rent_distribution {
solana_sdk::declare_id!("9TyDRDhs933rTCWGwzSUTSx1XeJT14sc17o1cNQzUaBq");
}
pub mod stake_program_v2 {
solana_sdk::declare_id!("BpCWufPmpbYaT1xRbdCeZKXDxQ4Wj1Z8ijaG6tWFrJg1");
}
pub mod rewrite_stake {
solana_sdk::declare_id!("HpGqShCRhP7QwMBXTs1KbATiHWa383EUWjg3kbQjN2Kf");
}
pub mod filter_stake_delegation_accounts {
solana_sdk::declare_id!("HpGqShCRhP7QwMBXTs1KbATiHWa383EUWjg3kbQjN2Kf");
}
pub mod bpf_loader_upgradeable_program {
solana_sdk::declare_id!("Cv6gGxiakDF6nd9Sxx53MbC4kij69qXpap8guiC6aK9U");
}
pub mod stake_program_v3 {
solana_sdk::declare_id!("6tYrCsaWbGqgeW9tN3NRbViw6BBLYjnNsJBqLJZZoo5B");
}
pub mod require_custodian_for_locked_stake_authorize {
solana_sdk::declare_id!("FKWSvfcXATHSBBNvr5VE6ns4tNsTG3EGzcDw2xVtowZQ");
}
pub mod spl_token_v2_self_transfer_fix {
solana_sdk::declare_id!("2XDc17ZmSTbpqV3B5fmEGac4CKCYnbJj7vnfASvdzqyN");
}
pub mod warp_timestamp_again {
solana_sdk::declare_id!("GvDsGDkH5gyzwpDhxNixx8vtx1kwYHH13RiNAPw27zXb");
}
pub mod check_init_vote_data {
solana_sdk::declare_id!("3ccR6QpxGYsAbWyfevEtBNGfWV4xBffxRj2tD6A9i39F");
}
pub mod check_program_owner {
solana_sdk::declare_id!("5XnbR5Es9YXEARRuP6mdvoxiW3hx5atNNeBmwVd8P3QD");
}
pub mod cpi_share_ro_and_exec_accounts {
solana_sdk::declare_id!("6VgVBi3uRVqp56TtEwNou8idgdmhCD1aYqX8FaJ1fnJb");
}
pub mod skip_ro_deserialization {
solana_sdk::declare_id!("6Sw5JV84f7QkDe8gvRxpcPWFnPpfpgEnNziiy8sELaCp");
}
pub mod require_stake_for_gossip {
solana_sdk::declare_id!("6oNzd5Z3M2L1xo4Q5hoox7CR2DuW7m1ETLWH5jHJthwa");
}
pub mod cpi_data_cost {
solana_sdk::declare_id!("Hrg5bXePPGiAVWZfDHbvjqytSeyBDPAGAQ7v6N5i4gCX");
}
pub mod upgradeable_close_instruction {
solana_sdk::declare_id!("FsPaByos3gA9bUEhp3EimQpQPCoSvCEigHod496NmABQ");
}
pub mod demote_sysvar_write_locks {
solana_sdk::declare_id!("86LJYRuq2zgtHuL3FccR6hqFJQMQkFoun4knAxcPiF1P");
}
pub mod sysvar_via_syscall {
solana_sdk::declare_id!("7411E6gFQLDhQkdRjmpXwM1hzHMMoYQUjHicmvGPC1Nf");
}
pub mod check_duplicates_by_hash {
solana_sdk::declare_id!("8ZqTSYHgzyaYCcXJPMViRy6afCFSgNvYooPDeVdyj5GC");
}
pub mod enforce_aligned_host_addrs {
solana_sdk::declare_id!("6Qob9Z4RwGdf599FDVCqsjuKjR8ZFR3oVs2ByRLWBsua");
}
pub mod set_upgrade_authority_via_cpi_enabled {
solana_sdk::declare_id!("GQdjCCptpGECG7QfE35hKTAopB1umGoSrdKfax2VmZWy");
}
pub mod update_data_on_realloc {
solana_sdk::declare_id!("BkPcYCrwHXBoTsv9vMhiRF9gteZmDj3Uwisz9CDjoMKp");
}
pub mod keccak256_syscall_enabled {
solana_sdk::declare_id!("7Ua8mFtahVfA3WCY9LoXDAJJdvJRJHckvSSr1dD8FTWc");
}
pub mod stake_program_v4 {
solana_sdk::declare_id!("Dc7djyhP9aLfdq2zktpvskeAjpG56msCU1yexpxXiWZb");
}
pub mod system_transfer_zero_check {
solana_sdk::declare_id!("BrTR9hzw4WBGFP65AJMbpAo64DcA3U6jdPSga9fMV5cS");
}
pub mod memory_ops_syscalls {
solana_sdk::declare_id!("ENQi37wsVhTvFz2gUiZAAbqFEWGN2jwFsqdEDTE8A4MU");
}
pub mod dedupe_config_program_signers {
solana_sdk::declare_id!("8kEuAshXLsgkUEdcFVLqrjCGGHVWFW99ZZpxvAzzMtBp");
}
lazy_static! {
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
(instructions_sysvar_enabled::id(), "instructions sysvar"),
(secp256k1_program_enabled::id(), "secp256k1 program"),
(consistent_recent_blockhashes_sysvar::id(), "consistent recentblockhashes sysvar"),
(deprecate_rewards_sysvar::id(), "deprecate unused rewards sysvar"),
(pico_inflation::id(), "pico inflation"),
(full_inflation::devnet_and_testnet::id(), "full inflation on devnet and testnet"),
(spl_token_v2_multisig_fix::id(), "spl-token multisig fix"),
(no_overflow_rent_distribution::id(), "no overflow rent distribution"),
(stake_program_v2::id(), "solana_stake_program v2"),
(rewrite_stake::id(), "rewrite stake"),
(filter_stake_delegation_accounts::id(), "filter stake_delegation_accounts #14062"),
(bpf_loader_upgradeable_program::id(), "upgradeable bpf loader"),
(stake_program_v3::id(), "solana_stake_program v3"),
(require_custodian_for_locked_stake_authorize::id(), "require custodian to authorize withdrawer change for locked stake"),
(spl_token_v2_self_transfer_fix::id(), "spl-token self-transfer fix"),
(full_inflation::mainnet::certusone::enable::id(), "full inflation enabled by Certus One"),
(full_inflation::mainnet::certusone::vote::id(), "community vote allowing Certus One to enable full inflation"),
(warp_timestamp_again::id(), "warp timestamp again, adjust bounding to 25% fast 80% slow #15204"),
(check_init_vote_data::id(), "check initialized Vote data"),
(check_program_owner::id(), "limit programs to operating on accounts owned by itself"),
(require_stake_for_gossip::id(), "require stakes for propagating crds values through gossip #15561"),
(cpi_data_cost::id(), "charge the compute budget for data passed via CPI"),
(upgradeable_close_instruction::id(), "close upgradeable buffer accounts"),
(demote_sysvar_write_locks::id(), "demote builtins and sysvar write locks to readonly #15497"),
(sysvar_via_syscall::id(), "provide sysvars via syscalls"),
(check_duplicates_by_hash::id(), "use transaction message hash for duplicate check"),
(enforce_aligned_host_addrs::id(), "enforce aligned host addresses"),
(update_data_on_realloc::id(), "Retain updated data values modified after realloc via CPI"),
(set_upgrade_authority_via_cpi_enabled::id(), "set upgrade authority instruction via cpi calls for upgradable programs"),
(keccak256_syscall_enabled::id(), "keccak256 syscall"),
(stake_program_v4::id(), "solana_stake_program v4"),
(system_transfer_zero_check::id(), "perform all checks for transfers of 0 lamports"),
(memory_ops_syscalls::id(), "add syscalls for memory operations"),
(dedupe_config_program_signers::id(), "dedupe config program signers"),
]
.iter()
.cloned()
.collect();
pub static ref ID: Hash = {
let mut hasher = Hasher::default();
let mut feature_ids = FEATURE_NAMES.keys().collect::<Vec<_>>();
feature_ids.sort();
for feature in feature_ids {
hasher.hash(feature.as_ref());
}
hasher.result()
};
}
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct FullInflationFeaturePair {
pub vote_id: Pubkey,
pub enable_id: Pubkey,
}
lazy_static! {
pub static ref FULL_INFLATION_FEATURE_PAIRS: HashSet<FullInflationFeaturePair> = [
FullInflationFeaturePair {
vote_id: full_inflation::mainnet::certusone::vote::id(),
enable_id: full_inflation::mainnet::certusone::enable::id(),
},
]
.iter()
.cloned()
.collect();
}
#[derive(AbiExample, Debug, Clone)]
pub struct FeatureSet {
pub active: HashMap<Pubkey, Slot>,
pub inactive: HashSet<Pubkey>,
}
impl Default for FeatureSet {
fn default() -> Self {
Self {
active: HashMap::new(),
inactive: FEATURE_NAMES.keys().cloned().collect(),
}
}
}
impl FeatureSet {
pub fn is_active(&self, feature_id: &Pubkey) -> bool {
self.active.contains_key(feature_id)
}
pub fn activated_slot(&self, feature_id: &Pubkey) -> Option<Slot> {
self.active.get(feature_id).copied()
}
pub fn full_inflation_features_enabled(&self) -> HashSet<Pubkey> {
let mut hash_set = FULL_INFLATION_FEATURE_PAIRS
.iter()
.filter_map(|pair| {
if self.is_active(&pair.vote_id) && self.is_active(&pair.enable_id) {
Some(pair.enable_id)
} else {
None
}
})
.collect::<HashSet<_>>();
if self.is_active(&full_inflation::devnet_and_testnet::id()) {
hash_set.insert(full_inflation::devnet_and_testnet::id());
}
hash_set
}
pub fn all_enabled() -> Self {
Self {
active: FEATURE_NAMES.keys().cloned().map(|key| (key, 0)).collect(),
inactive: HashSet::new(),
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_full_inflation_features_enabled_devnet_and_testnet() {
let mut feature_set = FeatureSet::default();
assert!(feature_set.full_inflation_features_enabled().is_empty());
feature_set
.active
.insert(full_inflation::devnet_and_testnet::id(), 42);
assert_eq!(
feature_set.full_inflation_features_enabled(),
[full_inflation::devnet_and_testnet::id()]
.iter()
.cloned()
.collect()
);
}
#[test]
fn test_full_inflation_features_enabled() {
let mut feature_set = FeatureSet::default();
assert!(feature_set.full_inflation_features_enabled().is_empty());
feature_set
.active
.insert(full_inflation::mainnet::certusone::vote::id(), 42);
assert!(feature_set.full_inflation_features_enabled().is_empty());
feature_set
.active
.insert(full_inflation::mainnet::certusone::enable::id(), 42);
assert_eq!(
feature_set.full_inflation_features_enabled(),
[full_inflation::mainnet::certusone::enable::id()]
.iter()
.cloned()
.collect()
);
let mut feature_set = FeatureSet::default();
assert!(feature_set.full_inflation_features_enabled().is_empty());
feature_set
.active
.insert(full_inflation::mainnet::certusone::enable::id(), 42);
assert!(feature_set.full_inflation_features_enabled().is_empty());
feature_set
.active
.insert(full_inflation::mainnet::certusone::vote::id(), 42);
assert_eq!(
feature_set.full_inflation_features_enabled(),
[full_inflation::mainnet::certusone::enable::id()]
.iter()
.cloned()
.collect()
);
}
}