@@ -2512,7 +2512,8 @@ impl Bank {
2512
2512
{
2513
2513
return;
2514
2514
}
2515
-
2515
+
2516
+ info!("Updating accumulator. Parent_epoch: {}", self.slot());
2516
2517
if let Err(e) = self.update_accumulator_impl() {
2517
2518
error!("Error updating accumulator: {:?}", e);
2518
2519
}
@@ -2530,7 +2531,7 @@ impl Bank {
2530
2531
};
2531
2532
2532
2533
// Use the current Clock to determine the index into the accumulator ring buffer.
2533
- let ring_index = (self.clock().slot % 10_000) as u32;
2534
+ let ring_index = (self.slot() % 10_000) as u32;
2534
2535
2535
2536
// Find all accounts owned by the Message Buffer program using get_program_accounts, and
2536
2537
// extract the account data.
@@ -2604,7 +2605,7 @@ impl Bank {
2604
2605
let acc_state_magic = &mut b"PAS1".to_vec();
2605
2606
let accounts_data = &mut accounts.clone().collect::<Vec<_>>().try_to_vec()?;
2606
2607
data.append(acc_state_magic);
2607
- data.append(&mut self.clock().slot .try_to_vec()?);
2608
+ data.append(&mut self.slot() .try_to_vec()?);
2608
2609
data.append(&mut ACCUMULATOR_RING_SIZE.try_to_vec()?);
2609
2610
data.append(accounts_data);
2610
2611
let owner = solana_sdk::system_program::id();
@@ -2676,7 +2677,7 @@ impl Bank {
2676
2677
sequence: sequence.sequence,
2677
2678
emitter_chain: 26,
2678
2679
emitter_address: ACCUMULATOR_EMITTER_ADDRESS,
2679
- payload: acc.serialize(self.clock().slot , ACCUMULATOR_RING_SIZE),
2680
+ payload: acc.serialize(self.slot() , ACCUMULATOR_RING_SIZE),
2680
2681
},
2681
2682
};
2682
2683
@@ -15108,7 +15109,7 @@ pub(crate) mod tests {
15108
15109
let (wormhole_message_pubkey, _bump) = Pubkey::find_program_address(
15109
15110
&[
15110
15111
b"AccumulatorMessage",
15111
- &(bank.clock().slot as u32).to_be_bytes(),
15112
+ &(bank.slot() as u32).to_be_bytes(),
15112
15113
],
15113
15114
&Pubkey::new_from_array(pythnet_sdk::pythnet::WORMHOLE_PID),
15114
15115
);
@@ -15158,7 +15159,7 @@ pub(crate) mod tests {
15158
15159
bank = new_from_parent(&Arc::new(bank));
15159
15160
15160
15161
// get the timestamp & slot for the message
15161
- let ring_index = (bank.clock().slot % ACCUMULATOR_RING_SIZE as u64) as u32;
15162
+ let ring_index = (bank.slot() % ACCUMULATOR_RING_SIZE as u64) as u32;
15162
15163
let wormhole_message_account = get_wormhole_message_account(&bank, ring_index);
15163
15164
15164
15165
assert_ne!(wormhole_message_account.data().len(), 0);
@@ -15171,7 +15172,7 @@ pub(crate) mod tests {
15171
15172
let expected_accumulator =
15172
15173
MerkleAccumulator::<Keccak160>::from_set(accumulator_elements).unwrap();
15173
15174
let expected_wormhole_message_payload =
15174
- expected_accumulator.serialize(bank.clock().slot , ACCUMULATOR_RING_SIZE);
15175
+ expected_accumulator.serialize(bank.slot() , ACCUMULATOR_RING_SIZE);
15175
15176
assert_eq!(
15176
15177
wormhole_message.message.payload,
15177
15178
expected_wormhole_message_payload
@@ -15213,7 +15214,7 @@ pub(crate) mod tests {
15213
15214
let acc_state_ring_size = LittleEndian::read_u32(&accumulator_state[12..16]);
15214
15215
15215
15216
assert_eq!(acc_state_magic, b"PAS1");
15216
- assert_eq!(acc_state_slot, bank.clock().slot );
15217
+ assert_eq!(acc_state_slot, bank.slot() );
15217
15218
assert_eq!(acc_state_ring_size, ACCUMULATOR_RING_SIZE);
15218
15219
15219
15220
let mut cursor = std::io::Cursor::new(&accumulator_state[16..]);
@@ -15238,15 +15239,15 @@ pub(crate) mod tests {
15238
15239
15239
15240
// verify ring buffer cycles
15240
15241
let ring_index_before_buffer_cycle =
15241
- (bank.clock().slot % ACCUMULATOR_RING_SIZE as u64) as u32;
15242
+ (bank.slot() % ACCUMULATOR_RING_SIZE as u64) as u32;
15242
15243
let target_slot = bank.slot() + ACCUMULATOR_RING_SIZE as u64;
15243
15244
// advance ACCUMULATOR_RING_SIZE slots using warp_from_parent since doing large loops
15244
15245
// with new_from_parent takes a long time. warp_from_parent results in a bank that is frozen.
15245
15246
bank = Bank::warp_from_parent(&Arc::new(bank), &Pubkey::default(), target_slot);
15246
15247
15247
15248
// accumulator messages should still be the same before looping around
15248
15249
let ring_index_after_buffer_cycle =
15249
- (bank.clock().slot % ACCUMULATOR_RING_SIZE as u64) as u32;
15250
+ (bank.slot() % ACCUMULATOR_RING_SIZE as u64) as u32;
15250
15251
assert_eq!(
15251
15252
ring_index_before_buffer_cycle,
15252
15253
ring_index_after_buffer_cycle
@@ -15282,7 +15283,7 @@ pub(crate) mod tests {
15282
15283
// Run accumulator, update clock & other sysvars etc
15283
15284
bank = new_from_parent(&Arc::new(bank));
15284
15285
15285
- let ring_index = (bank.clock().slot % ACCUMULATOR_RING_SIZE as u64) as u32;
15286
+ let ring_index = (bank.slot() % ACCUMULATOR_RING_SIZE as u64) as u32;
15286
15287
let updated_wormhole_message_account = get_wormhole_message_account(&bank, ring_index);
15287
15288
15288
15289
let updated_wormhole_message =
@@ -15303,7 +15304,7 @@ pub(crate) mod tests {
15303
15304
MerkleAccumulator::<Keccak160>::from_set(updated_accumulator_elements).unwrap();
15304
15305
assert_eq!(
15305
15306
updated_wormhole_message.message.payload,
15306
- expected_accumulator.serialize(bank.clock().slot , ACCUMULATOR_RING_SIZE)
15307
+ expected_accumulator.serialize(bank.slot() , ACCUMULATOR_RING_SIZE)
15307
15308
);
15308
15309
15309
15310
let expected_wormhole_message = PostedMessageUnreliableData {
@@ -15317,7 +15318,7 @@ pub(crate) mod tests {
15317
15318
sequence: wh_sequence_before_acc_update,
15318
15319
emitter_chain: 26,
15319
15320
emitter_address: ACCUMULATOR_EMITTER_ADDRESS,
15320
- payload: expected_accumulator.serialize(bank.clock().slot , ACCUMULATOR_RING_SIZE),
15321
+ payload: expected_accumulator.serialize(bank.slot() , ACCUMULATOR_RING_SIZE),
15321
15322
},
15322
15323
};
15323
15324
0 commit comments