Skip to content

Use std::filesystem. Remove Boost Filesystem & System#20744

Merged
maflcko merged 4 commits into
bitcoin:masterfrom
fanquake:use_std_filesystem
Feb 3, 2022
Merged

Use std::filesystem. Remove Boost Filesystem & System#20744
maflcko merged 4 commits into
bitcoin:masterfrom
fanquake:use_std_filesystem

Conversation

@fanquake

@fanquake fanquake commented Dec 22, 2020

Copy link
Copy Markdown
Member

This PR replaces our Boost Filesystem usage with std::filesystem and includes dropping Boost System as a dependency. It includes a squashed down version of the changes from #19245.

A macro has been added, modelling how we check for -latomic to facilitate linking with -lstdc++fs when required. This is ~GCC < 9.1 & ~Clang < 9.0, however not always. i.e you could be using Clang 7 on top of a GCC 9 installation (i.e Ubuntu Focal) and use <filesystem> without passing any additional arguments. I've tested this with GCC 8 on Bionic, Clang 7 on Focal & with Apple Clang 12.0.0 on macOS.

Guix build:

bash-5.1# find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
c1f9b326f9be4140f00cebeae5ff8de428a2fb8ecced539fcc36c53f53bfecf4  guix-build-07269321f38e/output/aarch64-linux-gnu/SHA256SUMS.part
b44aca3bcf5ea92a3a6c48c24d6f85576f425f59b73528d4d00c20e950cf2128  guix-build-07269321f38e/output/aarch64-linux-gnu/bitcoin-07269321f38e-aarch64-linux-gnu-debug.tar.gz
27a5553f7bd14797293fc40c5fb131c91e98a61d5481a283f13a1d0497eb5ed8  guix-build-07269321f38e/output/aarch64-linux-gnu/bitcoin-07269321f38e-aarch64-linux-gnu.tar.gz
99e55a88823f6095864a09c9eaa824e24d9ec527380eb394f751c7205b930f69  guix-build-07269321f38e/output/arm-linux-gnueabihf/SHA256SUMS.part
b720b2724fa47fde584f58ed3b587f1d1183523540777fd367ab7e582605cfea  guix-build-07269321f38e/output/arm-linux-gnueabihf/bitcoin-07269321f38e-arm-linux-gnueabihf-debug.tar.gz
c19c247f4e9e0d7f888ac8ba9de1c12d382f48fa828a685d4fe02818a18abd1f  guix-build-07269321f38e/output/arm-linux-gnueabihf/bitcoin-07269321f38e-arm-linux-gnueabihf.tar.gz
55b49ccb38de03bb95101354a16fd8d2190abede5ccc0d9b00b40c0cd526a2f6  guix-build-07269321f38e/output/arm64-apple-darwin/SHA256SUMS.part
baa44752470a6be9acae1c2f8fd1b9bc37afb00971787ea11fbaeddc9ab7c4aa  guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-arm64-apple-darwin.tar.gz
ad7df4d8026d5bcce1321cdccc2e1820e8a8bb7e1064ed16e20a7ea354057fd2  guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.dmg
f342066dc34a14d67c47779a2413a14633a996e8e7ddca89ae0184e23ef99efd  guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.tar.gz
f6905346a5d48f57805fb062d0247ab5007c89047070a0b3125941dd1a2b8aa6  guix-build-07269321f38e/output/dist-archive/bitcoin-07269321f38e.tar.gz
a1f6c4b2b118dbd89770801f0bcffd2218b82df408cd227e34c40493469bb7a2  guix-build-07269321f38e/output/powerpc64-linux-gnu/SHA256SUMS.part
ba8359426e523bf013d93579c1bedc57380214c8170a9743b64ec1a8a3bbccbf  guix-build-07269321f38e/output/powerpc64-linux-gnu/bitcoin-07269321f38e-powerpc64-linux-gnu-debug.tar.gz
b0bb500c274a683ea28ecbc1e8f18c618a9f8acb00045f80ae43c515288402c0  guix-build-07269321f38e/output/powerpc64-linux-gnu/bitcoin-07269321f38e-powerpc64-linux-gnu.tar.gz
38c85e9589e092cd3aa08996aa383c0ccd5c73208943389741355a6eb7f72537  guix-build-07269321f38e/output/powerpc64le-linux-gnu/SHA256SUMS.part
50fcba7942ff48d91e84c093fda0affc17e46167fe1d5137c6e14c5c41f289d1  guix-build-07269321f38e/output/powerpc64le-linux-gnu/bitcoin-07269321f38e-powerpc64le-linux-gnu-debug.tar.gz
fa08ef1ceca072e014faa95ffee945954b2976fa28f90926b87ab0e5f15f8ca5  guix-build-07269321f38e/output/powerpc64le-linux-gnu/bitcoin-07269321f38e-powerpc64le-linux-gnu.tar.gz
e52dd80a9c306d6aeb544acaa1f4ed560b6b92b5184764a05026d45451aa2e94  guix-build-07269321f38e/output/riscv64-linux-gnu/SHA256SUMS.part
864e0a16c485b4159cec3ee0a83b046f1b1c3bc821670011c5ac5cd09ddfb91f  guix-build-07269321f38e/output/riscv64-linux-gnu/bitcoin-07269321f38e-riscv64-linux-gnu-debug.tar.gz
4a061172181322e7ad0cf06405bf74f4c8683eaba3a67ecfd46158cba7627f62  guix-build-07269321f38e/output/riscv64-linux-gnu/bitcoin-07269321f38e-riscv64-linux-gnu.tar.gz
876d82251853205420dffe7237523fc6ee3d09f78bf74cc03dc71f548446f335  guix-build-07269321f38e/output/x86_64-apple-darwin/SHA256SUMS.part
3f82b2e62c60eee68e7b8fc28e4792e069e3c2cd780ee2d67290ca422cdbc47c  guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.dmg
4ccdd4c410cac9d627e54ce83ee4816608681735da3cb93c60c5eb70ca86337a  guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.tar.gz
2179d36b2f60e28c15262d4e51f27465b5ae077f60e550345e125683ca611066  guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx64.tar.gz
b377e72fe84b6a982b8d414d60c85e6319523dff50dc852a0ba907f6d850ddd0  guix-build-07269321f38e/output/x86_64-linux-gnu/SHA256SUMS.part
8547e2f582ce05ae6a6224793b64efb2eb63f2816bf0bed5d53fcc4786274597  guix-build-07269321f38e/output/x86_64-linux-gnu/bitcoin-07269321f38e-x86_64-linux-gnu-debug.tar.gz
83b64805aa39f31a6fa4c2ed41e029c3be084e6dea06b90fac1ebca5c95bce29  guix-build-07269321f38e/output/x86_64-linux-gnu/bitcoin-07269321f38e-x86_64-linux-gnu.tar.gz

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK for 0.23 (earliest), given that this again requires a bunch of aggressive bumps.

