Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix GBT: Restore "!segwit" and "csv" to "rules" key #17946
jnewbery left a comment
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.