Skip to main content

Module block_proof

Module block_proof 

Source
Expand description

Proofs of Tenderdash blocks: what getBlocks and getOwnerTransactionsInBlock return when asked to prove.

Tenderdash already commits to a block’s contents. The transactions and their execution results are Merkle trees whose roots are in the block header, the header hashes to the block id, and the validator quorum signs a vote for that block id. A proof carries the header, the block id and the signature, and for single transactions the Merkle paths to the two roots.

This module is the one definition of every hash on that chain. DAPI builds its proofs with it and checks them before they leave (check_header, check_block_contents, check_block_fields, MerkleTree), and a client verifies them with it (verify_block_proof, verify_transaction_proof), so a node cannot hand out a proof that clients refuse.

Modules§

fixtures
Blocks signed by test quorums, and the answers a node would give for them, for tests of this crate and of the crates that verify block proofs through it.

Structs§

MerkleTree
The tree over some leaves, with the paths of the selected ones: what a node needs to prove those leaves are under the root.

Enums§

BlockProofError
Why a Tenderdash block proof, or what an answer says about the block, was refused.

Functions§

check_block_contents
Check that a block’s contents are the ones header commits to: every transaction, by its hash, in block order, and the result leaf of each.
check_block_fields
Check that the fields a getBlocks block repeats from its header are the ones in proof. Only the header is signed, and a node reads those fields from another Tenderdash answer than the proof, so nothing else ties them to it.
check_header
Check that header is the one behind block_id: that it hashes to the block hash and to the state id, the two values of a block id a quorum’s signature covers.
header_hash
The hash Tenderdash gives a block: the Merkle root of its header’s fields, each in its protobuf encoding. A string, number or hash is wrapped in a one-field message first, so one that is empty or zero is an empty leaf.
header_time_ms
A header’s time in milliseconds since the Unix epoch, the precision a state id keeps.
merkle_root
The root of the tree over leaves.
proof_parts
The header and block id of a proof, which a well-formed one always carries.
result_leaf
The leaf of a transaction’s execution result in the tree behind a header’s results_hash: Tenderdash hashes only these fields of the result.
root_from_path
Follow path up from the leaf at index of a tree of total leaves, returning the root it leads to. path runs from the leaf’s sibling up to a child of the root.
state_id_hash
The state id Tenderdash derives from a header, which the quorum signs next to the block hash: the hash of these fields as Tenderdash’s StateID.
transaction_hash
The hash Tenderdash knows a transaction by, which is also its leaf in the tree behind a header’s data_hash.
verify_block_proof
Verify that a quorum committed the block proof describes, and return that block’s header, every field of which the quorum’s signature then covers.
verify_transaction_proof
Check that a transaction and its execution result are in the block of header, at the position proof names.