-
Notifications
You must be signed in to change notification settings - Fork 389
[0.17] Add initialfreecoins option, default of 0 #467
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] Add initialfreecoins option, default of 0 #467
Conversation
Relevant section: 7fc252d#diff-64cbe1ad5465e13bc59ee8bb6f3de2e7R516 |
@dongcarl this being worked on? |
@instagibbs Yes. I remember this one needs to be rebased on some other changes (maybe issuance consensus/policy?) before it can be fleshed out. |
@@ -435,6 +435,7 @@ class CCustomParams : public CRegTestParams { | |||
// All non-zero coinbase outputs must go to this scriptPubKey | |||
std::vector<unsigned char> man_bytes = ParseHex(gArgs.GetArg("-con_mandatorycoinbase", "")); | |||
consensus.mandatory_coinbase_destination = CScript(man_bytes.begin(), man_bytes.end()); // Blank script allows any coinbase destination | |||
initialFreeCoins = gArgs.GetArg("-initialfreecoins", 0); |
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 DEFAULT_INITIAL_FREE_COINS
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.
Would cause circular dependencies... Just used 0
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.
well that constant doesn't appear to be used then
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.
@instagibbs It would seem from surrounding code that the convention is to just specify instead of making a new constant. So I've removed it.
7a5916a
to
d526b73
Compare
Seems like |
@dongcarl it's failing the "bitcoind tests" run specifically. Try running it locally using |
So this is probably because this PR breaks the ability to make and run "vanilla regtest" blockchain, breaking the See: #436 I think it makes sense to do a minimal version of that PR, supporting Bitcoin-compatible genesis block generation, as well as elements/liquid-compatible. |
Ok, we "broke" bitcoin regtest block previously to adding the new tests, so I'd suggest you take this, generate the new json block data in the This would let us have bitcoin-compatible style blocks for regtest under custom chains, and allow adding more options over time. |
I guess the pegin PR will rebase once this one lands. So I'll add |
otherwise this is looking good! |
unmarked as WIP |
nit: Could you just squash the commits to make all commits past the test? |
|
||
# Issuance transaction is an OP_TRUE, so will be available to second node | ||
assert_raises_rpc_error(-5, "No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.", self.nodes[0].getrawtransaction, issuance_tx) | ||
self.nodes[1].getrawtransaction(issuance_tx) |
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.
Please add a test showing that listunspent
has a single(only one!) output worth the amount you set in the conf line: 5000000000
:
e.g.,
[ <--- assert there's only one result
{
"txid": "b22b529c27b20746d5fb658d6e53d9c839304b51a98ebcfae6a4b77bbbdeb9cf",
"vout": 0, <--- assert it is the first
"scriptPubKey": "51", <---- assert it's an op_true
"amount": 21000000.00000000, <--- assert the value
"confirmations": 1, <---- assert it's at the right confirmation level for genesis
"spendable": true,
"solvable": true,
"safe": true
}
]
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 would require anyonecanspendaremine=1
correct? Should I add that flag just for this test or shall we make this the default at least for the non-bitcoin functional tests?
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, I'd set it just for this test.
light tACK, just add those quick test conditions to make sure the output looks like something you expect |
6f4ca6e
to
9b0632b
Compare
@instagibbs Tests added, let me know if there are other things! |
re-ACK 9b0632b |
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.
1 piece of confusion and some nits..
src/chainparams.cpp
Outdated
// Safer for users if they load incorrect parameters via arguments. | ||
static std::vector<unsigned char> CommitToArguments(const Consensus::Params& params, const std::string& networkID) | ||
{ | ||
CSHA256 sha2; |
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.
2-spaces indentation, really? :D
src/chainparams.cpp
Outdated
std::vector<unsigned char> commit = CommitToArguments(consensus, strNetworkID); | ||
genesis = CreateGenesisBlock(CScript(commit), CScript(OP_RETURN), 1296688602, 2, 0x207fffff, 1, 0); | ||
if (initialFreeCoins != 0) { | ||
AppendInitialIssuance(genesis, COutPoint(uint256(commit), 0), initialFreeCoins, CScript() << OP_TRUE); |
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.
Another indentation nit..
@@ -1,117 +1,117 @@ | |||
{ | |||
"blocks": [ | |||
"010000000000000000000000000000000000000000000000000000000000000000000000bdb84e02590a29888f409285dfe25361bbd5560efa5a2dd6996c53488bf37e8edae5494dffff7f20020000000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1004ffff001d0104087265677465737432ffffffff0100f2052a01000000015100000000", |
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 it be possible to have this be compatible with bitcoin? With the genesis style and 0 initialfreecoins?
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.
good catch, yes with these commits they should match again
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.
Well technically no, it's "regtest2" network, which gets mixed into the block definition. The network main
still should work though. We don't really have tests for that per se, aside from assertions in the chainparams such as:
assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
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.
Not sure what the conclusion is here, does this need to be addressed?
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 don't think this is a blocker unless this mutation is incorrect behavior based on the rpc_blockstats test...
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 also don't get it. What exactly changed to the regtest genesis block?
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.
Can't we skip CommitToArguments
if the genesis-style is bitcoin?
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.
The test doesn't specify genesis style of bitcoin(though it maybe should).
9b0632b
to
31d82a5
Compare
needs rebase |
and please add a description :) |
- Add CommitToArgument without fedpegScript or signblockscript - Modify CreateGenesisBlock to take in the genesis scriptSig - Add AppendInitialIssuace without assets support - AppendInitialIssuance to genesis block for Custom chain only - Add -initialfreecoins option - Modify tests to work with initialfreecoins
- also regenerate test data for getblockstats
31d82a5
to
95432aa
Compare
@instagibbs Description added. |
utACK 95432aa |
95432aa Test listunspent sanity when specifying initialfreecoins (Carl Dong) 1ac14fc restore bitcoin regtest gen block using -genesis_style (Gregory Sanders) 8b8c11a Add initialfreecoins option, default of 0 (Carl Dong) Pull request description: This PR adds a `-initialfreecoins` debug option, and a `-con_genesis_style` to go along with it. This allows us to correctly set the amount of coins created in the genesis block, either in the `elements` style or `bitcoin` style. Tests have been modified to test that the correct amount of coins are created. Tree-SHA512: d3c56e7109e8e6496b6e5b819dc09f3ebf82013882854cc76062a39e4399e7eeb5789b567be527133278c1646a2765d02a09bd2d9618bdaeec5a852042e40c2b
post-merge ACK 95432aa :) was trying something out regarding the bitcoin_functional tests |
This PR adds a
-initialfreecoins
debug option, and a-con_genesis_style
to go along with it.This allows us to correctly set the amount of coins created in the genesis block, either in the
elements
style orbitcoin
style.Tests have been modified to test that the correct amount of coins are created.