BIP34, which is included in Zcash, encodes the block height into each block by adding it into the unused BitcoinScript field of the block's coinbase transaction. However, this is done just by requiring that the script pushes the block height onto the stack when it executes, and there are multiple different ways to push data onto the stack in BitcoinScript. Also, the genesis block does not include the block height, by accident. Because we want to *parse* transactions into an algebraic data type that encodes their structural properties, rather than allow possibly-invalid data to float through the internals of our node, we want to extract the block height upfront and store it separately from the rest of the coinbase data, which is inert. So the serialization code now contains just enough logic to parse BitcoinScript-encoded block heights, and special-case the encoding of the genesis block. Elsewhere in the source code, the `LockTime` struct requires that we must use block heights less than 500,000,000 (above which the number is interpreted as a unix timestamp, not a height). To unify invariants, we ensure that the parsing logic works with block heights up to 500,000,000, even though these are unlikely to ever be used for Zcash. |
||
---|---|---|
.github/workflows | ||
design | ||
zebra-chain | ||
zebra-client | ||
zebra-consensus | ||
zebra-network | ||
zebra-rpc | ||
zebra-script | ||
zebra-storage | ||
zebrad | ||
.firebaserc | ||
.gitignore | ||
.rustfmt.toml | ||
Cargo.lock | ||
Cargo.toml | ||
Dockerfile | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
clippy.toml | ||
cloudbuild.yaml | ||
firebase.json |
README.md
zebra 🦓
Hello! I am Zebra, an ongoing Rust implementation of a Zcash node.
Zebra is a work in progress. It is developed as a collection of zebra-*
libraries implementing the different components of a Zcash node (networking,
chain structures, consensus rules, etc), and a zebrad
binary which uses them.
Most of our work so far has gone into zebra-network
, building a new
networking stack for Zcash, and zebra-chain
, building foundational data
structures.
Rendered docs from the main
branch.
License
Zebra is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT.