Page MenuHomePhabricator

refactor, dbwrapper: Add DBParams and DBOptions structs
ClosedPublic

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

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC74a272dafa08: refactor, dbwrapper: Add DBParams and DBOptions structs
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 DBParams and DBOptions structs to remove ArgsManager uses from dbwrapper.

To reduce size of this commit, this moves references to gArgs variable out of
dbwrapper.cpp to calling code in txdb.cpp. But these moves are temporary. The
gArgs references in txdb.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/2eaeded37f3a07c35eef38d9a80c1e5fbd4d41ee

Depends on D16099

Test Plan

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

Diff Detail

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

Event Timeline

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

Tail of the build log:

[572/623] Linking CXX executable src/bitcoin-chainstate
FAILED: src/bitcoin-chainstate 
: && /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:109: error: undefined reference to 'node::ReadDatabaseArgs(ArgsManager const&, DBOptions&)'
../../src/txdb.cpp:88: error: undefined reference to 'node::ReadDatabaseArgs(ArgsManager const&, DBOptions&)'
../../src/txdb.cpp:218: 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
[573/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/chacha20.cpp.o
[574/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/chacha_poly_aead.cpp.o
[575/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/bitcoingui.cpp.o
[576/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/ccoins_caching.cpp.o
[577/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/crypto_hash.cpp.o
[578/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/bitcoin.cpp.o
[579/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/block_assemble.cpp.o
[580/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/examples.cpp.o
[581/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/guiutil.cpp.o
[582/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/lockedpool.cpp.o
[583/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/hashpadding.cpp.o
[584/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/checkqueue.cpp.o
[585/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/optionsdialog.cpp.o
[586/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/data.cpp.o
[587/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/gcs_filter.cpp.o
[588/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/poly1305.cpp.o
[589/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/merkle_root.cpp.o
[590/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/crypto_aes.cpp.o
[591/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/checkblock.cpp.o
[592/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/rollingbloom.cpp.o
[593/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/prevector.cpp.o
[594/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/util_time.cpp.o
[595/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/duplicate_inputs.cpp.o
[596/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/chained_tx.cpp.o
[597/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/bench.cpp.o
[598/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/load_external.cpp.o
[599/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/mempool_eviction.cpp.o
[600/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/verify_script.cpp.o
[601/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/platformstyle.cpp.o
[602/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qvalidatedlineedit.cpp.o
[603/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/peer_eviction.cpp.o
[604/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qvaluecombobox.cpp.o
[605/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qrc_bitcoin.cpp.o
[606/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/rpc_mempool.cpp.o
[607/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/mempool_stress.cpp.o
[608/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/nanobench.cpp.o
[609/623] Building CXX object src/bench/CMakeFiles/bitcoin-bench.dir/rpc_blockchain.cpp.o
[610/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/utilitydialog.cpp.o
[611/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/trafficgraphwidget.cpp.o
[612/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/optionsmodel.cpp.o
[613/623] Linking CXX executable src/bench/bitcoin-bench
[614/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/splashscreen.cpp.o
[615/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/peertablemodel.cpp.o
[616/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/qrc_bitcoin_locale.cpp.o
[617/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt-base.dir/rpcconsole.cpp.o
[618/623] Linking CXX static library src/qt/libbitcoin-qt-base.a
[619/623] Automatic MOC for target bitcoin-qt
[620/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt.dir/bitcoin-qt_autogen/mocs_compilation.cpp.o
[621/623] Building CXX object src/qt/CMakeFiles/bitcoin-qt.dir/main.cpp.o
[622/623] 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:11

we need database_args.cpp also for bitcoin-chainstate

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

rebase on D16099

This revision is now accepted and ready to land.May 2 2024, 19:31