Skip to content

Commit ff501b1

Browse files
committed
Add BIP-xxxx: additional coinbase fields for GBT
1 parent ecb074d commit ff501b1

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

bip-coinbase-fields-bip54.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
```
2+
BIP: ?
3+
Layer: API/RPC
4+
Title: getblocktemplate - additional coinbase fields
5+
Authors: Sjors Provoost <sjors@sprovoost.nl>
6+
Status: Draft
7+
Type: Specification
8+
Assigned: ?
9+
License: BSD-2-Clause
10+
Requires: 22
11+
```
12+
13+
## Abstract
14+
15+
This BIP describes modifications to the `getblocktemplate` JSON-RPC call
16+
([BIP 22](bip-0022.mediawiki)) to allow servers to specify the coinbase
17+
transaction's `nVersion`, `nLockTime`, and `nSequence` fields.
18+
19+
## Motivation
20+
21+
[BIP 54](bip-0054.md) proposes new consensus rules that would constrain the
22+
coinbase transaction's `nLockTime` and `nSequence` fields. Although BIP 54
23+
is the direct motivation for this BIP, it can be implemented independently.
24+
25+
BIP 54 does not constrain `nVersion`, but it's included in this BIP so that
26+
`getblocktemplate` now covers all coinbase transaction fields.[^complete]
27+
28+
This BIP only adds fields to the server response. It does not introduce
29+
consensus constraints on their values. However, it does require clients to
30+
use the exact value provided by the server (with a caveat for `nLockTime`).
31+
This makes it safer for soft forks to constrain these fields in the future.
32+
33+
## Specification
34+
35+
### Block Template
36+
37+
The template Object is extended to include new keys:
38+
39+
| Key | Required | Type | Description |
40+
|-----|----------|------|-------------|
41+
| `coinbase_version` | Yes | Number | coinbase `nVersion` value |
42+
| `coinbase_locktime` | Yes | Number | coinbase `nLockTime` value |
43+
| `coinbase_sequence` | Yes | Number | coinbase `nSequence` value |
44+
45+
Types are JSON types as defined in [BIP 22](bip-0022.mediawiki).
46+
47+
The `coinbase_version` field specifies the value that MUST be
48+
used for the coinbase transaction's `nVersion` field.[^version]
49+
50+
The `coinbase_locktime` field specifies the exact value that
51+
SHOULD be used for the coinbase transaction's `nLockTime` field.
52+
If BIP54 is activated then it MUST be used.[^locktime]
53+
54+
The `coinbase_sequence` field specifies a value that MUST be used
55+
for the coinbase transaction input's `nSequence` field.[^sequence]
56+
57+
## Rationale
58+
59+
Included as footnotes.
60+
61+
## Backward Compatibility
62+
63+
Servers that do not support this BIP will not include the new fields. Clients
64+
that do not understand these fields may ignore them. However, they will produce
65+
invalid blocks if [BIP 54](bip-0054.md) is activated, unless they independently
66+
implement the required constraints.
67+
68+
## Reference Implementation
69+
70+
- Bitcoin Core: [bitcoin/bitcoin#34419](https://github.com/bitcoin/bitcoin/pull/34419)
71+
72+
## Copyright
73+
74+
This BIP is licensed under the BSD 2-clause license.
75+
76+
[^version]: **What value should servers use for `coinbase_version`?**
77+
At the time of writing, there is no consensus constraint on transaction
78+
versions. Transaction version 2 is the latest version with defined
79+
semantics, as specified in [BIP 68](bip-0068.mediawiki), but its relative
80+
lock-time rules do not apply to the coinbase input. If future consensus
81+
rules constrain transaction versions, servers MUST reflect those rules in
82+
`coinbase_version`. Clients MUST use this value so that they don't need
83+
to be updated again later.
84+
85+
[^locktime]: **Why SHOULD vs MUST?**
86+
Unless BIP 54 is not activated, the `nLockTime` field could potentially be
87+
used as an `extraNonce`, which downstream software may need to roll. This
88+
use case would be ruled out by BIP 54 activation. It requires an `nLockTime`
89+
that's interpreted as a height and also constrains `nSequence`. That leaves
90+
no flexibility in `nLockTime`.
91+
92+
[^sequence]: **Why not use a bit mask?**
93+
The only restriction BIP 54 proposes for `nSequence` is to disallow
94+
`0xffffffff`. The server could communicate this intention via a bit mask,
95+
but for simplicity it just provides the entire `nSequence` value. Clients
96+
MUST use this value, so that future soft forks can safely add additional
97+
constraints.
98+
99+
[^complete]: **Does `getblocktemplate` now cover all coinbase transaction
100+
fields?**
101+
All fields that could potentially be constrained by a soft fork are now
102+
covered. The coinbase input's prevout txid (32 zero bytes) and vout index
103+
(0xffffffff) are fixed by consensus, so they can be safely hardcoded in
104+
mining software.
105+
106+

0 commit comments

Comments
 (0)