Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate transparent coinbase transaction data for BlockTemplate #5453

Closed
7 of 8 tasks
Tracked by #5235 ...
oxarbitrage opened this issue Oct 21, 2022 · 6 comments · Fixed by #5580
Closed
7 of 8 tasks
Tracked by #5235 ...

Populate transparent coinbase transaction data for BlockTemplate #5453

oxarbitrage opened this issue Oct 21, 2022 · 6 comments · Fixed by #5580

Comments

@oxarbitrage
Copy link
Contributor

oxarbitrage commented Oct 21, 2022

Motivation

The coinbasetxn field of the BlockTemplate is a struct:(#5235 (comment)) and can be complex enough to implement it in a separated ticket.

Specifications

  • [NU5 onward] The transaction version number MUST be 4 or 5. If the transaction version number is 4 then the version group ID MUST be 0x892F2085. If the transaction version number is 5 then the version group ID MUST be 0x26A7270A.
  • [NU5 onward] If effectiveVersion ≥ 5, the nConsensusBranchId field MUST match the consensus branch ID used for SIGHASH transaction hashes, as specified in [ZIP-244].
  • The total value in zatoshi of transparent outputs from a coinbase transaction, minus vbalanceSapling, minus vbalanceOrchard, MUST NOT be greater than the value in zatoshi of block subsidy plus the transaction fees paid by transactions in this block.
  • [NU5 onward] In a version 5 coinbase transaction, the enableSpendsOrchard flag MUST be 0.
  • [NU5 onward] In a version 5 transaction, the reserved bits 2 .. 7 of the flagsOrchard field MUST be zero.
  • A coinbase transaction for a block at block height greater than 0 MUST have a script that, as its first item, encodes the block height height as follows. For height in the range {1 .. 16}, the encoding is a single byte of value 0x50 + height. Otherwise, let heightBytes be the signed little-endian representation of height, using the minimum nonzero number of bytes such that the most significant byte is < 0x80. The length of heightBytes MUST be in the range {1 .. 5}. Then the encoding is the length of heightBytes encoded as one byte, followed by heightBytes itself. This matches the encoding used by Bitcoin in the implementation of [BIP-34] (but the description here is to be considered normative).
  • A coinbase transaction script MUST have length in {2 .. 100} bytes.
  • [NU5 onward] The nExpiryHeight field of a coinbase transaction MUST be equal to its block height .

https://zips.z.cash/protocol/protocol.pdf#txnconsensus

Tasks

Shielded coinbase is out of scope, most miners don't use it.

  • Create CoinBaseTxn struct.

  • Populate on getblocktemplate response

    • The coinbase transaction has the following fixed values:
      • required: true
    • Here are the fields that are calculated from the transactions, including the coinbase transaction:
      • defaultroots
        • authdataroot
        • merkleroot
  • Test: TODO

Depends on #5451

@teor2345
Copy link
Contributor

teor2345 commented Oct 24, 2022

@oxarbitrage I think the coinbase transaction depends on the transactions from ticket #5454, and the miner address from ticket #5456, because it includes the transaction fee, and pays the miner reward and fee to the miner.

@teor2345
Copy link
Contributor

Here are the fields that are calculated from the transactions, including the coinbase transaction:

  • defaultroots
    • authdataroot
    • merkleroot

And here are the fields that are calculated from the transactions, and the state request in #5455:

  • defaultroots
    • blockcommitmentshash (same value for lightclientroothash, finalsaplingroothash, and blockcommitmentshash)

Can I edit the ticket?

@teor2345
Copy link
Contributor

I think we might want to open another ticket for shielded coinbase, most of the existing coinbase transactions are transparent. (All the funding streams are transparent, and almost all miner payments are transparent.)

@mpguerra
Copy link
Contributor

I think we might want to open another ticket for shielded coinbase, most of the existing coinbase transactions are transparent. (All the funding streams are transparent, and almost all miner payments are transparent.)

Let's open the issue, however I'm not sure that we need to do this as part of an MVP for the getblocktemplate work.

@mpguerra
Copy link
Contributor

@teor2345 teor2345 changed the title 4- Populate the coinbase transaction data of BlockTemplate 4- Populate transparent coinbase transaction data for BlockTemplate Oct 25, 2022
@mpguerra mpguerra changed the title 4- Populate transparent coinbase transaction data for BlockTemplate Populate transparent coinbase transaction data for BlockTemplate Oct 26, 2022
@teor2345
Copy link
Contributor

teor2345 commented Nov 8, 2022

I split #5579 out of this ticket, because the state request isn't ready yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants