-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Fix GBT: Restore "!segwit" and "csv" to "rules" key #17946
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
Conversation
They have been missing since buried deployments were merged
Comments in IRC provide some context: without the information in rules field "miners have no way to know what rules are being used and might produce invalid blocks" |
Discussion in 16060 is here: #16060 (comment) |
(For clarity, I didn't mean fixing this bug in a separate PR, but rather the missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luke-jr : The rules field hasn't been populated with "!segwit" since 0.15 (#9955 changed the behaviour so that "segwit" would be included as a rule instead of "!segwit").
In IRC you stated that "miners have no way to know what rules are being used and might produce invalid blocks". Do you have any additional information about that? In what way would miners produce invalid blocks? Do you know of any miners that have had a problem because of this?
I don't have any objection to this change, but I'd like to better understand how miners have been impacted by this.
#9955 introduced a bug, sure, but that bug would only have impacted Segwit-unaware miners. Segwit-aware miners would have continued to work correctly because they saw that segwit was an active rule. Removing the rule entirely means that sigops are counted differently, and transactions may not include witness data. I don't know if there are any real-world miners impacted by this, but it is at least theoretically possible (IIRC, at least some branches of Eloipool support a safety trim based on sigop counts). |
I think you have this the wrong way round. Segwit-unaware miners would see "segwit" in the rules, but according to BIP 9:
and so the segwit-unaware miner would use the template, but not be able to add the witness commitment to the coinbase.
Since #14811, the GBT request must include "segwit" in the rule array, so sigops are always counted according to BIP 141 rules. Whether or not the return object includes "segwit" in the rules doesn't change this. In any case, I think it's fine to make this change because it doesn't really matter. Segwit has been active for two years and all miners using 0.18 onwards have to set "segwit" in the rules. I find it very hard to believe that any are reading what's returned in the rules field. |
They would fail by mining invalid blocks, instead of failing explicitly. Either way, they fail. Segwit-capable miners, on the other hand, shouldn't fail, but might because they think they're mining a non-segwit block.
The request rule doesn't affect sigop counting, only indicates the client can understand a segwit template. Sigop counting is enabled only when the template has segwit in its rules list. |
FYI without this mining with ckpool breaks since it will only try to produce segwit blocks when the segwit rule is seen. |
@@ -212,6 +207,7 @@ def run_test(self): | |||
assert tmpl['sigoplimit'] == 80000 | |||
assert tmpl['transactions'][0]['txid'] == txid | |||
assert tmpl['transactions'][0]['sigops'] == 8 | |||
assert '!segwit' in tmpl['rules'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we also test for 'csv'
being present here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to merge this to not invalidate ACKs. Test improvements are welcome and can be submitted in a follow-up
@jameshilliard can you point me at the code that does that? The only getblocktemplate |
@jnewbery Well here's the workaround ck had to apply. |
ACK 412d5fe |
Thanks for the references, James. Tested ACK 412d5fe. |
This should be backported to v0.20. |
This this need a new rc? Maybe not for a two-line change? I suggest either creating a backport pr or bringing it up in the meeting, so that it is not forgotten. |
412d5fe QA: feature_segwit: Check that template "rules" includes "!segwit" as appropriate (Luke Dashjr) 2abe8cc Bugfix: Include "csv","!segwit" in "rules" (Luke Dashjr) Pull request description: bitcoin#16060 removed CSV & segwit from versionbits, breaking the "rules" key returned by GBT. Without this, miners don't know they're mining segwit blocks, and should fall back to pre-segwit block creation. ACKs for top commit: sipa: ACK 412d5fe jnewbery: Tested ACK 412d5fe. Tree-SHA512: 825d72e257dc0dd4941f2fe498d8d4f4f2a21b9505cd21a8f9eb7fb5d6d7dd9219347928cf90bb57a777920ce24295859763e64fa8a22ebb58fc2380f80f5615
They have been missing since buried deployments were merged Github-Pull: bitcoin#17946 Rebased-From: 2abe8cc
… appropriate Github-Pull: bitcoin#17946 Rebased-From : 412d5fe
412d5fe QA: feature_segwit: Check that template "rules" includes "!segwit" as appropriate (Luke Dashjr) 2abe8cc Bugfix: Include "csv","!segwit" in "rules" (Luke Dashjr) Pull request description: Original branch merges cleanly (no rebase needed) See also #17946 ACKs for top commit: jnewbery: utACK 412d5fe Tree-SHA512: 8b269f7782c10f02dc245cc377d91f594474eade6a32184a49fa2ed3928d91917e4b83eefee6947bfb5ffff54eca2781f8cf2169c1f0ad3fefca1d4b3cf304dd
be95147 Updated appveyor job to checkout a specific vcpkg commit ID. (Aaron Clauson) 1fd9cd2 appveyor: Remove clcache (MarcoFalke) 8c0a959 Remove cached directories and associated script blocks from appveyor CI configuration. (Aaron Clauson) d70f700 lint: fix shellcheck URL in CI install (fanquake) f8f7d91 test: remove Cirrus CI FreeBSD job (fanquake) b7e16a8 Add missing QPainterPath include (Andrew Chow) 30a2814 gui: Avoid Wallet::GetBalance in WalletModel::pollBalanceChanged (João Barbosa) 0d87a5b QA: feature_segwit: Check that template "rules" includes "!segwit" as appropriate (Luke Dashjr) bde6a5a Bugfix: Include "csv","!segwit" in "rules" (Luke Dashjr) e422f65 build: Set libevent minimum version to 2.0.21 (Hennadii Stepanov) 0d0dd6a Update with new Windows code signing certificate (Andrew Chow) Pull request description: Backports the following to the 0.19 branch: * #17946 - Fix GBT: Restore "!segwit" and "csv" to "rules" key * #18160 - gui: Avoid Wallet::GetBalance in WalletModel::pollBalanceChanged * #18425 - releases: Update with new Windows code signing certificate * #18676 - build: Check libevent minimum version in configure script * #19097 - qt: Add missing QPainterPath include (as per #19510) * #18640 - appveyor: Remove clcache * #19444 - test: Remove cached directories and associated script blocks from appveyor config * #19612 - lint: fix shellcheck URL in CI install * #18001 - Updated appveyor job to checkout a specific vcpkg commit ID Closes: #19510. ACKs for top commit: jnewbery: ACK be95147 MarcoFalke: cherry-pick ACK be95147 🌎 Tree-SHA512: 2ec7e3ae1da99799ff6f8cfe26095d6885cffe6952b18a7e236dc5e657b3918225c2601b8c8e17cdff5319c40cb0a214d9fad49b0ff2f54af1db7c81d83a1df5
#16060 removed CSV & segwit from versionbits, breaking the "rules" key returned by GBT.
Without this, miners don't know they're mining segwit blocks, and should fall back to pre-segwit block creation.