Skip to content

Commit 2fc73b3

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 3906cc9 commit 2fc73b3

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) =
@@ -2366,17 +2406,34 @@ impl Bank {
23662406

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

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