-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Don't require segwit in getblocktemplate for segwit signalling or mining #9955
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
Don't require segwit in getblocktemplate for segwit signalling or mining #9955
Conversation
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.
Concept ACK.
qa/rpc-tests/segwit.py
Outdated
#assert_raises_jsonrpc(-8, "Support for 'segwit' rule requires explicit client support", self.nodes[0].getblocktemplate, {}) | ||
tmpl = self.nodes[0].getblocktemplate() | ||
# TODO: add a transaction with witness to mempool, and verify it's not | ||
# selected for mining. |
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.
Should test that witness tx can't sneak in as an ancestor of non-witness, too.
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.
I concur.
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.
Done in 7db565c
src/rpc/mining.cpp
Outdated
@@ -683,7 +689,6 @@ UniValue getblocktemplate(const JSONRPCRequest& request) | |||
result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); | |||
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); | |||
|
|||
const struct BIP9DeploymentInfo& segwit_info = VersionBitsDeploymentInfo[Consensus::DEPLOYMENT_SEGWIT]; | |||
if (!pblocktemplate->vchCoinbaseCommitment.empty() && setClientRules.find(segwit_info.name) != setClientRules.end()) { |
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.
Use fMineWitnessTransactions
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.
Addressed in 24428bd.
src/rpc/mining.cpp
Outdated
@@ -533,7 +539,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request) | |||
|
|||
// Create new block | |||
CScript scriptDummy = CScript() << OP_TRUE; | |||
pblocktemplate = BlockAssembler(Params()).CreateNewBlock(scriptDummy); | |||
pblocktemplate = BlockAssembler(Params()).CreateNewBlock(scriptDummy, fMineWitnessTransactions); |
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.
This is cached across calls, so it requires a bit more complexity.
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.
I think I fixed this in 24428bd.
Maybe transactions with a witness should not get inserted into the mempool? |
@JeremyRubin Sure, and miners could also continue to use 0.13.0 or older for (If we wanted to make CNB fast in this configuration, then I think the easiest thing to do would be to say add an |
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.
utACK (might be better to have two caches, but I doubt it matters)
Concept ACK |
Added a test to |
7db565c
to
a4a20d8
Compare
Rebased (conflict was in |
utACK a4a20d8a8de77b45e33cbdb8018dc30c9176fccd |
ACK. Had to go refresh myself on the proper meaning of the "!' prefix. Perhaps the documentation (e.g. BIPs) should be updated to give that a name, "Mandatory prefix". BIP 145 also needs a clear and direct call out to the extensions established in BIP9, not after it's already using them. Otherwise it's easily confusing. :) |
Merge conflict in segwit.py after #9970 |
Segwit's version bit will be signalled for all invocations of CreateNewBlock, and not specifying segwit only will cause CreateNewBlock to skip transactions with witness from being selected.
a4a20d8
to
c85ffe6
Compare
Rebased. |
…alling or mining c85ffe6 Test transaction selection when gbt called without segwit support (Suhas Daftuar) abe7b3d Don't require segwit in getblocktemplate for segwit signalling or mining (Suhas Daftuar) Tree-SHA512: 172496b6d7cdf1879de1266748f2b4ed9fd2ba9ff4a1fd964d74d73c674c16d74bf01a3ba42bf25f2d69f348217c0bbf3412ac64821f222efc9de25a287a5240
Segwit's version bit will be signalled for all invocations of CreateNewBlock, and not specifying segwit only will cause CreateNewBlock to skip transactions with witness from being selected. Github-Pull: bitcoin#9955 Rebased-From: abe7b3d
Github-Pull: bitcoin#9955 Rebased-From: c85ffe6
Segwit's version bit will be signalled for all invocations of CreateNewBlock,
and not specifying segwit only will cause CreateNewBlock to skip transactions
with witness from being selected. (Note that CreateNewBlock's performance may suffer if the mempool has witness transactions that are being skipped, so this is not a recommended configuration.)
Originally we didn't signal segwit unless the getblocktemplate caller explicitly indicated support, in order to prevent segwit from activating before any miners actually had support for the witness commitment. Now that many blocks are signalling segwit already, this is not a material concern.
Also, I need to figure out how to add a test to segwit.py to check that witness transactions would in fact be skipped.
As per IRC discussion, I think we should consider this for backport to the 0.14 branch.