Document the consensus rules for Section 3.6 (#3338)

This commit is contained in:
Marek 2022-01-25 00:27:45 +01:00 committed by GitHub
parent 9101e9a815
commit a1f4cec0de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 0 deletions

View File

@ -171,6 +171,20 @@ impl ZcashSerialize for Spend<PerSpendAnchor> {
}
impl ZcashDeserialize for Spend<PerSpendAnchor> {
/// # Consensus
///
/// > The anchor of each Spend description MUST refer to some earlier
/// > blocks final Sapling treestate. The anchor is encoded separately in
/// > each Spend description for v4 transactions, or encoded once and shared
/// > between all Spend descriptions in a v5 transaction.
///
/// <https://zips.z.cash/protocol/protocol.pdf#spendsandoutputs>
///
/// This rule is also implemented in
/// [`zebra_state::service::check::anchor`] and
/// [`zebra_chain::transaction::serialize`].
///
/// The "anchor encoding for v4 transactions" is implemented here.
fn zcash_deserialize<R: io::Read>(mut reader: R) -> Result<Self, SerializationError> {
Ok(Spend {
cv: commitment::NotSmallOrderValueCommitment::zcash_deserialize(&mut reader)?,

View File

@ -224,6 +224,21 @@ impl ZcashDeserialize for Option<sapling::ShieldedData<SharedAnchor>> {
.collect();
// Create transfers
//
// # Consensus
//
// > The anchor of each Spend description MUST refer to some earlier
// > blocks final Sapling treestate. The anchor is encoded separately
// > in each Spend description for v4 transactions, or encoded once and
// > shared between all Spend descriptions in a v5 transaction.
//
// <https://zips.z.cash/protocol/protocol.pdf#spendsandoutputs>
//
// This rule is also implemented in
// [`zebra_state::service::check::anchor`] and
// [`zebra_chain::sapling::spend`].
//
// The "anchor encoding for v5 transactions" is implemented here.
let transfers = match shared_anchor {
Some(shared_anchor) => sapling::TransferData::SpendsAndMaybeOutputs {
shared_anchor,

View File

@ -798,6 +798,13 @@ where
let bvk = orchard_shielded_data.binding_verification_key();
// # Consensus
//
// > The Spend transfers and Action transfers of a transaction MUST be
// > consistent with its vbalanceSapling value as specified in § 4.13
// > Balance and Binding Signature (Sapling) on p. 49.
//
// <https://zips.z.cash/protocol/protocol.pdf#spendsandoutputs>
async_checks.push(
primitives::redpallas::VERIFIER
.clone()