Move CopyrightHolders() and LicenseInfo() into libbitcoin_common #26688

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:221212-common changing 14 files +69 −36
  1. hebasto commented at 3:36 pm on December 12, 2022: member

    After #26645, this change is required to be able to #include clientversion.h in the libbitcoinconsensus code without dependency on util/translation.h.

    Steps to reproduce the problem

    To demonstrate the problem, let’s consider the x86_64-w64-mingw32 platform as it guarantees that all symbols are defined in a library:

    0$ make -C depends HOST=x86_64-w64-mingw32 NO_QT=1 NO_WALLET=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1
    1$ ./autogen.sh && ./configure CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site && make clean
    

    And now, let’s apply a diff as follows:

     0--- a/src/script/bitcoinconsensus.cpp
     1+++ b/src/script/bitcoinconsensus.cpp
     2@@ -8,6 +8,7 @@
     3 #include <primitives/transaction.h>
     4 #include <pubkey.h>
     5 #include <script/interpreter.h>
     6+#include <util/check.h>
     7 #include <version.h>
     8 
     9 namespace {
    10@@ -25,7 +26,7 @@ public:
    11     void read(Span<std::byte> dst)
    12     {
    13         if (dst.size() > m_remaining) {
    14-            throw std::ios_base::failure(std::string(__func__) + ": end of data");
    15+            throw std::ios_base::failure(STR_INTERNAL_BUG("end of data"));
    16         }
    17 
    18         if (dst.data() == nullptr) {
    

    The resulted code fails to compile:

    0$ make
    1...
    2  CXXLD    libbitcoinconsensus.la
    3/usr/bin/x86_64-w64-mingw32-ld: script/.libs/libbitcoinconsensus_la-bitcoinconsensus.o:bitcoinconsensus.cpp:(.text+0x1db): undefined reference to `StrFormatInternalBug[abi:cxx11](char const*, char const*, int, char const*)'
    4...
    

    Obviously, the util/check.cpp needs to be added to the library sources:

    0--- a/src/Makefile.am
    1+++ b/src/Makefile.am
    2@@ -972,6 +972,7 @@ lib_LTLIBRARIES += $(LIBBITCOINCONSENSUS)
    3 
    4 include_HEADERS = script/bitcoinconsensus.h
    5 libbitcoinconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(libbitcoin_consensus_a_SOURCES)
    6+libbitcoinconsensus_la_SOURCES += util/check.cpp
    7 
    8 libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
    9 libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
    

    Now, a linker complains about another symbol:

    0$ make
    1...
    2  CXXLD    libbitcoinconsensus.la
    3/usr/bin/x86_64-w64-mingw32-ld: util/.libs/libbitcoinconsensus_la-check.o:check.cpp:(.text+0x8c): undefined reference to `FormatFullVersion[abi:cxx11]()'
    4...
    

    which is defined in the clientversion.cpp:

    0--- a/src/Makefile.am
    1+++ b/src/Makefile.am
    2@@ -972,6 +972,7 @@ lib_LTLIBRARIES += $(LIBBITCOINCONSENSUS)
    3 
    4 include_HEADERS = script/bitcoinconsensus.h
    5 libbitcoinconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(libbitcoin_consensus_a_SOURCES)
    6+libbitcoinconsensus_la_SOURCES += clientversion.cpp util/check.cpp
    7 
    8 libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
    9 libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
    

    This time a linker error is:

    0$ make
    1...
    2  CXXLD    libbitcoinconsensus.la
    3/usr/bin/x86_64-w64-mingw32-ld: .libs/libbitcoinconsensus_la-clientversion.o:clientversion.:(.rdata$.refptr._Z17G_TRANSLATION_FUNB5cxx11[.refptr._Z17G_TRANSLATION_FUNB5cxx11]+0x0): undefined reference to `G_TRANSLATION_FUN[abi:cxx11]'
    4...
    

    which is supposed to be solved by this PR.


    See #26504.

    The last time those functions were moved in #24409.

  2. DrahtBot commented at 3:36 pm on December 12, 2022: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Ignored review MarcoFalke

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #27150 (Deduplicate bitcoind and bitcoin-qt init code by ryanofsky)
    • #10443 (Add fee_est tool for debugging fee estimation code by ryanofsky)

    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.

  3. fanquake commented at 3:40 pm on December 12, 2022: member
    0  CXX      libbitcoin_node_a-pow.o
    1  CXX      libbitcoin_node_a-rest.o
    2bitcoind.cpp:12:10: fatal error: common/license.h: No such file or directory
    3 #include <common/license.h>
    4          ^~~~~~~~~~~~~~~~~~
    5compilation terminated.
    6make[2]: *** [Makefile:15519: bitcoind-bitcoind.o] Error 1
    
  4. Move `CopyrightHolders()` and `LicenseInfo()` into `libbitcoin_common`
    After https://github.com/bitcoin/bitcoin/pull/26645, this change is
    required to be able to `#include clientversion.h` in the
    `libbitcoinconsensus` code without dependency on `util/translation.h`.
    1370d89b2d
  5. hebasto force-pushed on Dec 12, 2022
  6. maflcko commented at 4:01 pm on December 12, 2022: member

    What are the steps to test/reproduce? I tried, but failed with:

     0$ git diff  src/
     1diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
     2index 38bb11aad4..43084a862f 100644
     3--- a/src/script/interpreter.cpp
     4+++ b/src/script/interpreter.cpp
     5@@ -11,6 +11,7 @@
     6 #include <pubkey.h>
     7 #include <script/script.h>
     8 #include <uint256.h>
     9+#include <util/check.h>
    10 
    11 typedef std::vector<unsigned char> valtype;
    12 
    13@@ -400,6 +401,8 @@ static bool EvalChecksig(const valtype& sig, const valtype& pubkey, CScript::con
    14         // Key path spending in Taproot has no script, so this is unreachable.
    15         break;
    16     }
    17+     STR_INTERNAL_BUG("");
    18+     NONFATAL_UNREACHABLE();
    19     assert(false);
    20 }
    21 
    
  7. hebasto referenced this in commit c3bc03c54e on Dec 12, 2022
  8. hebasto commented at 4:34 pm on December 12, 2022: member

    @MarcoFalke

    What are the steps to test/reproduce? I tried, but failed with:

    An additional diff for your test is required as follows:

     0--- a/src/Makefile.am
     1+++ b/src/Makefile.am
     2@@ -973,7 +973,7 @@ if BUILD_BITCOIN_LIBS
     3 lib_LTLIBRARIES += $(LIBBITCOINCONSENSUS)
     4 
     5 include_HEADERS = script/bitcoinconsensus.h
     6-libbitcoinconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(libbitcoin_consensus_a_SOURCES)
     7+libbitcoinconsensus_la_SOURCES = clientversion.cpp support/cleanse.cpp util/check.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(libbitcoin_consensus_a_SOURCES)
     8 
     9 libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
    10 libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
    
  9. hebasto referenced this in commit b794cabc76 on Dec 12, 2022
  10. maflcko commented at 4:39 pm on December 12, 2022: member
    Ok, but what is the diff/steps to test that diff? ;)
  11. hebasto commented at 4:40 pm on December 12, 2022: member

    What are the steps to test…?

    Perhaps, the first two commits from #26504 are.

  12. maflcko commented at 8:09 am on December 13, 2022: member

    26504 is quite large. It would help testers if there was a MWE (minimal (non)working example) available.

    So for now, I tend toward NACK, unless there is a reason to do this change, with an explanation or steps to verify.

  13. maflcko commented at 5:44 pm on December 15, 2022: member
    26504 compiles fine for me with the changes here reverted
  14. hebasto commented at 8:01 pm on December 15, 2022: member

    @MarcoFalke

    26504 compiles fine for me with the changes here reverted

    And cross-compiling for Windows as well?

  15. maflcko commented at 8:11 pm on December 15, 2022: member
    Haven’t tried that. I think it would be helpful to mention it in the description, so that testing is easier.
  16. maflcko commented at 9:06 pm on December 15, 2022: member
    Ok, I used my diff to test (https://github.com/bitcoin/bitcoin/pull/26688#issuecomment-1346790217) on FILE_ENV="./ci/test/00_setup_env_win64.sh" and could reproduce the build failure. However, I needed #26688 (comment) as well to pass, so I’d suggest adding it here. Otherwise the fix seems incomplete.
  17. hebasto commented at 10:29 am on December 17, 2022: member

    Haven’t tried that. I think it would be helpful to mention it in the description, so that testing is easier.

    The PR description has been updated. A set of diffs was introduced to reproduce the problem and test its fix easily. Specifically noted, that using of x86_64-w64-mingw32 platform makes the problem recognizable as early as possible.

    However, I needed #26688 (comment) as well to pass, so I’d suggest adding it here. Otherwise the fix seems incomplete.

    Sorry, but I disagree. Adding source files, e.g., clientversion.cpp and util/check.cpp, is required to define symbols due to adding a new code, e.g., STR_INTERNAL_BUG(), to the library. This PR is focused on moving of the piece of code into a new source file, and it adds no code to the library.

  18. maflcko approved
  19. maflcko commented at 11:33 am on December 17, 2022: member
    Ok, lgtm
  20. maflcko requested review from fanquake on Dec 17, 2022
  21. hebasto commented at 8:42 am on December 20, 2022: member
    Friendly ping @fanquake :)
  22. fanquake commented at 10:31 am on December 20, 2022: member

    It’s not clear from the PR description why we are making this change. The description says that if you apply a diff, the build fails. However it doesn’t explain why we are fixing a problem we don’t have; there are currently no build issues with master, only after you apply a diff to (purposefully) break things.

    You say

    See #26504.

    but it’s not clear there is consensus on making that change, and the PR description here doesn’t explain how this a prerequisite for that, or, if so, why it needs to be split out in advance.

    It would be good for the PR description to either:

    • Explain why, stand-alone, we should make this change to master. Maybe this code should just live in lib common instead of lib util? If so, why?

    • Explain that it’s a requirement for 26504, and explain why we need to shuffle code now, even though nothing is broken, and it’s not clear that 26504 will actually go ahead.

  23. maflcko commented at 3:39 pm on December 20, 2022: member

    apply a diff to (purposefully) break things.

    I don’t think using util/check in code is a malicious change? At some point util/check will be used in libbitcoinconsensus, after which this change is required, so might as well do it now, to avoid putting the burden on an unsuspecting future dev?

    An alternative, I presume, would be to inject G_TRANSLATION_FUN into libbitcoinconsensus, but I don’t know if that makes more sense.

  24. fanquake commented at 3:58 pm on December 20, 2022: member

    I don’t think using util/check in code is a malicious change?

    I also don’t think it’s malicious. My point is just that if the entire PR rationale is that the build is broken, but only after you’ve broken it with some other patch (i.e not master), I don’t think that’s great reasoning to justify a refactor.

  25. maflcko commented at 4:04 pm on December 20, 2022: member
    I wouldn’t say it is “broken” to use util/check. It seems that it should be supported in all code.
  26. DrahtBot added the label Needs rebase on Mar 7, 2023
  27. DrahtBot commented at 6:06 pm on March 7, 2023: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

  28. achow101 closed this on Apr 25, 2023

  29. maflcko commented at 2:26 pm on April 26, 2023: member
    I think this is a bugfix/requirement for #26504, so I am not sure why it was closed but the other not?
  30. hebasto commented at 6:15 am on April 27, 2023: member

    I think this is a bugfix/requirement for #26504, so I am not sure why it was closed but the other not?

    It is closed as well now.

  31. bitcoin locked this on Apr 26, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-03 07:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me