Page MenuHomePhabricator

remove CChainParams from wallet methods that don't need it
ClosedPublic

Authored by PiRK on Sep 23 2021, 12:02.

Details

Summary

While working on CWallet, I noticed that it has methods that take a CChainParams as an argument but never use it. I removed those arguments. There is no other change than removing such parameters from function definitions and call-sites.

Now, the only remaining mention of CChainParams in those files is mostly related to CWallet::GetChainParams, which forwards the chain parameters from CWallet::m_chain

This is a follow-up to D7041.

Test Plan

ninja all check-all

Diff Detail

Event Timeline

PiRK requested review of this revision.Sep 23 2021, 12:02

Tail of the build log:

-- Install configuration: "RelWithDebInfo"
-- Install component: "secp256k1"
-- Installing: /results/artifacts/lib/libsecp256k1.a
-- Installing: /results/artifacts/include/secp256k1.h
-- Installing: /results/artifacts/include/secp256k1_preallocated.h
-- Installing: /results/artifacts/include/secp256k1_recovery.h
-- Installing: /results/artifacts/include/secp256k1_schnorr.h
[342/509] Linking CXX static library src/libcommon.a
[343/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/mining.cpp.o
[344/509] Building CXX object src/CMakeFiles/server.dir/script/sigcache.cpp.o
[345/509] Linking CXX shared library src/libbitcoinconsensus.so.0.24.3
[346/509] Creating library symlink src/libbitcoinconsensus.so.0 src/libbitcoinconsensus.so
[347/509] Linking CXX executable src/bitcoin-cli
[348/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/net.cpp.o
[349/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/str.cpp.o
[350/509] Building CXX object src/CMakeFiles/server.dir/interfaces/node.cpp.o
[351/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/transaction_utils.cpp.o
[352/509] Building CXX object src/CMakeFiles/server.dir/avalanche/peermanager.cpp.o
[353/509] Linking CXX executable src/bitcoin-tx
[354/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/bdb.cpp.o
[355/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[356/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[357/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/context.cpp.o
[358/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[359/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[360/509] Building CXX object src/CMakeFiles/server.dir/avalanche/processor.cpp.o
[361/509] Building CXX object src/CMakeFiles/bitcoind.dir/bitcoind.cpp.o
[362/509] Building CXX object src/CMakeFiles/server.dir/rpc/misc.cpp.o
[363/509] Building CXX object src/CMakeFiles/bitcoin-wallet.dir/bitcoin-wallet.cpp.o
[364/509] Building CXX object src/CMakeFiles/server.dir/wallet/init.cpp.o
[365/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[366/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/wallet.cpp.o
[367/509] Building CXX object src/CMakeFiles/server.dir/rpc/avalanche.cpp.o
[368/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[369/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/bitcoin.cpp.o
[370/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[371/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/dns.cpp.o
[372/509] Building CXX object src/seeder/CMakeFiles/bitcoin-seeder.dir/main.cpp.o
[373/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[374/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/db.cpp.o
[375/509] Building CXX object src/wallet/CMakeFiles/wallet-tool.dir/wallettool.cpp.o
[376/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/setup_common.cpp.o
[377/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/salvage.cpp.o
[378/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/__/interfaces/wallet.cpp.o
[379/509] Building CXX object src/CMakeFiles/server.dir/net_processing.cpp.o
[380/509] Building CXX object src/CMakeFiles/server.dir/init.cpp.o
[381/509] Building CXX object src/CMakeFiles/server.dir/validation.cpp.o
[382/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[383/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcdump.cpp.o
[384/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
[385/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
FAILED: src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o 
/usr/bin/ccache /usr/bin/c++  -DBOOST_AC_USE_STD_ATOMIC -DBOOST_SP_USE_STD_ATOMIC -DBUILD_BITCOIN_INTERNAL -DENABLE_AVX2 -DENABLE_SHANI -DENABLE_SSE41 -DHAVE_BUILD_INFO -DHAVE_CONFIG_H -DHAVE_CONSENSUS_LIB -I../../src/. -Isrc -I../../src/univalue/include -Isrc/crypto/.. -I../../src/secp256k1/include -isystem /usr/include/jemalloc -Werror -g -O2 -fPIC -fvisibility=hidden   -fstack-reuse=none -fstack-protector-all -Wstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wformat -Wvla -Wcast-align -Wunused-parameter -Wmissing-braces -Wredundant-decls -Wsign-compare -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Wformat-security -Woverloaded-virtual -Wno-unused-parameter -Wno-implicit-fallthrough -pthread -std=gnu++17 -MD -MT src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o -MF src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o.d -o src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o -c ../../src/wallet/rpcwallet.cpp
../../src/wallet/rpcwallet.cpp: In function ‘UniValue loadwallet(const Config&, const JSONRPCRequest&)’:
../../src/wallet/rpcwallet.cpp:3124:25: error: unused variable ‘chainParams’ [-Werror=unused-variable]
     const CChainParams &chainParams = config.GetChainParams();
                         ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
ninja: build stopped: cannot make progress due to previous errors.
Build build-diff failed with exit code 1

Tail of the build log:

[342/509] Linking CXX static library src/libbitcoinconsensus.a
[343/509] Linking C executable src/secp256k1/ecmult-bench
[344/509] Building CXX object src/CMakeFiles/script.dir/script/signingprovider.cpp.o
[345/509] Linking C executable src/secp256k1/internal-bench
[346/509] Linking C executable src/secp256k1/sign-bench
[347/509] Linking C executable src/secp256k1/verify-bench
[348/509] Linking C executable src/secp256k1/recover-bench
[349/509] Installing component secp256k1
-- Install configuration: "Debug"
-- Install component: "secp256k1"
-- Installing: /results/artifacts/lib/libsecp256k1.a
-- Installing: /results/artifacts/include/secp256k1.h
-- Installing: /results/artifacts/include/secp256k1_preallocated.h
-- Installing: /results/artifacts/include/secp256k1_recovery.h
-- Installing: /results/artifacts/include/secp256k1_schnorr.h
[350/509] Building CXX object src/CMakeFiles/bitcoin-wallet.dir/bitcoin-wallet.cpp.o
[351/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/context.cpp.o
[352/509] Building CXX object src/CMakeFiles/script.dir/script/descriptor.cpp.o
[353/509] Linking CXX static library src/libscript.a
[354/509] Linking CXX static library src/libcommon.a
[355/509] Linking CXX shared library src/libbitcoinconsensus.so.0.24.3
[356/509] Creating library symlink src/libbitcoinconsensus.so.0 src/libbitcoinconsensus.so
[357/509] Linking CXX executable src/bitcoin-cli
[358/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/blockfilter.cpp.o
[359/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/transaction_utils.cpp.o
[360/509] Building CXX object src/CMakeFiles/bitcoin-tx.dir/bitcoin-tx.cpp.o
[361/509] Linking CXX executable src/bitcoin-tx
[362/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[363/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/net.cpp.o
[364/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/mining.cpp.o
[365/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[366/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/bdb.cpp.o
[367/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[368/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[369/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/wallet.cpp.o
[370/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/setup_common.cpp.o
[371/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/dns.cpp.o
[372/509] Building CXX object src/wallet/CMakeFiles/wallet-tool.dir/wallettool.cpp.o
[373/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/db.cpp.o
[374/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[375/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[376/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[377/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/__/interfaces/wallet.cpp.o
[378/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/bitcoin.cpp.o
[379/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/salvage.cpp.o
[380/509] Building CXX object src/seeder/CMakeFiles/bitcoin-seeder.dir/main.cpp.o
[381/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[382/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcdump.cpp.o
[383/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[384/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
FAILED: src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o 
/usr/bin/ccache /usr/bin/c++  -DABORT_ON_FAILED_ASSUME -DBOOST_AC_USE_STD_ATOMIC -DBOOST_SP_USE_STD_ATOMIC -DBUILD_BITCOIN_INTERNAL -DDEBUG -DDEBUG_LOCKORDER -DENABLE_AVX2 -DENABLE_SHANI -DENABLE_SSE41 -DHAVE_BUILD_INFO -DHAVE_CONFIG_H -DHAVE_CONSENSUS_LIB -I../../src/. -Isrc -I../../src/univalue/include -Isrc/crypto/.. -I../../src/secp256k1/include -isystem /usr/include/jemalloc -Werror -O0 -fPIC -fvisibility=hidden   -g3 -ftrapv -fstack-reuse=none -fstack-protector-all -Wstack-protector -U_FORTIFY_SOURCE -Wall -Wextra -Wformat -Wvla -Wcast-align -Wunused-parameter -Wmissing-braces -Wredundant-decls -Wsign-compare -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Wformat-security -Woverloaded-virtual -Wno-unused-parameter -Wno-implicit-fallthrough -pthread -std=gnu++17 -MD -MT src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o -MF src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o.d -o src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o -c ../../src/wallet/rpcwallet.cpp
../../src/wallet/rpcwallet.cpp: In function ‘UniValue loadwallet(const Config&, const JSONRPCRequest&)’:
../../src/wallet/rpcwallet.cpp:3124:25: error: unused variable ‘chainParams’ [-Werror=unused-variable]
     const CChainParams &chainParams = config.GetChainParams();
                         ^~~~~~~~~~~
cc1plus: all warnings being treated as errors
[385/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
ninja: build stopped: cannot make progress due to previous errors.
Build build-debug failed with exit code 1

Tail of the build log:

[334/509] Building CXX object src/CMakeFiles/util.dir/util/error.cpp.o
[335/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/str.cpp.o
[336/509] Building CXX object src/CMakeFiles/util.dir/util/message.cpp.o
[337/509] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/pubkey.cpp.o
[338/509] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/util/strencodings.cpp.o
[339/509] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/consensus/tx_check.cpp.o
[340/509] Building CXX object src/CMakeFiles/bitcoinconsensus.dir/primitives/transaction.cpp.o
[341/509] Building CXX object src/CMakeFiles/util.dir/util/settings.cpp.o
[342/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[343/509] Building CXX object src/CMakeFiles/bitcoin-tx.dir/bitcoin-tx.cpp.o
[344/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/context.cpp.o
[345/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/blockfilter.cpp.o
[346/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[347/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/transaction_utils.cpp.o
[348/509] Building CXX object src/CMakeFiles/util.dir/util/time.cpp.o
[349/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/mining.cpp.o
[350/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/net.cpp.o
[351/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[352/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/wallet.cpp.o
[353/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[354/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/bdb.cpp.o
[355/509] Building CXX object src/CMakeFiles/util.dir/util/system.cpp.o
[356/509] Linking CXX static library src/libutil.a
[357/509] Linking CXX static library src/librpcclient.a
[358/509] Linking CXX static library src/libbitcoinconsensus.a
[359/509] Linking CXX static library src/libscript.a
[360/509] Linking CXX static library src/libcommon.a
[361/509] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqabstractnotifier.cpp.o
[362/509] Linking CXX shared library src/libbitcoinconsensus.so.0.24.3
[363/509] Creating library symlink src/libbitcoinconsensus.so.0 src/libbitcoinconsensus.so
[364/509] Linking CXX executable src/bitcoin-cli
[365/509] Linking CXX executable src/bitcoin-tx
[366/509] Building CXX object src/wallet/CMakeFiles/wallet-tool.dir/wallettool.cpp.o
[367/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[368/509] Building CXX object src/test/CMakeFiles/testutil.dir/util/setup_common.cpp.o
[369/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/db.cpp.o
[370/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[371/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/dns.cpp.o
[372/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
FAILED: src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o 
/usr/bin/ccache /usr/bin/clang++  -DBOOST_AC_USE_STD_ATOMIC -DBOOST_SP_USE_STD_ATOMIC -DBUILD_BITCOIN_INTERNAL -DENABLE_AVX2 -DENABLE_SHANI -DENABLE_SSE41 -DHAVE_BUILD_INFO -DHAVE_CONFIG_H -DHAVE_CONSENSUS_LIB -I../../src/. -Isrc -I../../src/univalue/include -Isrc/crypto/.. -I../../src/secp256k1/include -isystem /usr/include/jemalloc -Werror -g -O2 -fPIC -fvisibility=hidden   -fstack-protector-all -Wstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wformat -Wgnu -Wvla -Wcast-align -Wunused-parameter -Wmissing-braces -Wthread-safety -Wrange-loop-analysis -Wredundant-decls -Wunreachable-code-loop-increment -Wsign-compare -Wconditional-uninitialized -Wformat-security -Wredundant-move -Woverloaded-virtual -Wshadow -Wshadow-field -Wno-unused-parameter -Wno-implicit-fallthrough -pthread -std=gnu++17 -MD -MT src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o -MF src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o.d -o src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o -c ../../src/wallet/rpcwallet.cpp
../../src/wallet/rpcwallet.cpp:3124:25: error: unused variable 'chainParams' [-Werror,-Wunused-variable]
    const CChainParams &chainParams = config.GetChainParams();
                        ^
1 error generated.
[373/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[374/509] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqnotificationinterface.cpp.o
[375/509] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqpublishnotifier.cpp.o
[376/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/salvage.cpp.o
[377/509] Building CXX object src/zmq/CMakeFiles/zmq.dir/zmqrpc.cpp.o
[378/509] Linking CXX static library src/zmq/libzmq.a
[379/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/__/interfaces/wallet.cpp.o
[380/509] Building CXX object src/seeder/CMakeFiles/bitcoin-seeder.dir/main.cpp.o
[381/509] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/bitcoin.cpp.o
[382/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[383/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[384/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcdump.cpp.o
[385/509] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang failed with exit code 1
PiRK planned changes to this revision.Sep 23 2021, 12:10
PiRK edited the summary of this revision. (Show Details)

CI failures

Fix compiler warning/error: unused variable ‘chainParams’ [-Werror=unused-variable]

deadalnix added a subscriber: deadalnix.

You very often have these build failures. Are you running your test plan?

This revision is now accepted and ready to land.Sep 24 2021, 14:42

You very often have these build failures. Are you running your test plan?

Yes. In this case I missed the compilation warning message, and my test plan didn't use -Werror: true