Maybe helps review: https://github.com/jtimon/bitcoin/compare/0.13-new-testchain...jtimon:0.13-blocksign from #8994.
Once we allow users to create their own chains with #8994 and customize chain params viacommand line and/or a separate file (discuss there), this PR adds additional options and chainparams -con_fsignblockchain and -con_signblockscript to optionally replace pow with bitcoin scripts if -con_fsignblockchain=1; -con_signblockscript being the scriptPubKey the block producers need to provide a scriptSig for with each block (instead of prociding a nonce that passes the pow in the block hash like regular miners).
This will help spring testchains that are more reliable and controllable by developers testing new features. Among other people, folks from the lightning community have communicated that testnet3 is not ideal for some testing scenarios.
Note that also travis tests pass, the new functionality is only tested in test/signedblocks_tests.cpp Apart from that, BasicSignBlock is dependent on some other tests because the following doesn’t pass:
0./src/test/test_bitcoin --run_test=BasicSignBlock
It is good that it fails because testing manually with importprivkey cTVbLcfg8ftQ25j1YSysmTVugBVEuZymbKUqjHaiCmg2ZSWNmccU
and -con_signblockscript != 21026f9ee99573cf566726ab891ad7dd7ffd36cae816efe71a93bd81f71c3abd04d6ac[CScript() << ParseHex("cTVbLcfg8ftQ25j1YSysmTVugBVEuZymbKUqjHaiCmg2ZSWNmccU") << OP_CHECKSIG] doesn't work either.
I hope I will eventually figure it out with
gdb –args ./src/test/test_bitcoin –run_test=BasicSignBlock``` but if someone else is faster than me, thanks in advance.
Ideally, we would also reuse all the rpc tests for testing this mode with an additional option similar to -extended. First we need #8994 to reuse (or replace, please discuss there) all the rpc test for regtest with the new custom chain which by default is identical to regtest, only with a different genesis block and .bitcoin directory. Currently all of them are converted from regtest to custom except :
- p2p-comapctblocks.py
- segwit.py
- mempool_packages.py (extended)
- pruning.py (extended)
(help here welcomed too) Reusing all tests is not strictly necessary but would be nice.
Dependencies:
- Use a proper factory for creating chainparams #8855
- Really don’t validate genesis block #9102
- Testchains: Introduce custom chain whose constructor… #8994
Open design concerns:
- Global fSignBlocksGlobal is worrying
- Global UnionProof is worrying
You can also see https://github.com/jtimon/bitcoin/compare/0.13-blocksign...0.13-blocksign-longest for other things I’m trying or considering.