BIP: 145 Title: getblocktemplate Updates for Segregated Witness Author: Luke Dashjr <[email protected]> Status: Draft Type: Standards Track Created: 2016-01-30
This BIP describes modifications to the getblocktemplate JSON-RPC call (BIP 22) to support segregated witness as defined by BIP 141.
The template Object is revised to include these keys:
template | |||
---|---|---|---|
Key | Required | Type | Description |
costlimit | No | Number | total cost allowed in blocks |
sigoplimit | No | Number | total sigop cost allowed in blocks divided by 4 |
version | Yes | Number | block version; clients MUST understand the implications of the version they use (eg, comply with BIP 141 for version 5) |
The Objects listed in the response's "transactions" key is revised to include these keys:
template "transactions" element | ||
---|---|---|
Key | Type | Description |
txid | String | transaction id encoded in hexadecimal; required for transactions with witness data |
cost | Number | numeric cost of the transaction, as counted for purposes of the block's costlimit; if key is not present, cost is unknown and clients MUST NOT assume it is zero, although they MAY choose to calculate it themselves |
hash | String | reversed hash of complete transaction (with witness data included) encoded in hexadecimal |
Transactions with witness data may only be included if the template's block version is at least 5.
When block assembly is done without witness transactions, no changes are made by this BIP, and it should be assembled as previously.
When witness transactions are included in the block, the primary merkle root MUST be calculated with those transactions' "txid" field instead of "hash". A secondary merkle root MUST be calculated as per BIP 141's commitment structure specification to be inserted into the generation (coinbase) transaction.
Servers MUST NOT include a commitment in the "coinbasetxn" key on the template. Clients MUST insert the commitment as an additional output at the end of the final generation (coinbase) transaction. Only if the template includes a "mutable" key (see BIP 23 Mutations) including "generation", the client MAY in that case place the commitment output in any position it chooses, provided that no later output matches the commitment pattern.
Segregated witness substantially changes the structure of blocks, so the previous getblocktemplate specification is no longer sufficient. It additionally also adds a new way of counting resource limits, and so GBT must be extended to convey this information correctly as well.
Why doesn't "costlimit" simply redefine the existing "sizelimit"?
- "sizelimit" is already enforced by clients by counting the sum of bytes in transactions' "data" keys.
- Servers may wish to limit the overall size of a block, independently from the "cost" of the block.
- The old limit was already arbitrarily defined, and could not be counted by clients on their own anyway. The concept of "sigop cost" is merely a change in the arbitrary formula used.
- To resemble the previous values. (FIXME: is this a good reason? maybe we shouldn't divide it?)
- Servers which do not allow modification of the generation outputs ought to be checking this as part of the validity of submissions. By requiring a specific placement, they can simply strip the commitment and do a byte-for-byte comparison of the outputs. Placing it at the end avoids the possibility of a later output matching the pattern and overriding it.
- It would become impossible for servers to specify only "coinbasevalue", since clients would no longer have the information required to construct the commitment.
- getblocktemplate is intended to be a *decentralised* mining protocol, and allowing clients to be blinded to the content of the block works contrary to that purpose.
- BIP 23's "transactions" mutations allow the client to modify the transaction-set on their own, which is impossible without the complete transaction data.
- BIP 22: getblocktemplate - Fundamentals
- BIP 23: getblocktemplate - Pooled Mining
- BIP 141: Segregated Witness (Consensus layer)
This BIP is dual-licensed under the Open Publication License and BSD 2-clause license.