Comment thread ci/test/00_setup_env_native_nowallet.sh Outdated
Comment thread ci/test/00_setup_env_win64.sh Outdated
@bitcoin bitcoin deleted a comment from sheffine Dec 22, 2020
Comment thread configure.ac Outdated
Comment thread doc/dependencies.md Outdated
Comment thread src/rpc/blockchain.cpp Outdated
Comment thread src/test/util_tests.cpp Outdated
Comment thread src/wallet/wallettool.cpp Outdated
@DrahtBot

DrahtBot commented Dec 22, 2020

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #23931 (create bitcoin.conf on first run with template by prayank23)
  • #22472 (fuzz: Add environment option to keep /tmp/ clean by agroce)
  • #22380 (build: add and use C_STANDARD and CXX_STANDARD in depends by fanquake)
  • #17127 (util: Correct permissions for datadir and wallets subdir by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@mjdietzx mjdietzx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice‼️ Concept Ack

I didn't have any problems building and running some tests locally on my machine. Also, there's a minor TODO that kind of got lost in the mix here. I had a PR for it when we were on boost #20265

I rebased on your branch and tested it out, seems to work: mjdietzx@55bafb9 - not sure if you want to pull it into this PR, or once this get merged I'll re-open the PR

Comment thread src/wallet/wallet.cpp Outdated
Comment thread src/util/system.cpp Outdated
Comment on lines +742 to +793
if (!BaseParams().DataDir().empty()) {
path /= BaseParams().DataDir();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to "Why not just GetWalletDir() / name even if name is empty?", is another if branch really needed here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: replace boost::filesystem with std::filesystem" (f449c26)

re: #20744 (comment)

similar to "Why not just GetWalletDir() / name even if name is empty?", is another if branch really needed here?

See #20744 (comment), this avoids adding an empty path component and trailing slash if the base datadir is empty

@kiminuo kiminuo Jan 22, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fanquake I believe this one should be:

path = fsbridge::AbsPathJoin(path, BaseParams().DataDir());

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good, but it would be nice to move code changes to their own PR separate from the build changes, so they can get better review and so the final code is simpler. (It would be nice if final code wasn't checking for empty strings multiple places and wasn't calling fs::absolute on paths already known to be absolute.)

I think an initial PR simplifying this one would just replace fs::system_complete(x) with fs::absolute(x) and replace fs::absolute(x, y) with AbsPathJoin(y, x) everywhere. AbsPathJoin would be a util function defined like:

fs::path AbsPathJoin(fs::path p1, fs::path p2)
{
    assert(p1.is_absolute());
    return boost::filesystem::absolute(p2, p1);
}

Then I think this PR wouldn't need to touch any meaningful code except one line in AbsPathJoin:

fs::path AbsPathJoin(fs::path p1, fs::path p2)
{
    assert(p1.is_absolute());
    return p2.empty() ? p1 : p1 / p2;
}

Comment thread src/wallet/load.cpp Outdated
@kiminuo

kiminuo commented Dec 23, 2020

Copy link
Copy Markdown
Contributor

@ryanofsky It is maybe worth reading "Differences between filesystem implementations that affects Bitcoin code" in #19245.

@ryanofsky

ryanofsky commented Dec 23, 2020

Copy link
Copy Markdown
Contributor

@ryanofsky It is maybe worth reading "Differences between filesystem implementations that affects Bitcoin code" in #19245.

Thanks, I saw it but don't think it takes into account the "appends path::preferred_separator" behavior described https://en.cppreference.com/w/cpp/filesystem/path/append which can result in trailing slashes and is different from boost::absolute behavior https://www.boost.org/doc/libs/1_66_0/libs/filesystem/doc/reference.html#absolute.

Also I think it is clearer and better to avoid calling fs::absolute on paths that we already know are absolute. Ideally we would go further and never call fs::absolute or fs::system_complete after daemonization. Behavior of code shouldn't change depending on the process working directory, and in most cases it makes sense for usability to interpret paths relative to the data directory or wallet directory, not the process working directory.

@practicalswift

Copy link
Copy Markdown
Contributor

Concept ACK

@DrahtBot

Copy link
Copy Markdown
Contributor

🕵️ @laanwj @harding have been requested to review this pull request as specified in the REVIEWERS file.

@hebasto

hebasto commented Feb 3, 2022

Copy link
Copy Markdown
Member

Tested 0726932 on Ubuntu Bionic 18.04.

The third commit b87f9c5 compiles ok, but the last commit fails:

$ ./autogen.sh
$ ./configure --without-gui --without-bdb CC=gcc-8 CXX=g++-8
$ make clean
$ make
...
libbitcoin_util.a(libbitcoin_util_a-system.o): In function `boost::system::error_category::std_category::equivalent(std::error_code const&, int) const':
/usr/include/boost/system/error_code.hpp:686: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:689: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:701: undefined reference to `boost::system::generic_category()'
libbitcoin_util.a(libbitcoin_util_a-system.o): In function `boost::system::error_category::std_category::equivalent(int, std::error_condition const&) const':
/usr/include/boost/system/error_code.hpp:656: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:659: undefined reference to `boost::system::generic_category()'
libbitcoin_util.a(libbitcoin_util_a-system.o):/usr/include/boost/system/error_code.hpp:206: more undefined references to `boost::system::generic_category()' follow
libbitcoin_util.a(libbitcoin_util_a-system.o): In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:210: undefined reference to `boost::system::system_category()'
libbitcoin_util.a(libbitcoin_util_a-system.o): In function `_GLOBAL__sub_I_BITCOIN_CONF_FILENAME':
/usr/include/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
Makefile:5708: recipe for target 'bitcoind' failed
make[2]: *** [bitcoind] Error 1
...

@maflcko

maflcko commented Feb 3, 2022

Copy link
Copy Markdown
Member

Concept ACK 0726932 🎀

Show signature

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Concept ACK 07269321f38e46e9e02f16d7cd135ea90692638d 🎀
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgofAv+JlnSIf2qICI4sGlwHKVaOFpBXTij+BiUO/deMkVVE6l34iQxvziFRLLo
gxLGHEZuuvpT6Gg7WK0d/Fn0c3fHvywtF7DCiq299f/8I/Z7y8fKP3d7e2uL57I6
anIWW1QDr0FggeE/oR5Llz6pidZcSfvDDCff/8j1uMng9p/9RKapnNcJFT0ax0mv
nXkKa2axowGT8TkKGs80YPTpPXAPS7Q6sACta6JmRqcRG7ulWVjia5IANWC7aq/A
95HoLJdQ6X4khvQ6627k+vT0eSoPSL7i8dR2S10VBu+aNPFxRgMK2eEBzVLuQ3JN
sFWoW8M3g3dqENu1bsp7zHHmuwcxwn0PeNpKciEp54pooQBNBwWHGjOe5+5gsaar
klFxVV5XjeryXvlWcHjW0J1t7Sr5VCFs9MCsRZilOuyMS2i8FzAbpV6q2mxXue2Y
y6uT2VIbyNPpQwznoiQIiYgCfHRIYaRB4sUoyoAIsJmKDxA4TSoxt2XW23RYrQru
qz+ahi/U
=kXE8
-----END PGP SIGNATURE-----

@prusnak

prusnak commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

Tested 0726932 on Ubuntu Bionic 18.04.

@hebasto Does this happen with clean checkout? Maybe make clean left some artefacts.

@hebasto

hebasto commented Feb 3, 2022

Copy link
Copy Markdown
Member

Tested 0726932 on Ubuntu Bionic 18.04.

@hebasto Does this happen with clean checkout? Maybe make clean left some artefacts.

The same after git clean -xdff.

@maflcko

maflcko commented Feb 3, 2022

Copy link
Copy Markdown
Member

This only happens with system libs and not depends?

@hebasto

hebasto commented Feb 3, 2022

Copy link
Copy Markdown
Member

This only happens with system libs and not depends?

CI builds with depends, right?

@maflcko

maflcko commented Feb 3, 2022

Copy link
Copy Markdown
Member

Yes

Comment thread src/test/util_tests.cpp
Comment on lines +74 to +79
#ifndef WIN32
// Windows does not consider "datadir/.//" to be a valid directory path.
args.ForceSetArg("-datadir", fs::PathToString(dd_norm) + "/.//");
args.ClearPathCache();
BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: replace boost::filesystem with std::filesystem" (41d7166)

The way this is written, it's confusing and vague about windows test behavior. Would change this to actually check windows behavior instead of skipping it, and also add more detail to the comment:

    args.ForceSetArg("-datadir", fs::PathToString(dd_norm) + "/.//");
    args.ClearPathCache();
#ifndef WIN32
    BOOST_CHECK_EQUAL(dd_norm, args.GetDataDirBase());
#else
    // Windows does not consider "datadir/.//" to be a valid directory path, so
    // the check to see if the directory exists returns false on windows, and
    // GetDataDirBase() returns nothing. When this test was originally written
    // GetDataDirBase() function stripped trailing "/" slashes, so the test was
    // the same on all platforms. But as of #20744, trailing slashes are no
    // longer stripped (because it would have complicated the GetDataDirBase
    // implementation), so the test is now platform-specific.
    BOOST_CHECK(args.GetDataDirBase().empty());
#endif

I think trying to clarify things here is worth it, because this test is already very confusing (every time I look at it my brain hurts), and most developers are not using windows, so problems that only happen on windows are especially painful to deal with.

(This is also closer to originally suggested fix from #20744 (review))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the goal was to not allow the unit test to do random crap to the root dir /, outside their assigned m_path_root

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: #20744 (comment)

I think the goal was to not allow the unit test to do random crap to the root dir /, outside their assigned m_path_root

I don't think that's what's happening here. In any case:

  • It is good to replace a vague comment with a specific comment.
  • The point of the test is to ensure bitcoin has sane behavior if user uses extra trailing "./" characters in a custom datadir on linux. If we care about this behavior on linux, I don't think think we should say anything goes on windows and not check behavior there. Windows is a 30+ year old operating system with stable path semantics. If path semantics somehow do change, it is a good thing if the test fails, and the test has an understandable comment, we decide can what to do about it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: replace boost::filesystem with std::filesystem" (41d7166)

I think this change might be able to be reverted actually, because since this test was disabled a StripRedundantLastElementsOfPath call was added to GetDataDir. It looks like the call was added in the Dec 23 push #20744 (comment) https://github.com/bitcoin/bitcoin/compare/f53be20eade794e55470473f03a8d05d57691c87..2c990b05fae7e1bfef2d3f59044c24274812c559#diff-19427b0dd1a791adc728c82e88f267751ba4f1c751e19262cac03cccd2822216R438 without an explanation

Comment thread src/util/system.cpp
{
auto result = path;
while (fs::PathToString(result.filename()) == ".") {
while (result.filename().empty() || fs::PathToString(result.filename()) == ".") {

@ryanofsky ryanofsky Feb 3, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: replace boost::filesystem with std::filesystem" (41d7166)

Note: Just to explain this change, it's needed because std path class, unlike boost path class treats paths with trailing slashes as having a final "" component, instead of a final "." component.

This change was originally suggested #20744 (comment), and a test program for this behavior is https://godbolt.org/z/voadYc8M1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Unfortunately, links like #20744 (comment) do not work for me. There are probably too much comments in this PR or it's resolved. I don't know.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Unfortunately, links like #20744 (comment) do not work for me. There are probably too much comments in this PR or it's resolved. I don't know.)

Github struggles with long discusions threads, and these links often they stop working and then start working again. They're the same link used in github notification emails so not special.

@kiminuo

kiminuo commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

Compiled and run on Windows 11:

image

Seems to work fine 🎉

Comment thread src/util/system.cpp
path /= fs::PathFromString(BaseParams().DataDir());
path /= "blocks";
fs::create_directories(path);
path = StripRedundantLastElementsOfPath(path);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: replace boost::filesystem with std::filesystem" (41d7166)

Note: Just to explain this change, this line is deleted because the path variable is set 2 lines above with literal "blocks" last element, so this line would never do anything, even before this PR. Earlier discussion was #20744 (comment)

@kiminuo

kiminuo commented Feb 3, 2022

Copy link
Copy Markdown
Contributor

@hebasto I tried to compile on Ubuntu 18.04.6 LTS with your instructions and I can see the same result.

@maflcko

maflcko commented Feb 3, 2022

Copy link
Copy Markdown
Member

I think this is ready for merge. Any developers (hopefully none) on Ubuntu Bionic can:

  • Upgrade to a more recent Ubuntu
  • Revert the last commit locally
  • Build from depends
  • Install a more recent boost

Merging now gives more time for testing in master and we still have about 3 weeks to decide how to fix the build on Ubuntu Bionic, with the easiest being a clean revert of the last commit.

Any other minor fixups (like in the tests) can also land in the next 3 weeks.

@hebasto

hebasto commented Feb 3, 2022

Copy link
Copy Markdown
Member

Guix builds:

$ find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
c1f9b326f9be4140f00cebeae5ff8de428a2fb8ecced539fcc36c53f53bfecf4  guix-build-07269321f38e/output/aarch64-linux-gnu/SHA256SUMS.part
b44aca3bcf5ea92a3a6c48c24d6f85576f425f59b73528d4d00c20e950cf2128  guix-build-07269321f38e/output/aarch64-linux-gnu/bitcoin-07269321f38e-aarch64-linux-gnu-debug.tar.gz
27a5553f7bd14797293fc40c5fb131c91e98a61d5481a283f13a1d0497eb5ed8  guix-build-07269321f38e/output/aarch64-linux-gnu/bitcoin-07269321f38e-aarch64-linux-gnu.tar.gz
99e55a88823f6095864a09c9eaa824e24d9ec527380eb394f751c7205b930f69  guix-build-07269321f38e/output/arm-linux-gnueabihf/SHA256SUMS.part
b720b2724fa47fde584f58ed3b587f1d1183523540777fd367ab7e582605cfea  guix-build-07269321f38e/output/arm-linux-gnueabihf/bitcoin-07269321f38e-arm-linux-gnueabihf-debug.tar.gz
c19c247f4e9e0d7f888ac8ba9de1c12d382f48fa828a685d4fe02818a18abd1f  guix-build-07269321f38e/output/arm-linux-gnueabihf/bitcoin-07269321f38e-arm-linux-gnueabihf.tar.gz
55b49ccb38de03bb95101354a16fd8d2190abede5ccc0d9b00b40c0cd526a2f6  guix-build-07269321f38e/output/arm64-apple-darwin/SHA256SUMS.part
baa44752470a6be9acae1c2f8fd1b9bc37afb00971787ea11fbaeddc9ab7c4aa  guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-arm64-apple-darwin.tar.gz
ad7df4d8026d5bcce1321cdccc2e1820e8a8bb7e1064ed16e20a7ea354057fd2  guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.dmg
f342066dc34a14d67c47779a2413a14633a996e8e7ddca89ae0184e23ef99efd  guix-build-07269321f38e/output/arm64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.tar.gz
f6905346a5d48f57805fb062d0247ab5007c89047070a0b3125941dd1a2b8aa6  guix-build-07269321f38e/output/dist-archive/bitcoin-07269321f38e.tar.gz
a1f6c4b2b118dbd89770801f0bcffd2218b82df408cd227e34c40493469bb7a2  guix-build-07269321f38e/output/powerpc64-linux-gnu/SHA256SUMS.part
ba8359426e523bf013d93579c1bedc57380214c8170a9743b64ec1a8a3bbccbf  guix-build-07269321f38e/output/powerpc64-linux-gnu/bitcoin-07269321f38e-powerpc64-linux-gnu-debug.tar.gz
b0bb500c274a683ea28ecbc1e8f18c618a9f8acb00045f80ae43c515288402c0  guix-build-07269321f38e/output/powerpc64-linux-gnu/bitcoin-07269321f38e-powerpc64-linux-gnu.tar.gz
38c85e9589e092cd3aa08996aa383c0ccd5c73208943389741355a6eb7f72537  guix-build-07269321f38e/output/powerpc64le-linux-gnu/SHA256SUMS.part
50fcba7942ff48d91e84c093fda0affc17e46167fe1d5137c6e14c5c41f289d1  guix-build-07269321f38e/output/powerpc64le-linux-gnu/bitcoin-07269321f38e-powerpc64le-linux-gnu-debug.tar.gz
fa08ef1ceca072e014faa95ffee945954b2976fa28f90926b87ab0e5f15f8ca5  guix-build-07269321f38e/output/powerpc64le-linux-gnu/bitcoin-07269321f38e-powerpc64le-linux-gnu.tar.gz
e52dd80a9c306d6aeb544acaa1f4ed560b6b92b5184764a05026d45451aa2e94  guix-build-07269321f38e/output/riscv64-linux-gnu/SHA256SUMS.part
864e0a16c485b4159cec3ee0a83b046f1b1c3bc821670011c5ac5cd09ddfb91f  guix-build-07269321f38e/output/riscv64-linux-gnu/bitcoin-07269321f38e-riscv64-linux-gnu-debug.tar.gz
4a061172181322e7ad0cf06405bf74f4c8683eaba3a67ecfd46158cba7627f62  guix-build-07269321f38e/output/riscv64-linux-gnu/bitcoin-07269321f38e-riscv64-linux-gnu.tar.gz
876d82251853205420dffe7237523fc6ee3d09f78bf74cc03dc71f548446f335  guix-build-07269321f38e/output/x86_64-apple-darwin/SHA256SUMS.part
3f82b2e62c60eee68e7b8fc28e4792e069e3c2cd780ee2d67290ca422cdbc47c  guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.dmg
4ccdd4c410cac9d627e54ce83ee4816608681735da3cb93c60c5eb70ca86337a  guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx-unsigned.tar.gz
2179d36b2f60e28c15262d4e51f27465b5ae077f60e550345e125683ca611066  guix-build-07269321f38e/output/x86_64-apple-darwin/bitcoin-07269321f38e-osx64.tar.gz
b377e72fe84b6a982b8d414d60c85e6319523dff50dc852a0ba907f6d850ddd0  guix-build-07269321f38e/output/x86_64-linux-gnu/SHA256SUMS.part
8547e2f582ce05ae6a6224793b64efb2eb63f2816bf0bed5d53fcc4786274597  guix-build-07269321f38e/output/x86_64-linux-gnu/bitcoin-07269321f38e-x86_64-linux-gnu-debug.tar.gz
83b64805aa39f31a6fa4c2ed41e029c3be084e6dea06b90fac1ebca5c95bce29  guix-build-07269321f38e/output/x86_64-linux-gnu/bitcoin-07269321f38e-x86_64-linux-gnu.tar.gz

@hebasto

hebasto commented Feb 3, 2022

Copy link
Copy Markdown
Member

ACK 0726932

Agree with @MarcoFalke's comment.

@ryanofsky ryanofsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial code review ACK for commit "refactor: replace boost::filesystem with std::filesystem" (41d7166). I looked at this commit in detail, just not the other commits.

Overall I think this is good, but there is some dodginess going on with trailing / characters in paths, that is showing up in comments here about tests on windows, but could indicate unintended changes in behavior that cause bugs on other platforms. Windows complains more about extra / characters in paths but that doesn't mean extra / characters don't break things on other platforms, too. For example if there are string comparisons that no longer return true because of extra slashes.

Comment thread src/wallet/bdb.cpp

try {
if (fs::equivalent(pathSrc, pathDest)) {
if (fs::exists(pathDest) && fs::equivalent(pathSrc, pathDest)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "build: remove boost::filesystem usage" (b87f9c5)

Note: this change was needed because fs::equivalent was throwing an exception if the path didn't exist. Earlier discussion was #20744 (comment)

Comment thread src/wallet/load.cpp
std::error_code error;
// The canonical path cleans the path, preventing >1 Berkeley environment instances for the same directory
fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error).remove_trailing_separator();
fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: replace boost::filesystem with std::filesystem" (41d7166)

Note: std canonical function already strips trailing slashes, so this should not be a change in behavior

}

#ifndef WIN32
// Windows does not consider "datadir/wallets//" to be a valid directory path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "refactor: replace boost::filesystem with std::filesystem" (41d7166)

What's the behavior if you use this path on windows? I don't think we want bitcoins's behavior undefined and untested in this case. It would be better for users and also clearer in the test code to check what the resulting behavior is on windows and decide if it is good or bad.

Or best thing might be to add a StripRedundantLastElementsOfPath call in the -walletdir= parsing code like the one that was added to GetDataDir in this PR, so this test could go back to be enabled and working the same across platforms.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was assuming that this modifies gArgs, but given that the args is local, it should be fine, assuming that the argsmanager doesn't write to disk by itself.

@hebasto

hebasto commented Feb 3, 2022

Copy link
Copy Markdown
Member

Tested 0726932 on Ubuntu Bionic 18.04.

The third commit b87f9c5 compiles ok, but the last commit fails:

Fixed in #24254.

@maflcko

maflcko commented Feb 7, 2022

Copy link
Copy Markdown
Member

@DrahtBot

DrahtBot commented Feb 8, 2022

Copy link
Copy Markdown
Contributor

Guix builds

File commit 133f73e
(master)
commit c22ce78ce460aa5ae6870c0f6ec3f83182506a29
(master and this pull)
SHA256SUMS.part 4d29ebeb3309d60d... fe3150bbd0109d5f...
*-aarch64-linux-gnu-debug.tar.gz c29ba0d0426063e8... e16ef933ef09c924...
*-aarch64-linux-gnu.tar.gz e52c846b1841b3eb... 89b610a00c36b994...
*-arm-linux-gnueabihf-debug.tar.gz 5d3f9731cf88da5b... 4c1e672b25015b27...
*-arm-linux-gnueabihf.tar.gz 282b33b13dd1f8a0... 16dfc5343616a8f2...
*-arm64-apple-darwin.tar.gz 3f0dba0a6549c410... 68cf545be72ba21c...
*-osx-unsigned.dmg 6692809452b6cb62... 1d7e80f446d77db4...
*-osx-unsigned.tar.gz 4366f453672f800d... 135c65dd5f337523...
*-osx64.tar.gz 5387d0cdc36be37a... aa75f3413a4a724d...
*-powerpc64-linux-gnu-debug.tar.gz 1ed57908059941ef... efa6d04faf2798ae...
*-powerpc64-linux-gnu.tar.gz 21079e1bae0f459b... adcc9fe3a4e926d6...
*-powerpc64le-linux-gnu-debug.tar.gz 6b441c519f2d3185... d6f4c9fb1386b4e5...
*-powerpc64le-linux-gnu.tar.gz 132f95573d0fd005... affab9079ecc51be...
*-riscv64-linux-gnu-debug.tar.gz 3c5e1f8e3d9aa92a... 4acf9cee4026d4a8...
*-riscv64-linux-gnu.tar.gz b17efbca76425fc5... 0a8151ca3ddd5261...
*-x86_64-linux-gnu-debug.tar.gz 9f61cd7fca8d6425... 19538169ad68c373...
*-x86_64-linux-gnu.tar.gz 323dc8d7d0aa8290... 4642e4b995756947...
*.tar.gz 5887839fbd29cd1c... a83d8979a6d86f22...
guix_build.log 53868781dafe6675... 6a54af53a5cc64da...
guix_build.log.diff 3887c19da2411792...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No match for fs::path operator+= when compiling with Boost 1.78 C++17 std::fs