2

I'm wondering the differences between slot hash and block hash, and how are they calculated? (i.e., they are calculated based on what?)

From the "Sysvar: Slot hashes" on Solana explorer, We can see 512 most recent slot numbers and their corresponding slot hashes, shown in the following screenshot:

Screenshot of slot hashes

And after clicking the link of the latest slot (here we click slot 264031461), we can examine the details of block (the one and only one block) that belongs to this slot, shown in the following screenshot:

enter image description here

Apparently, slot hash and block hash are 2 different things. So how are they calculated?

My scenario: I want to implement a game like coin flip, but I don't want to use the slot hash or block hash of the latest slot as a pseudo-random number. I don't want to use a oracle or VRF either. So I'm wondering if I could use the slot/block hash of the slot which is the 100th slots in the future (100 slots roughly equal 40 seconds). Is the epoch leader/validator able to manipulate the hash to her favor? For example, she could construct a transaction in the 100th slots in the future so that the result of the coin flip is good to her.

2 Answers 2

3

As you've noticed, slot hash and block hash are not the same thing. They depend on each other for generation, but they have different purposes. To put it simply, the block hash belongs to a completed block, while a slot hash is recorded regularly for Proof-of-history.

For your case, future slot hashes and block hashes are not available to you when working on-chain, you only have access to past slot hashes and block hashes.

Either way, a validator can certainly wait until the hash is favorable to them before deciding to execute a transaction, or they could influence it by including certain transactions.

2
  • Yes future slot hashes and block hashes aren't available when executing an on-chain program. However, I could do this:
    – Yan
    Commented May 15 at 6:40
  • When a user plays my coin-flip game, she should first call enterGame and pay for the bet. Inside this instruction, the latest slot number (say slotNumberWhenEntering) will be recorded in a PDA which is derived by her wallet address. After some time, she must call concludeGame. Inside this instruction, we'll check if slot slotNumberWhenEntering + 100 is present in the slot hashes sysvar account. If it's present, we'll conclude the bet result based on the slot hash of slotNumberWhenEntering + 100.
    – Yan
    Commented May 15 at 6:46
0

My current understanding: you can think of a slot as discrete period of time where a block can be produced. For various reasons about 6% of slots don’t have blocks. If there's no block, the new slothash is generated from the proof of history hashing algorithm which allows us to know time has passed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.