Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions bip-0141.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ If all transactions in a block do not have witness data, the commitment is optio
A <code>scriptPubKey</code> (or <code>redeemScript</code> as defined in BIP16/P2SH) that consists of a 1-byte push opcode (for 0 to 16) followed by a data push between 2 and 32 bytes gets a new special meaning. The value of the first push is called the "version byte". The following byte vector pushed is called the "witness program".

There are two cases in which witness validation logic are triggered. Each case determines the location of the witness version byte and program, as well as the form of the scriptSig:
# Triggered by a <code>scriptPubKey</code> that is exactly a push of a version byte, plus a push of a witness program. The scriptSig must be exactly empty or validation fails.
# Triggered when a <code>scriptPubKey</code> is a P2SH script, and the BIP16 <code>redeemScript</code> pushed in the <code>scriptSig</code> is exactly a push of a version byte plus a push of a witness program. The <code>scriptSig</code> must be exactly a push of the BIP16 <code>redeemScript</code> or validation fails.
# Triggered by a <code>scriptPubKey</code> that is exactly a push of a version byte, plus a push of a witness program. The scriptSig must be exactly empty or validation fails. (''"native witness program"'')
# Triggered when a <code>scriptPubKey</code> is a P2SH script, and the BIP16 <code>redeemScript</code> pushed in the <code>scriptSig</code> is exactly a push of a version byte plus a push of a witness program. The <code>scriptSig</code> must be exactly a push of the BIP16 <code>redeemScript</code> or validation fails. (''"P2SH witness program"'')

If the version byte is 0, and the witness program is 20 bytes:
* It is interpreted as a pay-to-witness-public-key-hash (P2WPKH) program.
Expand Down Expand Up @@ -120,9 +120,11 @@ The new rule is ''block cost'' ≤ 4,000,000.

Sigops per block is currently limited to 20,000. We change this restriction as follows:

''Sigop cost'' is defined. The cost of a sigop in traditional script is 4, while the cost of a sigop in witness program is 1.
Sigops in the current pubkey script, signature script, and P2SH check script are counted at 4 times their previous value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for removing the sigop cost terminology? I thought it was useful to distinguish from the original sigops definition.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how the original sigops definition is relevant post-segwit. ie, what's the point?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoiding confusion :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find it more confusing to have two terms for essentially the same thing of different versions... should GBT be changed to remove sigops/sigoplimit and add sigopcost/sigopcostlimit as well?

The sigop limit is likewise quadrupled to ≤ 80,000.

The new rule is total ''sigop cost'' ≤ 80,000.
In addition, opcodes within the witness program are counted identical to as previously within the P2SH check script.
That is, CHECKSIG in a witness program is counted as only 1 sigop, and CHECKMULTISIG in a witness program is counted as 1 to 20 sigops according to the arguments. This rule applies to both native witness program and P2SH witness program.

== Examples ==

Expand Down Expand Up @@ -272,7 +274,7 @@ As a soft fork, older software will continue to operate without modification. N

== Deployment ==

This BIP will be deployed by "version bits" BIP9 using bit 1.
This BIP will be deployed by "version bits" BIP9 with the name "segwit" and using bit 1.

For Bitcoin mainnet, the BIP9 starttime will be midnight TBD UTC (Epoch timestamp TBD) and BIP9 timeout will be midnight TBD UTC (Epoch timestamp TBD).

Expand Down
17 changes: 11 additions & 6 deletions bip-0145.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ This BIP describes modifications to the getblocktemplate JSON-RPC call ([[bip-00

===Block Template===

The template Object is revised to include these keys:
The template Object is revised to include a new key:

{| class="wikitable"
!colspan=4| 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-0141.mediawiki|BIP 141]] for version 5)
|}

The '!' rule prefix MUST be enabled on the "segwit" rule for templates including transactions with witness data.
In particular, note that even if the client's "rules" list lacks "segwit", server MAY support old miners by producing a witness-free template and omitting the '!' rule prefix for "segwit" in the template's "rules" list.
If the GBT server does not support producing witness-free templates after its activation, it must also use the '!' rule prefix in the "vbavailable" list prior to activation.

====Transactions Object Format====

The Objects listed in the response's "transactions" key is revised to include these keys:
Expand All @@ -45,7 +45,11 @@ The Objects listed in the response's "transactions" key is revised to include th
| 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.
Transactions with witness data may only be included if the template's "rules" list (see [[bip-0009.mediawiki#getblocktemplate_changes|BIP 9]]) includes "segwit".

===Sigops===

For templates with "segwit" enabled as a rule, the "sigoplimit" and "sigops" keys must use the new values as calculated in [[bip-0141.mediawiki#Sigops|BIP 141]].

===Block Assembly with Witness Transactions===

Expand Down Expand Up @@ -87,6 +91,7 @@ Why shouldn't the server simply add the commitment upfront in the "coinbasetxn",
* [https://github.com/bitcoin/bitcoin/pull/7404/files Bitcoin Core]

==See Also==
* [[bip-0009.mediawiki|BIP 9: Version bits with timeout and delay]]
* [[bip-0022.mediawiki|BIP 22: getblocktemplate - Fundamentals]]
* [[bip-0023.mediawiki|BIP 23: getblocktemplate - Pooled Mining]]
* [[bip-0141.mediawiki|BIP 141: Segregated Witness (Consensus layer)]]
Expand Down