@@ -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) =
@@ -2366,17 +2406,34 @@ impl Bank {
2366
2406
2367
2407
// Generate the Message to emit via Wormhole.
2368
2408
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
+ }
2380
2437
},
2381
2438
};
2382
2439
@@ -3490,6 +3547,30 @@ impl Bank {
3490
3547
// committed before this write lock can be obtained here.
3491
3548
let mut hash = self.hash.write().unwrap();
3492
3549
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
+
3493
3574
// finish up any deferred changes to account state
3494
3575
self.collect_rent_eagerly(false);
3495
3576
self.collect_fees();
0 commit comments