33e2b82a4fc990253ff77655f437c7aed336bc55 wallet, bench: Remove unused database options from WalletBenchLoading (Andrew Chow) 80ace042d8fece9be50bfef1be64c6e5720e87e6 tests: Modify records directly in wallet ckey loading test (Andrew Chow) b3bb17d5d07f51ac2e501e4a7a3bbcd17144070f tests: Update DuplicateMockDatabase for MockableDatabase (Andrew Chow) f0eecf5e408238c64b77b0a4974ba2b9edb17487 scripted-diff: Replace CreateMockWalletDB with CreateMockableWalletDB (Andrew Chow) 075962bc25a90661612fe4613cd50ea1cae21f52 wallet, tests: Include wallet/test/util.h (Andrew Chow) 14aa4cb1e44f089a6022a2b14a98bca4a7dd9a01 wallet: Move DummyDatabase to salvage (Andrew Chow) f67a385556c60b2e4788a378196a395fca0539f5 wallet, tests: Replace usage of dummy db with mockable db (Andrew Chow) 33c6245ac1ecdfe25b1ee4fd9e93c43393634ae3 Introduce MockableDatabase for wallet unit tests (Andrew Chow) Pull request description: For the wallet's unit tests, we currently use either `DummyDatabase` or memory-only versions of either BDB or SQLite. The tests that use `DummyDatabase` just need a `WalletDatabase` so that the `CWallet` can be constructed, while the tests using the memory-only databases just need a backing data store. There is also a `FailDatabase` that is similar to `DummyDatabase` except it fails be default or can have a configured return value. Having all of these different database types can make it difficult to write tests, particularly tests that work when either BDB or SQLite is disabled. This PR unifies all of these different unit test database classes into a single `MockableDatabase`. Like `DummyDatabase`, most functions do nothing and just return true. Like `FailDatabase`, the return value of some functions can be configured on the fly to test various failure cases. Like the memory-only databases, records can actually be written to the `MockableDatabase` and be retrieved later, but all of this is still held in memory. Using `MockableDatabase` completely removes the need for having BDB or SQLite backed wallets in the unit tests for the tests that are not actually testing specific database behaviors. Because `MockableDatabase`s can be created by each unit test, we can also control what records are stored in the database. Records can be added and removed externally from the typical database modification functions. This will give us greater ability to test failure conditions, particularly those involving corrupted records. Possible alternative to #26644 ACKs for top commit: furszy: ACK 33e2b82 TheCharlatan: ACK 33e2b82a4fc990253ff77655f437c7aed336bc55 Tree-SHA512: c2b09eff9728d063d2d4aea28a0f0e64e40b76483e75dc53f08667df23bd25834d52656cd4eafb02e552db0b9e619cfdb1b1c65b26b5436ee2c971d804768bcc
Building Bitcoin Core with Visual Studio
Introduction
Visual Studio 2022 is minimum required to build Bitcoin Core.
Solution and project files to build with msbuild
or Visual Studio can be found in the build_msvc
directory.
To build Bitcoin Core from the command-line, it is sufficient to only install the Visual Studio Build Tools component.
The "Desktop development with C++" workload must be installed as well.
Building with Visual Studio is an alternative to the Linux based cross-compiler build.
Prerequisites
To build dependencies (except for Qt), the default approach is to use the vcpkg package manager from Microsoft:
-
Install vcpkg.
-
By default, vcpkg makes both
release
anddebug
builds for each package. To save build time and disk space, one could skipdebug
builds (example uses PowerShell):
Add-Content -Path "vcpkg\triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
Qt
To build Bitcoin Core with the GUI, a static build of Qt is required.
-
Download a single ZIP archive of Qt source code from https://download.qt.io/official_releases/qt/ (e.g.,
qt-everywhere-opensource-src-5.15.5.zip
), and expand it into a dedicated folder. The following instructions assume that this folder isC:\dev\qt-source
. -
Open "x64 Native Tools Command Prompt for VS 2022", and input the following commands:
cd C:\dev\qt-source
mkdir build
cd build
..\configure -release -silent -opensource -confirm-license -opengl desktop -static -static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -nomake examples -nomake tests -nomake tools -no-angle -no-dbus -no-gif -no-gtk -no-ico -no-icu -no-libjpeg -no-libudev -no-sql-sqlite -no-sql-odbc -no-sqlite -no-vulkan -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip doc -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtlottie -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -no-openssl -no-feature-bearermanagement -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-sql -no-feature-sqlmodel -no-feature-textbrowser -no-feature-textmarkdownwriter -no-feature-textodfwriter -no-feature-xml -prefix C:\Qt_static
nmake
nmake install
One could speed up building with jom
, a replacement for nmake
which makes use of all CPU cores.
To build Bitcoin Core without Qt, unload or disable the bitcoin-qt
, libbitcoin_qt
and test_bitcoin-qt
projects.
Building
- Use Python to generate
*.vcxproj
for the Visual Studio 2022 toolchain from Makefile:
python build_msvc\msvc-autogen.py
-
An optional step is to adjust the settings in the
build_msvc
directory and thecommon.init.vcxproj
file. This project file contains settings that are common to all projects such as the runtime library version and target Windows SDK version. The Qt directories can also be set. To specify a non-default path to a static Qt package directory, use theQTBASEDIR
environment variable. -
To build from the command-line with the Visual Studio toolchain use:
msbuild build_msvc\bitcoin.sln -property:Configuration=Release -maxCpuCount -verbosity:minimal
Alternatively, open the build_msvc/bitcoin.sln
file in Visual Studio.
Security
Base address randomization is used to make Bitcoin Core more secure. When building Bitcoin using the build_msvc
process base address randomization can be disabled by editing common.init.vcproj
to change RandomizedBaseAddress
from true
to false
and then rebuilding the project.
To check if bitcoind
has RandomizedBaseAddress
enabled or disabled run
.\dumpbin.exe /headers src/bitcoind.exe
If is it enabled then in the output Dynamic base
will be listed in the DLL characteristics
under OPTIONAL HEADER VALUES
as shown below
8160 DLL characteristics
High Entropy Virtual Addresses
Dynamic base
NX compatible
Terminal Server Aware
This may not disable all stack randomization as versions of windows employ additional stack randomization protections. These protections must be turned off in the OS configuration.