-
Notifications
You must be signed in to change notification settings - Fork 388
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
[0.17] Mandatory coinbase feature #430
[0.17] Mandatory coinbase feature #430
Conversation
9897b5e
to
5d77f54
Compare
a5536b4
to
22396a7
Compare
src/init.cpp
Outdated
@@ -514,6 +514,7 @@ void SetupServerArgs() | |||
gArgs.AddArg("-rpcuser=<user>", "Username for JSON-RPC connections", false, OptionsCategory::RPC); | |||
gArgs.AddArg("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), true, OptionsCategory::RPC); | |||
gArgs.AddArg("-server", "Accept command line and JSON-RPC commands", false, OptionsCategory::RPC); | |||
gArgs.AddArg("-con_mandatorycoinbase", "All non-zero valued coinbase outputs must go to this scriptPubKey, if set.", false, OptionsCategory::RPC); |
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 be OptionsCategory::CHAINPARAMS
.
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.
Agreed, and it should be in chainparamsbase.cpp
src/chainparams.cpp
Outdated
@@ -322,6 +334,9 @@ class CRegTestParams : public CChainParams { | |||
assert(consensus.hashGenesisBlock == uint256S("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")); | |||
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); | |||
|
|||
// All non-zero coinbase outputs must go to this scriptPubKey | |||
consensus.mandatory_coinbase_destination = StrHexToScriptWithDefault(gArgs.GetArg("-con_mandatorycoinbase", ""), CScript()); // Blank script allows any coinbase destination |
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.
Why not just
consensus.mandatory_coinbase_destination = StrHexToScriptWithDefault(gArgs.GetArg("-con_mandatorycoinbase", ""), CScript()); // Blank script allows any coinbase destination | |
// Blank script allows any coinbase destination | |
consensus.mandatory_coinbase_destination = ParseHex(args.GetArg("-con_mandatorycoinbase", "")); |
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.
Does it implicitly convert it? It's a script, not a series of bytes.
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.
It seems to be working on f0391db#diff-64cbe1ad5465e13bc59ee8bb6f3de2e7R431
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.
Hm ok in that case we don't need StrHexToScriptWithDefault at all, though I'll make the conversion explicit.
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.
Oh right C++: It can implicitly use constructor.
@@ -11,6 +11,8 @@ | |||
#include <map> | |||
#include <string> | |||
|
|||
#include <script/script.h> // mandatory_coinbase_destination |
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.
Isn't this dependency giving you problems? I would swear I tried the same with #433
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.
hopefully not, we do the same thing for elements-0.14.1 IIRC!
22396a7
to
0d52731
Compare
Hmm, the test doesn't seem to be working here:
|
hmm it appears my refactoring broke something. |
oh, I only applied the argument to regtest, tip is using "regtest2" custom chain. We should be removing regtest at some point, right @jtimon ? I'll move it to custom chain params now. |
0d52731
to
29f601e
Compare
Turns out me being explicit with construction means I was doing it the wrong way, the implicit way automagically was correct. |
29f601e
to
0d20b55
Compare
tACK 0d20b55 |
@@ -1850,6 +1850,17 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl | |||
|
|||
nBlocksTotal++; | |||
|
|||
// Check that all non-zero coinbase outputs pay to the required destination | |||
const CScript& mandatory_coinbase_destination = chainparams.GetConsensus().mandatory_coinbase_destination; |
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.
Is this local variable worth it? small nit, feel free to ignore.
We can remove regtest, testnet and main when we can no longer support them for real, I guess. Didn't look with much attention to the test, but the code looks good. utACK 0d20b55 |
0d20b55 add mandatory coinbase functional test (Gregory Sanders) edb0532 add consensus.mandatory_coinbase_destination (Gregory Sanders) Pull request description: Includes functional test Tree-SHA512: e7fdf4584c5a61516778dff272c0f4c9964fee515b705c4fd3ade842954bcc7426bdaf5273a64e4b2472fedc940ead7552c0ec80b4608aac381f91a8f2356d95
sigh, I didn't add the test to the test list... will fix |
Includes functional test