Update the BlockHeader fields for Heartwood (#767)
The Heartwood upgrade changes the meaning of the hashFinalSaplingRoot to hashLightClientRoot. Since we don't know the network upgrade heights in zebra-chain, we just use [u8; 32] for now.
This commit is contained in:
parent
59eb23772d
commit
06157a7c8e
|
@ -1,7 +1,6 @@
|
|||
use super::{difficulty::CompactDifficulty, BlockHeaderHash, Error};
|
||||
use crate::equihash_solution::EquihashSolution;
|
||||
use crate::merkle_tree::MerkleTreeRootHash;
|
||||
use crate::note_commitment_tree::SaplingNoteTreeRootHash;
|
||||
use crate::serialization::ZcashSerialize;
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
|
||||
|
@ -47,7 +46,7 @@ pub struct BlockHeader {
|
|||
// - replace with an unspecified HistoryRootHash type?
|
||||
// Note that the NetworkUpgrade list is in zebra-consensus, so we can't
|
||||
// parse this field into a HistoryRootHash enum in zebra-chain.
|
||||
pub final_sapling_root_hash: SaplingNoteTreeRootHash,
|
||||
pub history_root_hash: [u8; 32],
|
||||
|
||||
/// The block timestamp is a Unix epoch time (UTC) when the miner
|
||||
/// started hashing the header (according to the miner).
|
||||
|
|
|
@ -5,7 +5,6 @@ use std::io;
|
|||
use crate::block::difficulty::CompactDifficulty;
|
||||
use crate::equihash_solution::EquihashSolution;
|
||||
use crate::merkle_tree::MerkleTreeRootHash;
|
||||
use crate::note_commitment_tree::SaplingNoteTreeRootHash;
|
||||
use crate::serialization::ZcashDeserializeInto;
|
||||
use crate::serialization::{ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize};
|
||||
|
||||
|
@ -19,7 +18,7 @@ impl ZcashSerialize for BlockHeader {
|
|||
writer.write_u32::<LittleEndian>(self.version)?;
|
||||
self.previous_block_hash.zcash_serialize(&mut writer)?;
|
||||
writer.write_all(&self.merkle_root_hash.0[..])?;
|
||||
writer.write_all(&self.final_sapling_root_hash.0[..])?;
|
||||
writer.write_all(&self.history_root_hash[..])?;
|
||||
// this is a truncating cast, rather than a saturating cast
|
||||
// but u32 times are valid until 2106, and our block verification time
|
||||
// checks should detect any truncation.
|
||||
|
@ -67,7 +66,7 @@ impl ZcashDeserialize for BlockHeader {
|
|||
version,
|
||||
previous_block_hash: BlockHeaderHash::zcash_deserialize(&mut reader)?,
|
||||
merkle_root_hash: MerkleTreeRootHash(reader.read_32_bytes()?),
|
||||
final_sapling_root_hash: SaplingNoteTreeRootHash(reader.read_32_bytes()?),
|
||||
history_root_hash: reader.read_32_bytes()?,
|
||||
// This can't panic, because all u32 values are valid `Utc.timestamp`s
|
||||
time: Utc.timestamp(reader.read_u32::<LittleEndian>()? as i64, 0),
|
||||
difficulty_threshold: CompactDifficulty(reader.read_u32::<LittleEndian>()?),
|
||||
|
|
|
@ -3,7 +3,6 @@ use super::*;
|
|||
use crate::block::difficulty::CompactDifficulty;
|
||||
use crate::equihash_solution::EquihashSolution;
|
||||
use crate::merkle_tree::MerkleTreeRootHash;
|
||||
use crate::note_commitment_tree::SaplingNoteTreeRootHash;
|
||||
use crate::serialization::{
|
||||
SerializationError, ZcashDeserialize, ZcashDeserializeInto, ZcashSerialize,
|
||||
};
|
||||
|
@ -26,7 +25,7 @@ impl Arbitrary for BlockHeader {
|
|||
(4u32..(i32::MAX as u32)),
|
||||
any::<BlockHeaderHash>(),
|
||||
any::<MerkleTreeRootHash>(),
|
||||
any::<SaplingNoteTreeRootHash>(),
|
||||
any::<[u8; 32]>(),
|
||||
// time is interpreted as u32 in the spec, but rust timestamps are i64
|
||||
(0i64..(u32::MAX as i64)),
|
||||
any::<CompactDifficulty>(),
|
||||
|
@ -38,7 +37,7 @@ impl Arbitrary for BlockHeader {
|
|||
version,
|
||||
previous_block_hash,
|
||||
merkle_root_hash,
|
||||
final_sapling_root_hash,
|
||||
history_root_hash,
|
||||
timestamp,
|
||||
difficulty_threshold,
|
||||
nonce,
|
||||
|
@ -47,7 +46,7 @@ impl Arbitrary for BlockHeader {
|
|||
version,
|
||||
previous_block_hash,
|
||||
merkle_root_hash,
|
||||
final_sapling_root_hash,
|
||||
history_root_hash,
|
||||
time: Utc.timestamp(timestamp, 0),
|
||||
difficulty_threshold,
|
||||
nonce,
|
||||
|
|
Loading…
Reference in New Issue