Skip to content

Commit 5dc6572

Browse files
committed
SlotHashes sysvar/call assertion
1 parent 132e0f9 commit 5dc6572

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • programs/sbf/rust/sysvar/src

programs/sbf/rust/sysvar/src/lib.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use {
1313
solana_stake_history::{StakeHistory, StakeHistoryGetEntry, sysvar::StakeHistorySysvar},
1414
solana_sysvar::{
1515
Sysvar, clock::Clock, epoch_rewards::EpochRewards, epoch_schedule::EpochSchedule,
16-
rent::Rent, slot_hashes::PodSlotHashes,
16+
rent::Rent, slot_hashes::PodSlotHashes, slot_history::SlotHistory,
1717
},
1818
solana_sysvar_id::SysvarId,
1919
};
@@ -194,9 +194,14 @@ pub fn process_instruction(
194194
{
195195
msg!("SlotHashes identifier:");
196196
sysvar::slot_hashes::id().log();
197-
// Syscall `sol_get_sysvar`.
198-
let pod_slot_hashes = PodSlotHashes::fetch()?;
199-
assert!(pod_slot_hashes.get(/* slot */ &0)?.is_some());
197+
// Account deserialization is unsupported.
198+
// Inspecting first entry and comparing with the syscall value.
199+
assert_eq!(accounts[7].data_len(), solana_sysvar::slot_hashes::SIZE);
200+
let data = accounts[7].data.borrow();
201+
let account_slot = u64::from_le_bytes(data[8..16].try_into().unwrap());
202+
let account_hash = &data[16..48];
203+
let syscall_hash = PodSlotHashes::fetch()?.get(&account_slot)?.unwrap();
204+
assert_eq!(syscall_hash.as_ref(), account_hash);
200205
}
201206

202207
Ok(())

0 commit comments

Comments
 (0)