import Base import ./types.bend as Ty # Cluster sysvars. Checker bodies return 0. The compiler natives call # sol_get_sysvar, except Instructions, which is the account the transaction # must pass (Sysvar1nstructions1111111111111111111111111). # # A failed syscall reads as 0. Fees and recent blockhashes are not here. # Slot history and stake history are variable-length and not read. # # Clock is 40 bytes. Timestamps are the i64 bits. def Clock.slot() -> Ty.u64: Ty.u64.zero() def Clock.epoch_start_timestamp() -> Ty.u64: Ty.u64.zero() def Clock.epoch() -> Ty.u64: Ty.u64.zero() def Clock.leader_schedule_epoch() -> Ty.u64: Ty.u64.zero() def Clock.unix_timestamp() -> Ty.u64: Ty.u64.zero() # EpochSchedule bincode: two u64s, a bool, then two u64s (33 bytes). def EpochSchedule.slots_per_epoch() -> Ty.u64: Ty.u64.zero() def EpochSchedule.leader_schedule_slot_offset() -> Ty.u64: Ty.u64.zero() def EpochSchedule.warmup() -> U32: 0 def EpochSchedule.first_normal_epoch() -> Ty.u64: Ty.u64.zero() def EpochSchedule.first_normal_slot() -> Ty.u64: Ty.u64.zero() def LastRestartSlot.slot() -> Ty.u64: Ty.u64.zero() # EpochRewards. The parent blockhash and total points sit between partitions # and total_rewards; those two are not read. def EpochRewards.distribution_starting_block_height() -> Ty.u64: Ty.u64.zero() def EpochRewards.num_partitions() -> Ty.u64: Ty.u64.zero() def EpochRewards.total_rewards() -> Ty.u64: Ty.u64.zero() def EpochRewards.distributed_rewards() -> Ty.u64: Ty.u64.zero() def EpochRewards.active() -> U32: 0 # Rent.lamports_per_byte_year. rent_exempt in sol.bend applies the threshold. def Rent.lamports_per_byte_year() -> Ty.u64: Ty.u64.zero() # SlotHashes: u64 count, then entries of slot u64 + 32-byte hash, newest first. def SlotHashes.len() -> Ty.u64: Ty.u64.zero() def SlotHashes.slot(+i: Ty.u64) -> Ty.u64: match i: case _: Ty.u64.zero() def newest_go(empty: Bool) -> Ty.u64: match empty: case True{}: Ty.u64.zero() case False{}: SlotHashes.slot(Ty.u64.zero()) # Slot of the newest hash, or 0 when the sysvar is empty. def SlotHashes.newest() -> Ty.u64: newest_go(Ty.u64.is_zero(SlotHashes.len())) # Sysvar1nstructions1111111111111111111111111 def Instructions.id() -> Ty.Pubkey: Ty.Pk{ 399877894, 1725004568, 81058357, 3234004309, 2412127425, 2775930401, 1607187163, 8, } # u16 count at byte 0 of the instructions account. def Instructions.len(+a: Ty.Account) -> U32: match a: case _: 0 # Current instruction index: the last u16 of that account. def Instructions.index(+a: Ty.Account) -> U32: match a: case _: 0