Page MenuHomePhabricator

rpc: Add generateblock to mine a custom set of transactions
ClosedPublic

Authored by Fabien on Nov 30 2020, 15:14.

Details

Summary
The existing block generation rpcs for regtest, generatetoaddress and
generatetodescriptor, mine everything in the mempool up to the block
weight limit. This makes it difficult to test a system for several
scenarios where a different set of transactions are mined. For example:

    Testing the common scenario where a transaction is replaced in the
mempool but the replaced transaction is mined instead.
    Testing for a double-spent transaction where a transaction that
conflicts with the mempool is mined.
    Testing for non-standard transactions that are mined.
    Testing the scenario where several blocks are mined without a
specific transaction in the mempool being included in a block.

This PR introduces a new rpc, generateblock, that takes an array of raw
transactions and txids and mines only those and the coinbase. Any txids
must be in the mempool, but the raw txs can be anything conforming to
consensus rules. The coinbase can be specified as either an address or
descriptor.

Backport of core PR17693.

The code has been adapted to remove the Segwit parts. For now the RPC
interface is kept identical to core, but it would be interesting to not
enforce CTOR in the call and sort the txs in the RPC code instead to
make it easier to mix raw txs and txids.

Test Plan
ninja check-functional

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Nov 30 2020, 15:15

Tail of the build log:

