@@ -1409,7 +1409,18 @@ 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
+ // If the accumulator is not moved to end of block, update the
1414
+ // accumulator last to make sure that the solana fully updated
1415
+ // state before the accumulator is used. bank is in a fully
1416
+ // updated state before the accumulator is used.
1417
+ if !bank
1418
+ .feature_set
1419
+ .is_active(&feature_set::move_accumulator_to_end_of_block::id())
1420
+ {
1421
+ bank.update_accumulator();
1422
+ }
1423
+
1413
1424
bank
1414
1425
}
1415
1426
@@ -1775,7 +1786,16 @@ impl Bank {
1775
1786
);
1776
1787
1777
1788
let (_, update_accumulator_time) = measure!({
1778
- new.update_accumulator();
1789
+ // If the accumulator is not moved to end of block, update the
1790
+ // accumulator last to make sure that all fully updated state before
1791
+ // the accumulator sysvar updates. sysvars are in a fully updated
1792
+ // state before the accumulator sysvar updates.
1793
+ if !new
1794
+ .feature_set
1795
+ .is_active(&feature_set::move_accumulator_to_end_of_block::id())
1796
+ {
1797
+ new.update_accumulator();
1798
+ }
1779
1799
});
1780
1800
1781
1801
let (_, fill_sysvar_cache_time) =
@@ -2367,18 +2387,35 @@ impl Bank {
2367
2387
2368
2388
// Generate the Message to emit via Wormhole.
2369
2389
let message = PostedMessageUnreliableData {
2370
- message: MessageData {
2371
- vaa_version: 1,
2372
- consistency_level: 1,
2373
- vaa_time: 1u32,
2374
- vaa_signature_account: Pubkey::default().to_bytes(),
2375
- submission_time: self.clock().unix_timestamp as u32,
2376
- nonce: 0,
2377
- sequence: sequence.sequence,
2378
- emitter_chain: 26,
2379
- emitter_address: accumulator_emitter_addr.to_bytes(),
2380
- payload: acc.serialize(self.slot(), ACCUMULATOR_RING_SIZE),
2381
- },
2390
+ message: if !self
2391
+ .feature_set
2392
+ .is_active(&feature_set::zero_wormhole_message_timestamps::id())
2393
+ {
2394
+ MessageData {
2395
+ vaa_version: 1,
2396
+ consistency_level: 1,
2397
+ vaa_time: 1u32,
2398
+ vaa_signature_account: Pubkey::default().to_bytes(),
2399
+ submission_time: self.clock().unix_timestamp as u32,
2400
+ nonce: 0,
2401
+ sequence: sequence.sequence,
2402
+ emitter_chain: 26,
2403
+ emitter_address: accumulator_emitter_addr.to_bytes(),
2404
+ payload: acc.serialize(self.slot(), ACCUMULATOR_RING_SIZE),
2405
+ }
2406
+ } else {
2407
+ // Use Default::default() to ensure zeroed VAA fields.
2408
+ MessageData {
2409
+ vaa_version: 1,
2410
+ consistency_level: 1,
2411
+ submission_time: self.clock().unix_timestamp as u32,
2412
+ sequence: sequence.sequence,
2413
+ emitter_chain: 26,
2414
+ emitter_address: accumulator_emitter_addr.to_bytes(),
2415
+ payload: acc.serialize(self.slot(), ACCUMULATOR_RING_SIZE),
2416
+ ..Default::default()
2417
+ }
2418
+ }
2382
2419
};
2383
2420
2384
2421
debug!("Accumulator: Wormhole message data: {:?}", message.message);
@@ -3491,6 +3528,19 @@ impl Bank {
3491
3528
// committed before this write lock can be obtained here.
3492
3529
let mut hash = self.hash.write().unwrap();
3493
3530
if *hash == Hash::default() {
3531
+ // Update the accumulator before doing other tasks when freezing to avoid any conflicts.
3532
+ if self
3533
+ .feature_set
3534
+ .is_active(&feature_set::move_accumulator_to_end_of_block::id())
3535
+ {
3536
+ self.update_accumulator();
3537
+ } else {
3538
+ info!(
3539
+ "Accumulator: Skipping accumulating end of block because the feature is disabled. Slot: {}",
3540
+ self.slot()
3541
+ );
3542
+ }
3543
+
3494
3544
// finish up any deferred changes to account state
3495
3545
self.collect_rent_eagerly(false);
3496
3546
self.collect_fees();
0 commit comments