diff --git a/zebra-chain/src/sapling/spend.rs b/zebra-chain/src/sapling/spend.rs index d0f1e373e..578619d23 100644 --- a/zebra-chain/src/sapling/spend.rs +++ b/zebra-chain/src/sapling/spend.rs @@ -171,6 +171,20 @@ impl ZcashSerialize for Spend { } impl ZcashDeserialize for Spend { + /// # Consensus + /// + /// > The anchor of each Spend description MUST refer to some earlier + /// > block’s 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. + /// + /// + /// + /// 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(mut reader: R) -> Result { Ok(Spend { cv: commitment::NotSmallOrderValueCommitment::zcash_deserialize(&mut reader)?, diff --git a/zebra-chain/src/transaction/serialize.rs b/zebra-chain/src/transaction/serialize.rs index 014cc7fae..0aa653a1e 100644 --- a/zebra-chain/src/transaction/serialize.rs +++ b/zebra-chain/src/transaction/serialize.rs @@ -224,6 +224,21 @@ impl ZcashDeserialize for Option> { .collect(); // Create transfers + // + // # Consensus + // + // > The anchor of each Spend description MUST refer to some earlier + // > block’s 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. + // + // + // + // 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, diff --git a/zebra-consensus/src/transaction.rs b/zebra-consensus/src/transaction.rs index 96614bd43..635b7601f 100644 --- a/zebra-consensus/src/transaction.rs +++ b/zebra-consensus/src/transaction.rs @@ -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. + // + // async_checks.push( primitives::redpallas::VERIFIER .clone()