\crossref{coinbasetransactions} effectively defined a coinbase transaction as the first

transaction in a block. This wording was copied from the Bitcoin Developer Reference
(https://developer.bitcoin.org/reference/transactions.html#coinbase-input-the-input-of-the-first-transaction-in-a-block),
but it does not match the implementation in zcashd that was inherited from Bitcoin Core.

Instead, a coinbase transaction should be, and now is, defined as a transaction with a
single null prevout. The specifications of consensus rules have been clarified and adjusted
(without any actual consensus change) to take this into account, as follows:

 * a block MUST have at least one transaction;
 * the first transaction in a block MUST be a coinbase transaction, and subsequent
   transactions MUST NOT be coinbase transactions;
 * a transparent input in a non-coinbase transaction MUST NOT have a null prevout;
 * every non-null prevout MUST point to a unique UTXO in either a preceding block, or a
   *previous* transaction in the same block (this rule was previously not given explicitly
   because it was assumed to be inherited from Bitcoin);
 * the rule that "A coinbase transaction MUST NOT have any transparent inputs with non-null
   prevout fields" is removed as an explicit consensus rule because it is implied by the
   corrected definition of coinbase transaction.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-03-18 01:26:24 +00:00
parent e123584794
commit e381ded490
2 changed files with 44 additions and 10 deletions

View File

@ -3677,9 +3677,11 @@ The calculations are described in \crossref{subsidies}.
\lsubsection{Coinbase Transactions}{coinbasetransactions}
The first (and only the first) \transaction in a block is a \defining{\coinbaseTransaction},
which collects and spends any \minerSubsidy and \transactionFees paid by \transactions
included in this \block.
A \transaction that has a single \transparentInput with a null \prevoutField{} field, is
called a \defining{\coinbaseTransaction}. Every \block has a single \coinbaseTransaction
as the first \transaction in the \block. The purpose of this \coinbaseTransaction is to
collect and spend any \minerSubsidy, and \transactionFees paid by other \transactions included
in the \block.
\precanopy{As described in \crossref{foundersreward}, the \coinbaseTransaction \MUST also pay
the \foundersReward.}
@ -12601,13 +12603,9 @@ in \cite{ZIP-239}.
\item The total value in \zatoshi of \transparentOutputs from a \coinbaseTransaction\heartwood{, minus
$\vBalance{Sapling}$,}\nufive{ minus $\vBalance{Orchard}$,} \MUSTNOT be greater than the value in
\zatoshi of \blockSubsidy plus the \transactionFees paid by \transactions in this \block.
\item A \coinbaseTransaction \MUSTNOT have any \transparentInputs with non-null $\prevout$ fields,\notheartwood{
\joinSplitDescriptions\sapling{, \spendDescriptions, or \outputDescriptions}.
}
\notbeforeheartwood{
\joinSplitDescriptions\sapling{, or \spendDescriptions}.
\preheartwooditem{\sapling{A \coinbaseTransaction also \MUSTNOT have any \outputDescriptions.}}
}
\item A \coinbaseTransaction \MUSTNOT have any \joinSplitDescriptions.
\item \sapling{A \coinbaseTransaction \MUSTNOT have any \spendDescriptions.}
\preheartwooditem{\sapling{A \coinbaseTransaction \MUST have any \outputDescriptions.}}
\nufiveonwarditem{In a version 5 \coinbaseTransaction, the \enableSpendsOrchard{} flag \MUST be $0$.}
\nufiveonwarditem{In a version 5 \transaction, the reserved bits $\barerange{2}{7}$ of the
\flagsOrchard{} field \MUST be zero.}
@ -12621,6 +12619,9 @@ in \cite{ZIP-239}.
the encoding used by \Bitcoin in the implementation of \cite{BIP-34} (but the description here
is to be considered normative).
\item A \coinbaseTransaction script \MUST have length in $\range{2}{100}$ bytes.
\item A \transparentInput in a non-coinbase \transaction \MUSTNOT have a null \prevout.
\item Every non-null \prevout \MUST point to a unique \utxo in either a preceding \block, or a
\emph{previous} \transaction in the same \block.
\item %\consensuslink{bad-txns-premature-spend-of-coinbase}
A \transaction \MUSTNOT spend a \transparentOutput of a \coinbaseTransaction
from a \block less than 100 \blocks prior to the spend. Note that \transparentOutputs of
@ -13100,6 +13101,9 @@ preceding \blocks if there are fewer than $\PoWMedianBlockSpan$). The \medianTim
\nufiveonwarditem{$\hashBlockCommitments$ \MUST be set to the value of $\hashBlockCommitments$
for this \block, as specified in \cite{ZIP-244}.}
}
\item A \block \MUST have at least one \transaction.
\item The first \transaction in a \block \MUST be a \coinbaseTransaction, and subsequent
\transactions \MUSTNOT be \coinbaseTransactions.
\item \todo{Other rules inherited from \Bitcoin.}
\end{consensusrules}
@ -14627,6 +14631,29 @@ Peter Newell's illustration of the Jubjub bird, from \cite{Carroll1902}.
} %sapling
\item Document the consensus rule that coinbase script length \MUST be
$\range{2}{100}$ bytes.
\item \crossref{coinbasetransactions} effectively defined a \coinbaseTransaction
as the first \transaction in a \block. This wording was copied from the
Bitcoin Developer Reference \cite{Bitcoin-CbInput}, but it does not match
the implementation in \zcashd that was inherited from \BitcoinCore.
Instead, a \coinbaseTransaction should be, and now is, defined as a
\transaction with a single null \prevout.
The specifications of consensus rules have been clarified and adjusted
(without any actual consensus change) to take this into account, as follows:
\begin{itemize}
\item a \block \MUST have at least one \transaction;
\item the first \transaction in a \block \MUST be a \coinbaseTransaction,
and subsequent \transactions \MUSTNOT be \coinbaseTransactions;
\item a \transparentInput in a non-coinbase \transaction \MUSTNOT have
a null \prevout;
\item every non-null \prevout \MUST point to a unique \utxo in either
a preceding \block, or a \emph{previous} \transaction in the
same \block (this rule was previously not given explicitly
because it was assumed to be inherited from \Bitcoin);
\item the rule that ``A \coinbaseTransaction \MUSTNOT have any
\transparentInputs with non-null \prevoutField{} fields'' is
removed as an explicit consensus rule because it is implied by
the corrected definition of \coinbaseTransaction.
\end{itemize}
\end{itemize}

View File

@ -990,6 +990,13 @@ Last revised February~5, 2018.}
urldate={2020-07-13}
}
@misc{Bitcoin-CbInput,
presort={Bitcoin-CoinbaseIn},
title={Coinbase Input --- {B}itcoin {D}eveloper {R}eference},
url={https://developer.bitcoin.org/reference/transactions.html#coinbase-input-the-input-of-the-first-transaction-in-a-block},
urldate={2022-03-17}
}
@misc{Bitcoin-Multisig,
presort={Bitcoin-Multisig},
title={Transactions: {M}ultisig --- {B}itcoin {D}eveloper {G}uide},