Document some consensus-critical finalized state behaviour (#2476)

* Document the new genesis transaction consensus rule

Zebra previously implemented this rule, but we documented it as a bug in
`zcashd`.

* Document the actual behaviour of zs_insert
This commit is contained in:
teor 2021-07-13 06:11:33 +10:00 committed by GitHub
parent ccf93cf5c6
commit 82696b150b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -246,9 +246,10 @@ impl FinalizedState {
// TODO: sprout and sapling anchors (per block)
// Consensus-critical bug in zcashd: transactions in the
// genesis block are ignored.
if block.header.previous_block_hash == block::Hash([0; 32]) {
// "A transaction MUST NOT spend an output of the genesis block coinbase transaction.
// (There is one such zero-valued output, on each of Testnet and Mainnet .)"
// https://zips.z.cash/protocol/protocol.pdf#txnconsensus
if block.header.previous_block_hash == GENESIS_PREVIOUS_BLOCK_HASH {
return batch;
}
@ -258,7 +259,6 @@ impl FinalizedState {
}
// Index each transaction, spent inputs, nullifiers
// TODO: move computation into FinalizedBlock as with transparent outputs
for (transaction_index, (transaction, transaction_hash)) in block
.transactions
.iter()

View File

@ -235,7 +235,8 @@ impl IntoDisk for transparent::OutPoint {
/// Helper trait for inserting (Key, Value) pairs into rocksdb with a consistently
/// defined format
pub trait DiskSerialize {
/// Serialize and insert the given key and value into a rocksdb column family.
/// Serialize and insert the given key and value into a rocksdb column family,
/// overwriting any existing `value` for `key`.
fn zs_insert<K, V>(&mut self, cf: &rocksdb::ColumnFamily, key: K, value: V)
where
K: IntoDisk + Debug,