3

example blockhash

Specifically,

  • What is the hash function used?
  • What are the inputs to the hash function, and in what order?

The docs have a glossary entry on it, but it's very brief. So too is the "What is a blockhash?" section.

From what I gathered from these 2 articles, entry_id = hash(transaction_ids of the entry's transactions), where an entry which is a set of transactions that do not have write conflicts with each other and can be executed in parallel. Blockhash is a PoH hash "calculated from the last entry_id of the block" by taking hash(prev_PoH_hash, entry_id). Not sure if this is correct, and could use more details on this - for example, in what order are the transaction_ids hashed? Are there other inputs to calculate entry_id?

Would also really appreciate it if someone could link to the part in the main github repo where it's calculated and used for future reference. Thanks!

1 Answer 1

2

It's a bit tough to search through the whole thing, but you have a lot of parts correct!

The hash function used is SHA-256: https://github.com/solana-labs/solana/blob/0dcac3fe7c4832fc6f358f010ddba8a116da70ab/sdk/program/src/hash.rs#L55

You can see where proof-of-history registers ticks onto the bank at https://github.com/solana-labs/solana/blob/0dcac3fe7c4832fc6f358f010ddba8a116da70ab/poh/src/poh_recorder.rs#L687

Ticks can come from two sources: proof-of-history hashing and transactions.

Proof-of-history registers empty ticks through sequential hashing at https://github.com/solana-labs/solana/blob/0dcac3fe7c4832fc6f358f010ddba8a116da70ab/poh/src/poh_recorder.rs#L801

The banking stage registers entries with executed transactions using the TransactionRecorder at https://github.com/solana-labs/solana/blob/0dcac3fe7c4832fc6f358f010ddba8a116da70ab/core/src/banking_stage/consumer.rs#L623

That's eventually consumed by the Proof-of-history service at https://github.com/solana-labs/solana/blob/0dcac3fe7c4832fc6f358f010ddba8a116da70ab/poh/src/poh_service.rs#L239

Proof-of-history is either creating hashes from sequentially hashing empty ticks or sets of transactions, and one of those eventually becomes the "blockhash" inside the bank, once the right amount of ticks have been registered: https://github.com/solana-labs/solana/blob/0dcac3fe7c4832fc6f358f010ddba8a116da70ab/runtime/src/bank.rs#L4197

I might have some steps out of order with the way messages are passed between the different systems, but I hope you'll be able to dig in with some of this info!

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.