Page MenuHomePhabricator

refactor, txdb: Add CoinsViewOptions struct
ClosedPublic

Authored by PiRK on May 2 2024, 08:56.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC788e09ea04bf: refactor, txdb: Add CoinsViewOptions struct
Summary

PR rationale:

Code in the libbitcoin_kernel library should not be calling ArgsManager methods or trying to read options from the command line. Instead it should just get options values from simple structs and function arguments that are passed in externally. This PR removes gArgs accesses from dbwrapper and txdb modules by defining appropriate options structs.

Add CoinsViewOptions struct to remove ArgsManager uses from txdb.

To reduce size of this commit, this moves references to gArgs variable out of
txdb.cpp to calling code in validation.cpp. But these moves are temporary. The
gArgs references in validation.cpp are moved out to calling code in init.cpp in
later commits.

This commit does not change behavior.

This is a partial backport of core#25862
https://github.com/bitcoin/bitcoin/pull/25862/commits/c00fa1a7341d3f47f992e0beb043da655cbca777

Depends on D16091

Test Plan

with bitcoin-chainstate compilation enabled:
ninja all check-all

Event Timeline

PiRK requested review of this revision.May 2 2024, 08:56

Tail of the build log:

: && /usr/bin/c++ -Werror -g -O2 -fuse-ld=gold -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lstdc++fs -fPIE -pie src/CMakeFiles/bitcoin-chainstate.dir/bitcoin-chainstate.cpp.o -o src/bitcoin-chainstate  /usr/lib/x86_64-linux-gnu/libjemalloc_pic.a  -lstdc++fs  src/libbitcoinkernel.a  src/crypto/libcrypto.a  src/crypto/libcrypto_sse4.1.a  src/crypto/libcrypto_avx2.a  src/crypto/libcrypto_shani.a  src/univalue/libunivalue.a  src/secp256k1/libsecp256k1.a  src/leveldb/libleveldb.a  src/leveldb/libleveldb-sse4.2.a  src/leveldb/libmemenv.a  /usr/lib/x86_64-linux-gnu/libjemalloc_pic.a  -lm  -pthread  -ldl  -lstdc++fs && :
../../src/txdb.cpp:195: error: undefined reference to 'node::ReadDatabaseArgs(ArgsManager const&, DBOptions&)'
../../src/validation.cpp:1152: error: undefined reference to 'node::ReadCoinsViewArgs(ArgsManager const&, CoinsViewOptions&)'
../../src/validation.cpp:1147: error: undefined reference to 'node::ReadDatabaseArgs(ArgsManager const&, DBOptions&)'
../../src/index/base.cpp:46: error: undefined reference to 'node::ReadDatabaseArgs(ArgsManager const&, DBOptions&)'
collect2: error: ld returned 1 exit status
[572/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/bench_bitcoin.cpp.o
[573/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/chacha20.cpp.o
[574/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/chacha_poly_aead.cpp.o
[575/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/bitcoingui.cpp.o
[576/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/ccoins_caching.cpp.o
[577/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/intro.cpp.o
[578/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/bitcoin.cpp.o
[579/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/crypto_hash.cpp.o
[580/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/examples.cpp.o
[581/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/block_assemble.cpp.o
[582/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/hashpadding.cpp.o
[583/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/checkqueue.cpp.o
[584/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/optionsdialog.cpp.o
[585/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/lockedpool.cpp.o
[586/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/data.cpp.o
[587/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/gcs_filter.cpp.o
[588/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/guiutil.cpp.o
[589/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/checkblock.cpp.o
[590/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/merkle_root.cpp.o
[591/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/crypto_aes.cpp.o
[592/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/poly1305.cpp.o
[593/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/rollingbloom.cpp.o
[594/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/bench.cpp.o
[595/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/util_time.cpp.o
[596/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/prevector.cpp.o
[597/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/duplicate_inputs.cpp.o
[598/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/chained_tx.cpp.o
[599/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/load_external.cpp.o
[600/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/verify_script.cpp.o
[601/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/mempool_eviction.cpp.o
[602/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/platformstyle.cpp.o
[603/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qvalidatedlineedit.cpp.o
[604/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qvaluecombobox.cpp.o
[605/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/peer_eviction.cpp.o
[606/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/rpc_mempool.cpp.o
[607/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qrc_bitcoin.cpp.o
[608/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/mempool_stress.cpp.o
[609/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/rpc_blockchain.cpp.o
[610/624] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/nanobench.cpp.o
[611/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/utilitydialog.cpp.o
[612/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/trafficgraphwidget.cpp.o
[613/624] Linking CXX executable src/bench/bitcoin-bench
[614/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/optionsmodel.cpp.o
[615/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qrc_bitcoin_locale.cpp.o
[616/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/splashscreen.cpp.o
[617/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/peertablemodel.cpp.o
[618/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/rpcconsole.cpp.o
[619/624] Linking CXX static library src/qt/libbitcoin-qt-base.a
[620/624] Automatic MOC for target bitcoin-qt
[621/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt.dir/bitcoin-qt_autogen/mocs_compilation.cpp.o
[622/624] Building CXX object src/qt/CMakeFiles/bitcoin-qt.dir/main.cpp.o
[623/624] Linking CXX executable src/qt/bitcoin-qt
ninja: build stopped: cannot make progress due to previous errors.
Build build-without-wallet failed with exit code 1
PiRK planned changes to this revision.May 2 2024, 09:16

Failed tests logs:

====== Bitcoin ABC functional tests: interface_rest.py ======

------- Stdout: -------
2024-05-02T09:14:24.903000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240502_090927/interface_rest_64
2024-05-02T09:14:25.518000Z TestFramework (INFO): Mine blocks and send Bitcoin Cash to node 1
2024-05-02T09:15:28.095000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 147, in main
    self._run_test_internal()
  File "/work/test/functional/test_framework/test_framework.py", line 137, in _run_test_internal
    self.run_test()
  File "/work/test/functional/interface_rest.py", line 98, in run_test
    self.sync_all()
  File "/work/test/functional/test_framework/test_framework.py", line 820, in sync_all
    self.sync_mempools(nodes)
  File "/work/test/functional/test_framework/test_framework.py", line 792, in sync_mempools
    raise AssertionError(f"Mempool sync timed out after {timeout}s:{pool_str}")
AssertionError: Mempool sync timed out after 60s:
  {'216448ceeb3fba8232fc3a3702587ca3cf2c76af77ff4ab75cab115259164344'}
  set()
2024-05-02T09:15:28.146000Z TestFramework (INFO): Stopping nodes
2024-05-02T09:15:28.248000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240502_090927/interface_rest_64
2024-05-02T09:15:28.248000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240502_090927/interface_rest_64/test_framework.log
2024-05-02T09:15:28.248000Z TestFramework (ERROR): 
2024-05-02T09:15:28.249000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_  _20240502_090927/interface_rest_64' to consolidate all logs
2024-05-02T09:15:28.249000Z TestFramework (ERROR): 
2024-05-02T09:15:28.249000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2024-05-02T09:15:28.249000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2024-05-02T09:15:28.249000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: interface_rest.py

PiRK edited the test plan for this revision. (Show Details)

rebase

This revision is now accepted and ready to land.May 2 2024, 19:36
This revision was automatically updated to reflect the committed changes.