Page MenuHomePhabricator

[electrum] deglobalize config
ClosedPublic

Authored by PiRK on Oct 10 2025, 10:09.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCc2be42b738b3: [electrum] deglobalize config
Summary

Now the config object is create in the main script and passed down via the Daemon to all the various components that need it.

The previous way of setting a singleton instance of the config consisted of overwriting the previous global config with a new one, but it didn't really enforce anything and just added even more inconsistency. Some functions used the config object created at application launch time passed down via the function params, other functions accessed the global config via get_config which could be the same as the one created initially or a new one instantiated later.

Right now in GUI mode everything uses the same config, the one created at the application start. In daemon mode, each RPC command still causes a new config to be instantiated and used for this one command. In practice this new config shares some configuration with the existing one (everything that is read from the disk file in which config is commited), and differs via the command line args passed to the client calling the RPC.

Depends on D18780

Test Plan

python test_runner.py

Run the application, try various features that rely on configuration state (change configuration options and check it is persisted after restart)

Diff Detail

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

Event Timeline

PiRK requested review of this revision.Oct 10 2025, 10:09

Tail of the build log:

[274/333] Building CXX object src/CMakeFiles/server.dir/rpc/server_util.cpp.o
[275/333] Building CXX object src/CMakeFiles/server.dir/rest.cpp.o
[276/333] Building CXX object src/CMakeFiles/server.dir/script/scriptcache.cpp.o
[277/333] Building CXX object src/CMakeFiles/server.dir/script/sigcache.cpp.o
[278/333] Building CXX object src/CMakeFiles/server.dir/shutdown.cpp.o
[279/333] Building CXX object src/CMakeFiles/server.dir/timedata.cpp.o
[280/333] Building CXX object src/CMakeFiles/server.dir/torcontrol.cpp.o
[281/333] Building CXX object src/CMakeFiles/server.dir/node/blockfitter.cpp.o
[282/333] Building CXX object src/CMakeFiles/server.dir/txdb.cpp.o
[283/333] Building CXX object src/CMakeFiles/server.dir/txmempool.cpp.o
[284/333] Building CXX object src/CMakeFiles/server.dir/pow/daa.cpp.o
[285/333] Building CXX object src/CMakeFiles/server.dir/validation.cpp.o
[286/333] Building CXX object src/CMakeFiles/server.dir/validationinterface.cpp.o
[287/333] Building CXX object src/CMakeFiles/server.dir/versionbits.cpp.o
[288/333] Building CXX object src/CMakeFiles/server.dir/wallet/init.cpp.o
[289/333] Building C object src/secp256k1/CMakeFiles/secp256k1.dir/src/secp256k1.c.o
[290/333] Linking C static library src/secp256k1/libsecp256k1.a
[291/333] Linking CXX static library src/libbitcoinconsensus.a
[292/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/bdb.cpp.o
[293/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[294/333] Building CXX object src/CMakeFiles/server.dir/pow/grasberg.cpp.o
[295/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[296/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/context.cpp.o
[297/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[298/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[299/333] Building CXX object src/CMakeFiles/server.dir/init/common.cpp.o
[300/333] Building CXX object src/CMakeFiles/server.dir/node/chainstatemanager_args.cpp.o
[301/333] Building CXX object src/CMakeFiles/server.dir/rpc/abc.cpp.o
[302/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
[303/333] Building CXX object src/CMakeFiles/script.dir/script/descriptor.cpp.o
[304/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpc/backup.cpp.o
[305/333] Building CXX object src/CMakeFiles/server.dir/avalanche/stakecontendercache.cpp.o
[306/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpc/encrypt.cpp.o
[307/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpc/signmessage.cpp.o
[308/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpc/util.cpp.o
[309/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/salvage.cpp.o
[310/333] Linking CXX static library src/libscript.a
[311/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/spend.cpp.o
[312/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[313/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/sqlite.cpp.o
[314/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
[315/333] Linking CXX static library src/libcommon.a
[316/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/receive.cpp.o
[317/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[318/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[319/333] Building CXX object src/CMakeFiles/server.dir/policy/block/preconsensus.cpp.o
[320/333] Building CXX object src/CMakeFiles/bitcoind.dir/bitcoind.cpp.o
[321/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[322/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/transaction.cpp.o
[323/333] Building CXX object src/CMakeFiles/server.dir/txpool.cpp.o
[324/333] Building CXX object src/CMakeFiles/server.dir/node/miner.cpp.o
[325/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[326/333] Building CXX object src/CMakeFiles/server.dir/rpc/txoutproof.cpp.o
[327/333] Building CXX object src/wallet/CMakeFiles/wallet.dir/interfaces.cpp.o
[328/333] Building CXX object src/CMakeFiles/server.dir/rpc/avalanche.cpp.o
[329/333] Linking CXX static library src/wallet/libwallet.a
[330/333] Building CXX object src/CMakeFiles/server.dir/net_processing.cpp.o
[331/333] Linking CXX static library src/libserver.a
[332/333] Linking CXX executable src/bitcoind
Build electrum-functional-tests timed out after 3600.0s
PiRK planned changes to this revision.Oct 10 2025, 15:40

Looks like there is an extra SimpleConfig object instantiated in daemon mode, whenever a RPC command is queried. Need to investigate and reproduce outside of the functional test framework

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

we can't force the config to be a singleton, as RPC commands each use their own config to communicate their command line params to the daemon.
This can be fixed in the future by splitting command line args and persistent config committed to disk into separate objects. For now let's not change anything, except no more global config.

This revision is now accepted and ready to land.Oct 13 2025, 13:04
This revision was automatically updated to reflect the committed changes.