[319/490] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/hash.cpp.o
[320/490] Linking C executable src/secp256k1/verify-bench
[321/490] Linking C executable src/secp256k1/recover-bench
[322/490] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/uint256.cpp.o
[323/490] Building CXX object src/CMakeFiles/util.dir/util/error.cpp.o
[324/490] Building CXX object src/CMakeFiles/util.dir/util/settings.cpp.o
[325/490] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/primitives/transaction.cpp.o
[326/490] Building CXX object src/CMakeFiles/util.dir/util/message.cpp.o
[327/490] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/util/strencodings.cpp.o
[328/490] Building CXX object src/test/CMakeFiles/testutil.dir/util/str.cpp.o
[329/490] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/consensus/tx_check.cpp.o
[330/490] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/pubkey.cpp.o
[331/490] Building CXX object src/test/CMakeFiles/testutil.dir/util/transaction_utils.cpp.o
[332/490] Building CXX object src/CMakeFiles/bitcoin-tx.dir/bitcoin-tx.cpp.o
[333/490] Building CXX object src/test/CMakeFiles/testutil.dir/util/logging.cpp.o
[334/490] Building CXX object src/CMakeFiles/util.dir/util/time.cpp.o
[335/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[336/490] Building CXX object src/test/CMakeFiles/testutil.dir/util/blockfilter.cpp.o
[337/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[338/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[339/490] Building CXX object src/test/CMakeFiles/testutil.dir/util/mining.cpp.o
[340/490] Building CXX object src/test/CMakeFiles/testutil.dir/util/wallet.cpp.o
[341/490] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqabstractnotifier.cpp.o
[342/490] Building CXX object src/CMakeFiles/util.dir/util/system.cpp.o
[343/490] Linking CXX static library src/libutil.a
[344/490] Linking CXX static library src/libscript.a
[345/490] Linking CXX static library src/libcommon.a
[346/490] Linking CXX static library src/librpcclient.a
[347/490] Linking CXX executable src/bitcoin-cli
[348/490] Linking CXX static library src/libbitcoinconsensus.a
[349/490] Linking CXX shared library src/libbitcoinconsensus.so.0.22.8
[350/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[351/490] Creating library symlink src/libbitcoinconsensus.so.0 src/libbitcoinconsensus.so
[352/490] Building CXX object src/wallet/CMakeFiles/wallet-tool.dir/wallettool.cpp.o
[353/490] Linking CXX executable src/bitcoin-tx
[354/490] Building CXX object src/test/CMakeFiles/testutil.dir/util/setup_common.cpp.o
[355/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[356/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[357/490] Building CXX object src/seeder/CMakeFiles/seeder.dir/dns.cpp.o
[358/490] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqnotificationinterface.cpp.o
[359/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[360/490] Building CXX object src/seeder/CMakeFiles/seeder.dir/bitcoin.cpp.o
[361/490] Building CXX object src/seeder/CMakeFiles/seeder.dir/db.cpp.o
[362/490] Linking CXX static library src/seeder/libseeder.a
[363/490] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqpublishnotifier.cpp.o
[364/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/__/interfaces/wallet.cpp.o
[365/490] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqrpc.cpp.o
[366/490] Linking CXX static library src/zmq/libzmq.a
[367/490] Building CXX object src/seeder/CMakeFiles/bitcoin-seeder.dir/main.cpp.o
[368/490] Linking CXX executable src/seeder/bitcoin-seeder
[369/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[370/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[371/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcdump.cpp.o
[372/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
[373/490] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
[374/490] Linking CXX static library src/wallet/libwallet.a
[375/490] Linking CXX static library src/wallet/libwallet-tool.a
[376/490] Linking CXX executable src/bitcoin-wallet
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang-tidy failed with exit code 1
Fabien planned changes to this revision.Nov 30 2020, 15:47

Tail of the build log:

[360/418] Running utility command for check-bitcoin-wallet_crypto_tests
[361/418] Running utility command for check-bitcoin-sync_tests
[362/418] bitcoin: testing torcontrol_tests
[363/418] Running utility command for check-bitcoin-torcontrol_tests
[364/418] bitcoin: testing settings_tests
[365/418] bitcoin: testing timedata_tests
[366/418] bitcoin: testing streams_tests
[367/418] Running utility command for check-bitcoin-settings_tests
[368/418] bitcoin: testing undo_tests
[369/418] Running utility command for check-bitcoin-timedata_tests
[370/418] Running utility command for check-bitcoin-streams_tests
[371/418] Running utility command for check-bitcoin-undo_tests
[372/418] bitcoin: testing util_threadnames_tests
[373/418] bitcoin: testing validation_chainstatemanager_tests
[374/418] Running utility command for check-bitcoin-util_threadnames_tests
[375/418] bitcoin: testing compilerbug_tests
[376/418] Running utility command for check-bitcoin-compilerbug_tests
[377/418] Running utility command for check-bitcoin-validation_chainstatemanager_tests
[378/418] bitcoin: testing txvalidationcache_tests
[379/418] Running utility command for check-bitcoin-txvalidationcache_tests
[380/418] bitcoin: testing checkpoints_tests
[381/418] bitcoin: testing validationinterface_tests
[382/418] Running utility command for check-bitcoin-checkpoints_tests
[383/418] Running utility command for check-bitcoin-validationinterface_tests
[384/418] bitcoin: testing cashaddr_tests
[385/418] Running utility command for check-bitcoin-cashaddr_tests
[386/418] bitcoin: testing radix_tests
[387/418] Running utility command for check-bitcoin-radix_tests
[388/418] bitcoin: testing blockcheck_tests
[389/418] bitcoin: testing getarg_tests
[390/418] Running utility command for check-bitcoin-blockcheck_tests
[391/418] Running utility command for check-bitcoin-getarg_tests
[392/418] bitcoin: testing crypto_tests
[393/418] bitcoin: testing ref_tests
[394/418] Running utility command for check-bitcoin-crypto_tests
[395/418] Running utility command for check-bitcoin-ref_tests
[396/418] bitcoin: testing cuckoocache_tests
[397/418] Running utility command for check-bitcoin-cuckoocache_tests
[398/418] bitcoin: testing script_tests
[399/418] Running utility command for check-bitcoin-script_tests
[400/418] bitcoin: testing validation_tests
[401/418] Running utility command for check-bitcoin-validation_tests
[402/418] bitcoin: testing monolith_opcodes_tests
[403/418] Running utility command for check-bitcoin-monolith_opcodes_tests
[404/418] bitcoin: testing skiplist_tests
[405/418] Running utility command for check-bitcoin-skiplist_tests
[406/418] bitcoin: testing coinselector_tests
[407/418] Running utility command for check-bitcoin-coinselector_tests
[408/418] bitcoin: testing util_tests
[409/418] Running utility command for check-bitcoin-util_tests
[410/418] bitcoin: testing op_reversebytes_tests
[411/418] Running utility command for check-bitcoin-op_reversebytes_tests
[412/418] bitcoin: testing transaction_tests
[413/418] Running utility command for check-bitcoin-transaction_tests
[414/418] bitcoin: testing coins_tests
[415/418] Running utility command for check-bitcoin-coins_tests
[416/418] Running bitcoin test suite
PASSED: bitcoin test suite
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang-tidy failed with exit code 1
This revision is now accepted and ready to land.Dec 1 2020, 15:15
This revision was landed with ongoing or failed builds.Dec 1 2020, 15:29
This revision was automatically updated to reflect the committed changes.