@@ -1409,7 +1409,28 @@ impl Bank {
1409
1409
bank.update_epoch_schedule();
1410
1410
bank.update_recent_blockhashes();
1411
1411
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
+
1413
1434
bank
1414
1435
}
1415
1436
@@ -1775,7 +1796,26 @@ impl Bank {
1775
1796
);
1776
1797
1777
1798
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
+ }
1779
1819
});
1780
1820
1781
1821
let (_, fill_sysvar_cache_time) =
@@ -2365,17 +2405,34 @@ impl Bank {
2365
2405
2366
2406
// Generate the Message to emit via Wormhole.
2367
2407
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
+ }
2379
2436
},
2380
2437
};
2381
2438
@@ -3489,6 +3546,30 @@ impl Bank {
3489
3546
// committed before this write lock can be obtained here.
3490
3547
let mut hash = self.hash.write().unwrap();
3491
3548
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
+
3492
3573
// finish up any deferred changes to account state
3493
3574
self.collect_rent_eagerly(false);
3494
3575
self.collect_fees();
0 commit comments