Skip to content

Commit b41fb7f

Browse files
Reisenilya-bobyr
authored andcommitted
pythnet features
Include pythnet features from before 1.14.17 and an update to match the current genesis state. Genesis matches the current Pythnet production release when needed. The activated features are added and the genesis cluster type is fixed to match what we used to create the genesis at first.
1 parent ed0177e commit b41fb7f

File tree

3 files changed

+142
-14
lines changed

3 files changed

+142
-14
lines changed

genesis/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
565565
}
566566

567567
solana_stake_program::add_genesis_accounts(&mut genesis_config);
568-
if genesis_config.cluster_type == ClusterType::Development {
568+
if genesis_config.cluster_type == ClusterType::MainnetBeta {
569569
solana_runtime::genesis_utils::activate_pythnet_genesis_features(&mut genesis_config);
570570
}
571571

runtime/src/bank.rs

Lines changed: 94 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,28 @@ impl Bank {
14091409
bank.update_epoch_schedule();
14101410
bank.update_recent_blockhashes();
14111411
bank.fill_missing_sysvar_cache_entries();
1412-
bank.update_accumulator();
1412+
1413+
// The features are activated one after another.
1414+
// The accumulator is moved to end of the block either if the
1415+
// move_accumulator_to_end_of_block feature is active or if all
1416+
// the features are active.
1417+
let accumulator_moved_to_end_of_block = bank
1418+
.feature_set
1419+
.is_active(&feature_set::move_accumulator_to_end_of_block::id())
1420+
^ bank
1421+
.feature_set
1422+
.is_active(&feature_set::undo_move_accumulator_to_end_of_block::id())
1423+
^ bank
1424+
.feature_set
1425+
.is_active(&feature_set::redo_move_accumulator_to_end_of_block::id());
1426+
// If the accumulator is not moved to end of block, update the
1427+
// accumulator last to make sure that the solana fully updated
1428+
// state before the accumulator is used. bank is in a fully
1429+
// updated state before the accumulator is used.
1430+
if !accumulator_moved_to_end_of_block {
1431+
bank.update_accumulator();
1432+
}
1433+
14131434
bank
14141435
}
14151436

@@ -1775,7 +1796,26 @@ impl Bank {
17751796
);
17761797

17771798
let (_, update_accumulator_time) = measure!({
1778-
new.update_accumulator();
1799+
// The features are activated one after another.
1800+
// The accumulator is moved to end of the block either if the
1801+
// move_accumulator_to_end_of_block feature is active or if all
1802+
// the features are active.
1803+
let accumulator_moved_to_end_of_block = new
1804+
.feature_set
1805+
.is_active(&feature_set::move_accumulator_to_end_of_block::id())
1806+
^ new
1807+
.feature_set
1808+
.is_active(&feature_set::undo_move_accumulator_to_end_of_block::id())
1809+
^ new
1810+
.feature_set
1811+
.is_active(&feature_set::redo_move_accumulator_to_end_of_block::id());
1812+
// If the accumulator is not moved to end of block, update the
1813+
// accumulator last to make sure that all fully updated state before
1814+
// the accumulator sysvar updates. sysvars are in a fully updated
1815+
// state before the accumulator sysvar updates.
1816+
if !accumulator_moved_to_end_of_block {
1817+
new.update_accumulator();
1818+
}
17791819
});
17801820

17811821
let (_, fill_sysvar_cache_time) =
@@ -2365,17 +2405,34 @@ impl Bank {
23652405

23662406
// Generate the Message to emit via Wormhole.
23672407
let message = PostedMessageUnreliableData {
2368-
message: MessageData {
2369-
vaa_version: 1,
2370-
consistency_level: 1,
2371-
vaa_time: 1u32,
2372-
vaa_signature_account: Pubkey::default().to_bytes(),
2373-
submission_time: self.clock().unix_timestamp as u32,
2374-
nonce: 0,
2375-
sequence: sequence.sequence,
2376-
emitter_chain: 26,
2377-
emitter_address: accumulator_emitter_addr.to_bytes(),
2378-
payload: acc.serialize(self.slot(), ACCUMULATOR_RING_SIZE),
2408+
message: if !self
2409+
.feature_set
2410+
.is_active(&feature_set::zero_wormhole_message_timestamps::id())
2411+
{
2412+
MessageData {
2413+
vaa_version: 1,
2414+
consistency_level: 1,
2415+
vaa_time: 1u32,
2416+
vaa_signature_account: Pubkey::default().to_bytes(),
2417+
submission_time: self.clock().unix_timestamp as u32,
2418+
nonce: 0,
2419+
sequence: sequence.sequence,
2420+
emitter_chain: 26,
2421+
emitter_address: accumulator_emitter_addr.to_bytes(),
2422+
payload: acc.serialize(self.slot(), ACCUMULATOR_RING_SIZE),
2423+
}
2424+
} else {
2425+
// Use Default::default() to ensure zeroed VAA fields.
2426+
MessageData {
2427+
vaa_version: 1,
2428+
consistency_level: 1,
2429+
submission_time: self.clock().unix_timestamp as u32,
2430+
sequence: sequence.sequence,
2431+
emitter_chain: 26,
2432+
emitter_address: accumulator_emitter_addr.to_bytes(),
2433+
payload: acc.serialize(self.slot(), ACCUMULATOR_RING_SIZE),
2434+
..Default::default()
2435+
}
23792436
},
23802437
};
23812438

@@ -3489,6 +3546,30 @@ impl Bank {
34893546
// committed before this write lock can be obtained here.
34903547
let mut hash = self.hash.write().unwrap();
34913548
if *hash == Hash::default() {
3549+
// The features are activated one after another.
3550+
// The accumulator is moved to end of the block either if the
3551+
// move_accumulator_to_end_of_block feature is active or if all
3552+
// the features are active.
3553+
let accumulator_moved_to_end_of_block = self
3554+
.feature_set
3555+
.is_active(&feature_set::move_accumulator_to_end_of_block::id())
3556+
^ self
3557+
.feature_set
3558+
.is_active(&feature_set::undo_move_accumulator_to_end_of_block::id())
3559+
^ self
3560+
.feature_set
3561+
.is_active(&feature_set::redo_move_accumulator_to_end_of_block::id());
3562+
// If accumulator move to end of block is active update the accumulator before doing
3563+
// other tasks when freezing to avoid any conflicts.
3564+
if accumulator_moved_to_end_of_block {
3565+
self.update_accumulator();
3566+
} else {
3567+
info!(
3568+
"Accumulator: Skipping accumulating end of block because the feature is disabled. Slot: {}",
3569+
self.slot()
3570+
);
3571+
}
3572+
34923573
// finish up any deferred changes to account state
34933574
self.collect_rent_eagerly(false);
34943575
self.collect_fees();

sdk/src/feature_set.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,22 @@ pub mod enable_accumulator_sysvar {
548548
solana_sdk::declare_id!("BawYFA2oeA4CacxgQgLn6ZwRWDq1ZPXruUuEbko8oPT5");
549549
}
550550

551+
pub mod move_accumulator_to_end_of_block {
552+
solana_sdk::declare_id!("Ecz7cAP89wKDAoEJYhovFcxMcXRJiWGfFdefcSrx2Ynr");
553+
}
554+
555+
pub mod zero_wormhole_message_timestamps {
556+
solana_sdk::declare_id!("UMg4wFe51vKLHXpbdKWP8kFHWQBsCfbd67AoiyPSaH2");
557+
}
558+
559+
pub mod undo_move_accumulator_to_end_of_block {
560+
solana_sdk::declare_id!("EfmMYu7ajxsKNgtWmDWKYq9Pt5EUrC3qEHAXEVBBT1bs");
561+
}
562+
563+
pub mod redo_move_accumulator_to_end_of_block {
564+
solana_sdk::declare_id!("skyhwRBbP1LoHzWy1QrwLWy3vo2uHkzVV1zpN9UsGuw");
565+
}
566+
551567
lazy_static! {
552568
/// Map of feature identifiers to user-visible description
553569
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@@ -679,6 +695,10 @@ lazy_static! {
679695
(move_serialized_len_ptr_in_cpi::id(), "cpi ignore serialized_len_ptr #29592"),
680696
(enable_request_heap_frame_ix::id(), "Enable transaction to request heap frame using compute budget instruction #30076"),
681697
(enable_accumulator_sysvar::id(), "enable accumulator sysvar #<GH_ISSUE_NUMBER>"),
698+
(move_accumulator_to_end_of_block::id(), "move accumulator to end of block #<GH_ISSUE_NUMBER>"),
699+
(zero_wormhole_message_timestamps::id(), "use zeroed timestamps in wormhole messages"),
700+
(undo_move_accumulator_to_end_of_block::id(), "undo accumulator end of block change"),
701+
(redo_move_accumulator_to_end_of_block::id(), "redo accumulator end of block change"),
682702
/*************** ADD NEW FEATURES HERE ***************/
683703
]
684704
.iter()
@@ -778,6 +798,33 @@ lazy_static! {
778798
// expensive, account creation uses older harsher formula.
779799
// (tx_wide_compute_cap::id(), "transaction wide compute cap"),
780800
// (reduce_required_deploy_balance::id(), "reduce required payer balance for program deploys"),
801+
802+
// Features enabled later. This list will be updated as new features are enabled.
803+
804+
// Slot: 82172256
805+
(enable_accumulator_sysvar::id(), "enable accumulator sysvar #<GH_ISSUE_NUMBER>"),
806+
807+
// Slot: 115868256
808+
(preserve_rent_epoch_for_rent_exempt_accounts::id(), "preserve rent epoch for rent exempt accounts #26479"),
809+
(nonce_must_be_authorized::id(), "nonce must be authorized"),
810+
(nonce_must_be_advanceable::id(), "durable nonces must be advanceable"),
811+
(vote_authorize_with_seed::id(), "An instruction you can use to change a vote accounts authority when the current authority is a derived key #25860"),
812+
(prevent_crediting_accounts_that_end_rent_paying::id(), "prevent crediting rent paying accounts #26606"),
813+
(return_none_for_zero_lamport_accounts::id(), "return none for zero lamport accounts #27800"),
814+
(move_accumulator_to_end_of_block::id(), "move accumulator to end of block #<GH_ISSUE_NUMBER>"),
815+
(quick_bail_on_panic::id(), "quick bail on panic"),
816+
(check_syscall_outputs_do_not_overlap::id(), "check syscall outputs do_not overlap #28600"),
817+
(tx_wide_compute_cap::id(), "transaction wide compute cap"),
818+
(zero_wormhole_message_timestamps::id(), "use zeroed timestamps in wormhole messages"),
819+
820+
// Slot: 125372256
821+
(move_serialized_len_ptr_in_cpi::id(), "cpi ignore serialized_len_ptr #29592"),
822+
823+
// Slot: 131852256
824+
(undo_move_accumulator_to_end_of_block::id(), "undo accumulator end of block change"),
825+
826+
// Slot: 152588256
827+
(redo_move_accumulator_to_end_of_block::id(), "redo accumulator end of block change"),
781828
]
782829
.iter()
783830
.cloned()

0 commit comments

Comments
 (0)