Commit Graph

27545 Commits

Author SHA1 Message Date
MarcoFalke
8e1913ae02
Merge #21062: refactor: return MempoolAcceptResult from ATMP
53e716ea11 [refactor] improve style for touched code (gzhao408)
174cb5330a [refactor] const ATMPArgs and non-const Workspace (gzhao408)
f82baf0762 [refactor] return MempoolAcceptResult (gzhao408)
9db10a5506 [refactor] clean up logic in testmempoolaccept (gzhao408)

Pull request description:

  This is the first 4 commits of #20833, and does refactoring only. It should be relatively simple to review, and offers a few nice things:
  - It makes accessing values that don't make sense (e.g. fee) when the tx is invalid an error.
  - Returning `MempoolAcceptResult` from ATMP makes the interface cleaner. The caller can get a const instead of passing in a mutable "out" param.
  - We don't have to be iterating through a bunch of lists for package validation, we can just return a `std::vector<MempoolAcceptResult>`.
  - We don't have to refactor all ATMP call sites again if/when we want to return more stuff from it.

ACKs for top commit:
  MarcoFalke:
    ACK 53e716ea11 💿
  jnewbery:
    Code review ACK 53e716ea11
  ariard:
    Code Review ACK 53e716e, I did tweak a bit the touched paths to see if we had good test coverage. Didn't find holes.

Tree-SHA512: fa6ec324a08ad9e6e55948615cda324cba176255708bf0a0a0f37cedb7a75311aa334ac6f223be7d8df3c7379502b1081102b9589f9a9afa1713ad3d9ab3c24f
2021-02-11 14:45:41 +01:00
Wladimir J. van der Laan
a1be08405d
Merge #20788: net: add RAII socket and use it instead of bare SOCKET
615ba0eb96 test: add Sock unit tests (Vasil Dimov)
7bd21ce1ef style: rename hSocket to sock (Vasil Dimov)
04ae846904 net: use Sock in InterruptibleRecv() and Socks5() (Vasil Dimov)
ba9d73268f net: add RAII socket and use it instead of bare SOCKET (Vasil Dimov)
dec9b5e850 net: move CloseSocket() from netbase to util/sock (Vasil Dimov)
aa17a44551 net: move MillisToTimeval() from netbase to util/time (Vasil Dimov)

Pull request description:

  Introduce a class to manage the lifetime of a socket - when the object
  that contains the socket goes out of scope, the underlying socket will
  be closed.

  In addition, the new `Sock` class has a `Send()`, `Recv()` and `Wait()`
  methods that can be overridden by unit tests to mock the socket
  operations.

  The `Wait()` method also hides the
  `#ifdef USE_POLL poll() #else select() #endif` technique from higher
  level code.

ACKs for top commit:
  laanwj:
    Re-ACK 615ba0eb96
  jonatack:
    re-ACK 615ba0eb96

Tree-SHA512: 3003e6bc0259295ca0265ccdeb1522ee25b4abe66d32e6ceaa51b55e0a999df7ddee765f86ce558a788c1953ee2009bfa149b09d494593f7d799c0d7d930bee8
2021-02-11 14:07:33 +01:00
MarcoFalke
685c16fcb2
Merge #21043: net: Avoid UBSan warning in ProcessMessage(...)
3ddbf22ed1 util: Disallow negative mocktime (MarcoFalke)
f5f2f97168 net: Avoid UBSan warning in ProcessMessage(...) (practicalswift)

Pull request description:

  Avoid UBSan warning in `ProcessMessage(...)`.

  Context: https://github.com/bitcoin/bitcoin/pull/20380#issuecomment-770427182 (thanks Crypt-iQ!)

ACKs for top commit:
  MarcoFalke:
    re-ACK 3ddbf22ed1 only change is adding patch written by me
  ajtowns:
    ACK 3ddbf22ed1 -- code review only

Tree-SHA512: e8d7af0457ca86872b75a4e406c0a93aafd841c2962e244e147e748cc7ca118c56be0fdafe53765f4b291410030b2c3cc8f76f733b37a955d34fc885ab6037b9
2021-02-11 12:40:12 +01:00
MarcoFalke
e498aeffbe
Merge #20211: Use -Wswitch for TxoutType where possible
fa650ca7f1 Use -Wswitch for TxoutType where possible (MarcoFalke)
fa59e0b5bd test: Add missing script_standard_Solver_success cases (MarcoFalke)

Pull request description:

  This removes unused `default:` cases for all `switch` statements on `TxoutType` and adds the cases (`MULTISIG`, `NULL_DATA`, `NONSTANDARD`) to `ExtractDestination` for clarity.

  Also, the compiler is now able to use `-Wswitch`.

ACKs for top commit:
  practicalswift:
    cr ACK fa650ca7f1: patch looks correct and `assert(false);` is better than UB :)
  hebasto:
    ACK fa650ca7f1, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 282458b6523bd8923a0c0f5c423d1db2dce2a2d1b1d1dae455415c6fc995bb41ce82c1f9b0a1c0dcc6d874d171e04c30eca585f147582f52c7048c140358630a
2021-02-11 11:48:12 +01:00
MarcoFalke
a59e7ed0bc
Merge #20915: fuzz: Fail if message type is not fuzzed
fa4bc897fc fuzz: Fail if message type is not fuzzed (MarcoFalke)
faefed8cd5 fuzz: Count message type fuzzers before main() (MarcoFalke)

Pull request description:

  `process_message_*` is a nice way to quickly fuzz a single message type. However, the offered message types are outdated and all BIPs implemented in the last years are missing.

  Fix that by adding them and failing when the number of message types don't add up.

ACKs for top commit:
  practicalswift:
    cr ACK fa4bc897fc: patch looks correct and touches only `src/test/fuzz/`

Tree-SHA512: 8c98374b50fb4ab2ff2550daeab4c6e9f486bfe847466d217d4bc97d119adc99a82b87b56f47535b1cf8f844232bc7fa1230712a9147cda514ae78851556f988
2021-02-11 10:50:15 +01:00
Vasil Dimov
615ba0eb96
test: add Sock unit tests 2021-02-11 10:44:53 +01:00
MarcoFalke
dd0521b640
Merge #21023: fuzz: Disable shuffle when merge=1
fabeb5b9c7 fuzz: Disable shuffle when merge=1 (MarcoFalke)

Pull request description:

  This should hopefully help make the deletion of fuzz inputs more deterministic.

  My tests (N=1) revealed that without this patch 7000 files differ (https://github.com/bitcoin-core/qa-assets/pull/44#issuecomment-768841467). With this patch, "only" 2000 files differ.

ACKs for top commit:
  practicalswift:
    cr ACK fabeb5b9c7: `-shuffle=0` and `-prefer_small=1` make sense

Tree-SHA512: 21a701f52450d402a91dd6e0b33d564c63a9c3b919738eb9a80c24d48fc5b964088e325470738f39af0d595612c844acc7bf0941590cc2dc8c6f6ee4cb69c861
2021-02-11 10:34:45 +01:00
MarcoFalke
fa4bc897fc
fuzz: Fail if message type is not fuzzed 2021-02-11 09:40:41 +01:00
MarcoFalke
faefed8cd5
fuzz: Count message type fuzzers before main() 2021-02-11 09:39:32 +01:00
MarcoFalke
b69eab9025
Merge #20663: fuzz: Hide script_assets_test_minimizer
fac726b1b8 doc: Fixup docs in fuzz/script_assets_test_minimizer.cpp (MarcoFalke)
fafca47adc fuzz: Hide script_assets_test_minimizer (MarcoFalke)

Pull request description:

  This is not an actual fuzz target. It is a hack to exploit the built-in capability of fuzz engines to measure coverage.

ACKs for top commit:
  practicalswift:
    cr ACK fac726b1b8: patch looks correct and touches only `src/test/fuzz/`

Tree-SHA512: 0652dd8d9e95746b0906be4044467435d8204a34a30366ae9bdb75b9cb0788d429db7cedf2760fd543565d9d4f7ee206873ed10a29dd715a792a26337f65b53c
2021-02-11 07:54:22 +01:00
Wladimir J. van der Laan
deb185d2fd
Merge #21130: script: Make LXC container size suitable for gitian builds
166266a372 script: Make LXC container size suitable for gitian builds (Hennadii Stepanov)

Pull request description:

  This change prevents "No space left on device" error.

  See:
  - https://github.com/bitcoin/bitcoin/pull/21036#issuecomment-774771873
  - https://github.com/bitcoin/bitcoin/pull/21036#issuecomment-775031315

ACKs for top commit:
  jonasschnelli:
    ACK 166266a372 - I had to add this manually to my nighly build base image

Tree-SHA512: 47d84c3a65f0a17013b2cb970c34bfa4e600e83066be302ff10280aefefa0a7c6cb6c21a191b3e8e6fcd1c292d1c434cc4769e04626c4536050aced29b34d573
2021-02-10 19:37:06 +01:00
Wladimir J. van der Laan
3c514cfe62
Merge #21114: Deduplicate some block-to-JSON code
fa2c521115 Deduplicate some block-to-JSON code. (Daniel Kraft)

Pull request description:

  Some of the logic converting blocks and block headers to JSON for the blockchain RPC methods (`getblock`, `getlockheader`) was duplicated. Instead of that, the `blockToJSON` RPC method now calls `blockheaderToJSON` first, and then fills in the missing, block-specific bits explicitly.

ACKs for top commit:
  laanwj:
    Code review ACK fa2c521115

Tree-SHA512: 1b9b269e251d9c8c1056f253cfc2a795170d609f4c26ecc85b1ff9cdd567095a673dd89564e0d587b32dfc152ea01b2682169b018f2c9c3004c511a9998d772e
2021-02-10 14:49:44 +01:00
Wladimir J. van der Laan
b3dda0af0e
Merge #21123: code style: Add EditorConfig file
7a135d57b2 Add EditorConfig file. (Kiminuo)

Pull request description:

  ### Motivation

  Developers are supposed to follow [Coding style](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#coding-style-general). However, [from time to time](https://github.com/bitcoin/bitcoin/pull/21075#discussion_r570125634) a PR is created and then its author is asked to change tabs to spaces, for example.

  Introducing an `.editorconfig` file can mitigate these formatting issues.

  ### User story

  A contributor wants to create a new PR. She clones Bitcoin Core repo, opens her editor, the editor loads `.editorconfig` rules and writes her patch with correct formatting rules. Less Coding Style issues is then discovered in the PR review process and thus less CI runs are needed.

  ### What is EditorConfig file?

  https://editorconfig.org provides very well and concise explanation:

  > What is EditorConfig?

  > EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs. The EditorConfig project consists of a file format for defining coding styles and a collection of text editor plugins that enable editors to read the file format and adhere to defined styles. EditorConfig files are easily readable and they work nicely with version control systems.

  ### Support

  `.editorconfig` is supported by many IDEs and text editors. Sometimes, the support is out of the box and sometimes a plugin is needed. However, for example, VS Code detects `.editorconfig` presence and automatically offers you to install the missing plugin.

  See https://editorconfig.org/#pre-installed for details on support. To name a few:

  * Visual Studio (out of the box)
  * VS Code (plugin)
  * JetBrains IDEs (IntelliJ IDEA, PyCharm, etc.) (out of the box)
  * Sublime Text (plugin)
  * Emacs (plugin)
  * Vim (plugin)

  Not supported (AFAIK):

  * [mcedit](https://github.com/MidnightCommander/mc)

  ### My editor does not support `.editorconfig`

  Then nothing really changes for you.

  ### `.editorconfig` vs `.clang-format`

  As explained [here](https://devblogs.microsoft.com/cppblog/clangformat-support-in-visual-studio-2017-15-7-preview-1/):

  > Note that Visual Studio also supports EditorConfig, which works in a similar way. ClangFormat, however, has a [much larger variety of style options](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) than EditorConfig, including some very C++ specific rules that can be set, and it is already used by C++ developers today.

  Having both `.editorconfig` and `.clang-format` in a project, may not always work correctly though, I think. As some editors may have a plugin for `.editorconfig` and a plugin for `clang-formatter` which may not work correctly in unison. In VS Code & Visual Studio EditorConfig [takes precedence over other settings](https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/ide/cpp-editorconfig-properties.md#c-editorconfig-formatting-conventions).

  ### Possible issues

  Your editor may change formatting for some 3rd party library if you edit the code. A solution for this would be to make EditorConfig rules more specific (include only certain paths). I'm not sure if it is an issue in practice.

  ### Testing

  Add some trailing whitespace to a Python file and save the file. You should see that the trailing whitespace is removed.

  ### Possible future work

  It would be great to define rules for Makefiles. This would be good start:

  ```
  # Makefiles
  [Makefile,*.am]
  indent_style = tab
  trim_trailing_whitespace = true
  ```

  I don't know makefiles in this project good enough to propose something reasonable. If this PR is well received, it would be great to add it in this PR.

  Also, there are actually many different file extensions and so the proposed `.editorconfig` file can be probably improved very much:

  ```powershell
  Get-ChildItem -Recurse | % {$_.Extension.ToLower()} | sort | unique
  ```

  <details><summary>Click to see the output</summary>

  ```
  .1
  .ac
  .adoc
  .am
  .bash-completion
  .bat
  .bmp
  .c
  .cc
  .cert
  .cfg
  .clang_complete
  .clang-format
  .cmake
  .cmd
  .cnf
  .com
  .conf
  .cpp
  .css
  .csv
  .doxyfile
  .dtd
  .empty
  .exe
  .exp
  .gci
  .gitattributes
  .github
  .gitignore
  .gitmodules
  .guess
  .h
  .hex
  .hpp
  .html
  .icns
  .ico
  .idb
  .ilk
  .in
  .include
  .ini
  .init
  .ipp
  .jam
  .js
  .json
  .lastbuildstate
  .lib
  .list
  .log
  .m
  .m4
  .md
  .mk
  .mm
  .moc
  .obj
  .openrc
  .openrcconf
  .patch
  .pc
  .pdb
  .pl
  .plist
  .png
  .po
  .pro
  .py
  .python-version
  .qbk
  .qm
  .qml
  .qrc
  .raw
  .rb
  .rc
  .recipe
  .res
  .s
  .sage
  .sass
  .scm
  .scss
  .service
  .sgml
  .sh
  .sln
  .spec
  .sub
  .supp
  .svg
  .targets
  .td
  .tlog
  .ts
  .tx
  .txt
  .ui
  .user
  .v2
  .vcxproj
  .verbatim
  .vscode
  .xml
  .xpm
  .xsl
  .y
  .yapf
  .yml
  .yy
  ```

  </details>

  Fixes #21092

ACKs for top commit:
  laanwj:
    Tested re-ACK 7a135d57b2
  MarcoFalke:
    Approach ACK 7a135d57b2

Tree-SHA512: c36a3424ecc751fbdd66101463b0c470f5c7adcdb4795b1cd267ff718eb345a04615fc1182338adf5b7db724469dca00c64815a9ef77064734a6536fba41a2ba
2021-02-10 14:30:58 +01:00
Vasil Dimov
7bd21ce1ef
style: rename hSocket to sock
In the arguments of `InterruptibleRecv()`, `Socks5()` and
`ConnectThroughProxy()` the variable `hSocket` was previously of type
`SOCKET`, but has been changed to `Sock`. Thus rename it to `sock` to
imply its type, to distinguish from other `SOCKET` variables and to
abide to the coding style wrt variables' names.
2021-02-10 13:30:09 +01:00
Vasil Dimov
04ae846904
net: use Sock in InterruptibleRecv() and Socks5()
Use the `Sock` class instead of `SOCKET` for `InterruptibleRecv()` and
`Socks5()`.

This way the `Socks5()` function can be tested by giving it a mocked
instance of a socket.

Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>
2021-02-10 13:30:08 +01:00
Vasil Dimov
ba9d73268f
net: add RAII socket and use it instead of bare SOCKET
Introduce a class to manage the lifetime of a socket - when the object
that contains the socket goes out of scope, the underlying socket will
be closed.

In addition, the new `Sock` class has a `Send()`, `Recv()` and `Wait()`
methods that can be overridden by unit tests to mock the socket
operations.

The `Wait()` method also hides the
`#ifdef USE_POLL poll() #else select() #endif` technique from higher
level code.
2021-02-10 13:30:08 +01:00
Vasil Dimov
dec9b5e850
net: move CloseSocket() from netbase to util/sock
Move `CloseSocket()` (and `NetworkErrorString()` which it uses) from
`netbase.{h,cpp}` to newly added `src/util/sock.{h,cpp}`.

This is necessary in order to use `CloseSocket()` from a newly
introduced Sock class (which will live in `src/util/sock.{h,cpp}`).
`sock.{h,cpp}` cannot depend on netbase because netbase will depend
on it.
2021-02-10 13:30:08 +01:00
fanquake
cda914228a
Merge #21138: ci: Re-run wine tests once if they fail
faa8afe70b ci: Re-run wine tests once if they fail (MarcoFalke)

Pull request description:

  Works around the intermittent wine issue: https://github.com/bitcoin/bitcoin/issues/21122#issuecomment-776517563

ACKs for top commit:
  fanquake:
    ACK faa8afe70b - thanks for following up with this.

Tree-SHA512: cb377a8e62c7fcf38fb5bdd6203af82c6c302c86f7fc219cb756eb7b6d3d4fe4ebf30a36ebba739199ff7814b26256a3701cf38dc5e681b18c2f249cdf6d852e
2021-02-10 19:51:01 +08:00
Vasil Dimov
aa17a44551
net: move MillisToTimeval() from netbase to util/time
Move `MillisToTimeval()` from `netbase.{h,cpp}` to
`src/util/system.{h,cpp}`.

This is necessary in order to use `MillisToTimeval()` from a newly
introduced `src/util/sock.{h,cpp}` which cannot depend on netbase
because netbase will depend on it.
2021-02-10 11:00:12 +01:00
MarcoFalke
f61c3a1090
Merge #21125: test: Change BOOST_CHECK to BOOST_CHECK_EQUAL for paths
059e8ccc1e Change BOOST_CHECK to BOOST_CHECK_EQUAL to see mismatched values when a check fails. (Kiminuo)

Pull request description:

  This is useful to see mismatched values when a check fails as specified in the [Boost documentation](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_level.html).

  This PR would make #20744 PR's diff smaller by a bit.

ACKs for top commit:
  MarcoFalke:
    review ACK 059e8ccc1e
  theStack:
    Code Review ACK 059e8ccc1e

Tree-SHA512: 82359ef38e0d1926f12a34aeff6fde6d1d307c703a080547749b908f873c2a2f894f6f094c33470b32987c229e3a1f17f7d1e877663c53293c023bde0e7272c1
2021-02-10 10:07:07 +01:00
Daniel Kraft
fa2c521115 Deduplicate some block-to-JSON code.
Some of the logic converting blocks and block headers to JSON for
the blockchain RPC methods (getblock, getlockheader) was duplicated.
Instead of that, the blockToJSON RPC method now calls blockheaderToJSON
first, and then fills in the missing, block-specific bits explicitly.
2021-02-10 09:16:58 +01:00
MarcoFalke
faa8afe70b
ci: Re-run wine tests once if they fail 2021-02-10 08:59:35 +01:00
Kiminuo
7a135d57b2 Add EditorConfig file. 2021-02-10 08:00:06 +01:00
fanquake
09530b0255
Merge #21126: ci: Properly bump to focal for win cross build
fa272dfdff ci: Properly bump to focal for win cross build (MarcoFalke)

Pull request description:

  Fixes #21122

ACKs for top commit:
  fanquake:
    ACK fa272dfdff - Looks good to me. I can see the wine version output, `wine-5.0 (Ubuntu 5.0-3ubuntu1)`, in the [log](https://cirrus-ci.com/task/5743559502462976), and `make check` is running.

Tree-SHA512: cd37462afc5512e00cef5e9e7fd1bb5c43c600e833b30cdea2c1c443dc7b0e68f5f2cbaf9d7b655892059af0a226478211db1dc97c10fe4dcdfe666a784f3afc
2021-02-10 09:40:44 +08:00
Wladimir J. van der Laan
d202054675
Merge #21052: refactor: Replace fs::unique_path with GetUniquePath(path) calls
1bca2aa694 Introduce GetUniquePath(base) helper method to replace boost::filesystem::unique_path() which is not available in std::filesystem. (Kiminuo)

Pull request description:

  This PR makes it easier in #20744 to remove our dependency on the `boost::filesystem::unique_path()` function which does not have a direct equivalent in C++17.

  This PR attempts to re-implement `boost::filesystem::unique_path()` as `GetUniquePath(path)` but the implementations are not meant to be the same.

  Note:

  * Boost 1.75.0 implementation of `unique_path`: 9cab675b71/src/unique_path.cpp (L235)

  * In the previous implementation, I attempted to add:
      ```cpp
      fs::path GetUniquePath(const fs::path& base)
      {
          FastRandomContext rnd;
          fs::path tmpFile = base / HexStr(rnd.randbytes(8));
          return tmpFile;
      }
      ```

      to `fs.cpp` but this leads to a circular dependency: "fs -> random -> logging -> fs". That is why the modified implementation adds a new file.

ACKs for top commit:
  laanwj:
    Code review ACK 1bca2aa694
  ryanofsky:
    Code review ACK 1bca2aa694. It's a simple change and extra test coverage is nice

Tree-SHA512: f324bdf0e254160c616b5033c3ece33d87db23eb0135acee99346ade7b5cf0d30f3ceefe359a25a8e9b53ba8e4419f459c2bdd369e10fc0152ce95031d1f221c
2021-02-09 22:22:13 +01:00
MarcoFalke
fa272dfdff
ci: Properly bump to focal for win cross build 2021-02-09 21:37:14 +01:00
MarcoFalke
d48f9e8ebb
Merge #21124: test: remove unnecessary assignment in bdb
c9095b738f test: remove unnecessary assignment in bdb (Bruno Garcia)

Pull request description:

  This PR removes the unnecessary assignment to page_info['entries'] on line 54 since there is another assignment for it in line 59.

  I think a lint (#21096) would detect cases like this one.

ACKs for top commit:
  achow101:
    ACK c9095b738f
  theStack:
    Code Review ACK c9095b738f

Tree-SHA512: 23377077c015b04361fd416b41bf6806ad0bdd4d264be6760f0fd3bc88d694d2cd52cae250519925c5d3b3c70715772714c3863f8fa181a2eb4883204ccdbf9d
2021-02-09 19:21:34 +01:00
Hennadii Stepanov
166266a372
script: Make LXC container size suitable for gitian builds
This change prevents "No space left on device" error.
2021-02-09 18:56:45 +02:00
gzhao408
53e716ea11 [refactor] improve style for touched code 2021-02-09 07:01:52 -08:00
gzhao408
174cb5330a [refactor] const ATMPArgs and non-const Workspace
ATMPArgs should contain const arguments for validation.
The Workspace should contain state that may change
throughout validation.
2021-02-09 07:01:52 -08:00
gzhao408
f82baf0762 [refactor] return MempoolAcceptResult
This creates a cleaner interface with ATMP, allows us to make results const,
and makes accessing values that don't make sense (e.g. fee when tx is
invalid) an error.
2021-02-09 07:01:52 -08:00
Kiminuo
059e8ccc1e Change BOOST_CHECK to BOOST_CHECK_EQUAL to see mismatched values when a check fails.
See https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/boost_test/utf_reference/testing_tool_ref/assertion_boost_level_eq.html
2021-02-09 15:00:02 +01:00
Bruno Garcia
c9095b738f test: remove unnecessary assignment in bdb 2021-02-09 10:22:50 -03:00
Wladimir J. van der Laan
b847f49717
Merge #20557: addrman: Fix new table bucketing during unserialization
4676a4fb5b [addrman] Don't repeat "Bucketing method was updated" log multiple times (John Newbery)
436292367c [addrman] Improve serialization comments (John Newbery)
ac3547eddd [addrman] Improve variable naming/code style of touched code. (John Newbery)
a5c9b04959 [addrman] Don't rebucket new table entries unnecessarily (John Newbery)
8062d928ce [addrman] Rename asmap version to asmap checksum (John Newbery)
009b8e0fdf [addrman] Improve variable naming/code style of touched code. (John Newbery)
b4c5fda417 [addrman] Fix new table bucketing during unserialization (John Newbery)

Pull request description:

  This fixes three issues in addrman unserialization.

  1. An addrman entry can appear in up to 8 new table buckets. We store this entry->bucket indexing during shutdown so that on restart we can restore the entries to their correct buckets. Commit ec45646de9 broke the deserialization code so that each entry could only be put in up to one new bucket.

  2. Unserialization may result in an entry appearing in a 9th bucket. If the entry already appears in 8 buckets don't try to place it in another bucket.

  3. We unnecessarily rebucket when reading a peers.dat with file version 1. Don't do that.

ACKs for top commit:
  vasild:
    ACK 4676a4fb5b
  glozow:
    re-ACK 4676a4fb5b, changes were a rename, comments, and removing repeat-logging.
  naumenkogs:
    ACK 4676a4f
  laanwj:
    Code review ACK 4676a4fb5b
  dhruv:
    ACK 4676a4fb5b
  ryanofsky:
    Code review ACK 4676a4fb5b. I'm not previously familiar with this code but all the changes here do make sense and seem like improvements. Left some notes and comments, but they aren't important so feel to ignore.

Tree-SHA512: b228984f6dec5910be23c3740ae20258da33bcf66ceb7edb10e5a53163450f743bab349e47f09808b7e8d40f27143119ec3e0981d7e678aa494d8559a1c99c23
2021-02-09 12:36:32 +01:00
MarcoFalke
3641ec1aac
Merge #21112: ci: use Focal for macOS cross builds
ac24af453d ci: use Ubuntu Focal for macOS cross build (fanquake)

Pull request description:

  I had assumed Cirrus was spinning up Docker containers to run the CI,
  however we are actaully running on the Cirrus machines themselves. See
  `DANGER_RUN_CI_ON_HOST` and in the logs:
  ```bash
  Running on host system without docker wrapper
  ```

  So with this change we will actually be using Focal for the macOS cross build.

  Follow up to #21036.

  This originally contained Windows changes, and an attempt to get Cirrus running without `DANGER_RUN_CI_ON_HOST`, however that seems non-trival, so Windows changes have been dropped from here for now.

ACKs for top commit:
  MarcoFalke:
    cr ACK ac24af453d

Tree-SHA512: 587ba5acf741bcefecf1bc262fa1177f565ebfa9de56125eca19ed3c7db7b9aabfb96866e9c140681b88cb7015a3ded2bc6b4b1b235543d6f6e9dfc6984d569f
2021-02-09 08:00:33 +01:00
MarcoFalke
19b1ceddc7
Merge #21075: doc: Fix markdown formatting
e1604b3d50 doc: Replace tabs for spaces (Gunar C. Gessner)
98db48d349 doc: Fix markdown formatting (Gunar Gessner)

Pull request description:

  Lines were being joined making it hard to read.

ACKs for top commit:
  RandyMcMillan:
    ACK e1604b3d50

Tree-SHA512: fd5a7c5e9a1cbbf0fbb13b5c30b87853c84751da7f0fad08151bda07f1933872ab51cad29a0c0a70ced48e60df6d83bff3f84c2f77d00d22723fae9a8c3534fc
2021-02-09 07:56:44 +01:00
MarcoFalke
c4214d0e0d
Merge #21117: test: remove assert_blockchain_height
fa0a4d6c60 test: remove assert_blockchain_height (MarcoFalke)

Pull request description:

  This simplifies the code and solves intermittent timeouts caused by commit 0d39b5848a.

  E.g. https://cirrus-ci.com/task/5196092369272832?command=ci#L3126

  ```
   test  2021-02-08T12:27:56.275000Z TestFramework (ERROR): Assertion failed
                                     Traceback (most recent call last):
                                       File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 127, in main
                                         self.run_test()
                                       File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/feature_assumevalid.py", line 180, in run_test
                                         self.assert_blockchain_height(self.nodes[0], 101)
                                       File "/tmp/cirrus-ci-build/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/feature_assumevalid.py", line 92, in assert_blockchain_height
                                         assert False, "blockchain too short after timeout: %d" % current_height
                                     AssertionError: blockchain too short after timeout: 101

ACKs for top commit:
  glozow:
    ACK fa0a4d6c60

Tree-SHA512: 3859b0c1581c21f03c775f119204cc3a219e5d86346883634886f6da46feaf254b9c6c49c1ec4581ffe409cdf05f6e91ec38c3976c3daf4a9e67f96ddc1e0dce
2021-02-09 07:43:47 +01:00
fanquake
a0077a80b0
Merge #21116: build: Disable --disable-fuzz-binary for gitian/guix builds
cb151b797a build: Disable --disable-fuzz-binary for guix builds (Hennadii Stepanov)
fd7caae35f build: Disable --disable-fuzz-binary for gitian builds (Hennadii Stepanov)

Pull request description:

  Fuzz binary is not shipped to users.
  This PR saves hundreds MB of the disk space for containers.

ACKs for top commit:
  MarcoFalke:
    review ACK cb151b797a
  fanquake:
    ACK cb151b797a

Tree-SHA512: 858e3816576c307b47915bb05de79a28029beaef8835c01f1bd6a764a0cf7f7f63ef8c2dc2c5944cb36cc9f4788d9b0590b8a5dda96940167252ba371cdbd078
2021-02-09 14:22:11 +08:00
fanquake
ac24af453d
ci: use Ubuntu Focal for macOS cross build 2021-02-09 13:58:59 +08:00
fanquake
d864696649
Merge #21115: test: Fix Windows cross build
723eb4326b test: Fix Windows cross build (Hennadii Stepanov)

Pull request description:

  On master (e51f6c4dee, after #20936 merge), Windows cross compiling fails:
  ```
  $ make > /dev/null
  In file included from ./policy/fees.h:12,
                   from policy/fees.cpp:6:
  policy/fees.cpp: In member function ‘unsigned int CBlockPolicyEstimator::HighestTargetTracked(FeeEstimateHorizon) const’:
  ./sync.h:232:104: warning: control reaches end of non-void function [-Wreturn-type]
    232 | #define LOCK(cs) DebugLock<decltype(cs)> PASTE2(criticalblock, __COUNTER__)(cs, #cs, __FILE__, __LINE__)
        |                                                                                                        ^
  policy/fees.cpp:680:5: note: in expansion of macro ‘LOCK’
    680 |     LOCK(m_cs_fee_estimator);
        |     ^~~~
  test/fuzz/netaddress.cpp:12:10: fatal error: netinet/in.h: No such file or directory
     12 | #include <netinet/in.h>
        |          ^~~~~~~~~~~~~~
  compilation terminated.
  make[2]: *** [Makefile:13039: test/fuzz/fuzz-netaddress.o] Error 1
  make[2]: *** Waiting for unfinished jobs....
  libtool: warning: undefined symbols not allowed in x86_64-w64-mingw32 shared libraries; building static only
  test/fuzz/string.cpp: In function ‘void string_fuzz_target(FuzzBufferType)’:
  test/fuzz/string.cpp:81:11: error: ‘ShellEscape’ was not declared in this scope
     81 |     (void)ShellEscape(random_string_1);
        |           ^~~~~~~~~~~
  make[2]: *** [Makefile:13543: test/fuzz/fuzz-string.o] Error 1
  make[1]: *** [Makefile:15078: all-recursive] Error 1
  make: *** [Makefile:812: all-recursive] Error 1
  ```

  This PR fixes both of errors.

ACKs for top commit:
  MarcoFalke:
    cr ACK 723eb4326b

Tree-SHA512: 5d2fba5ca806e64bf92011786d1f868c6624f786bfa753a10316feab7a802a28ec27a4bd25fc26dc289a399895a521c3878ffa1efeff0e540c7245cdb8e4942c
2021-02-09 13:48:26 +08:00
MarcoFalke
b09ad737ee
Merge #20944: rpc: Return total fee in getmempoolinfo
fa362064e3 rpc: Return total fee in mempool (MarcoFalke)

Pull request description:

  This avoids having to loop over the whole mempool to query each entry's fee

ACKs for top commit:
  achow101:
    ACK fa362064e3
  glozow:
    ACK fa362064e3 🧸
  jnewbery:
    ACK fa362064e3

Tree-SHA512: e2fa1664df39c9e187f9229fc35764ccf436f6f75889c5a206d34fff473fc21efbf2bb143f4ca7895c27659218c22884d0ec4195e7a536a5a96973fc9dd82d08
2021-02-08 20:36:46 +01:00
MarcoFalke
fa0a4d6c60
test: remove assert_blockchain_height 2021-02-08 16:56:46 +01:00
Hennadii Stepanov
cb151b797a
build: Disable --disable-fuzz-binary for guix builds 2021-02-08 16:41:05 +02:00
Hennadii Stepanov
fd7caae35f
build: Disable --disable-fuzz-binary for gitian builds 2021-02-08 15:38:26 +02:00
Hennadii Stepanov
723eb4326b
test: Fix Windows cross build 2021-02-08 15:17:48 +02:00
MarcoFalke
b401b09355
Merge #21107: test: remove type: comments in favour of actual annotations
9913419cc9 test: remove type: comments in favour of actual annotations (fanquake)

Pull request description:

  Now that we require Python 3.6+, we should be using variable type
  annotations directly rather than `# type:` comments.

  Also takes care of the discarded value issue in p2p_message_capture.py.
  See: https://github.com/bitcoin/bitcoin/pull/19509/files#r571674446.

ACKs for top commit:
  MarcoFalke:
    review ACK 9913419cc9
  jnewbery:
    Code review ACK 9913419cc9

Tree-SHA512: 63aba5eef6c1320578f66cf8a6d85ac9dbab9d30b0d21e6e966be8216e63606de12321320c2958c67933bf68d10f2e76e9c43928e5989614cea34dde4187aad8
2021-02-08 10:56:54 +01:00
MarcoFalke
ca85449f22
Merge #21036: gitian: Bump descriptors to Focal for 22.0
2ecaf21433 gitian: remove execstack workaround for ricv64 & powerpc64le (fanquake)
5baff2b318 build: use focal in gitian descriptors (fanquake)

Pull request description:

  This PR changes the gitian descriptors to use Ubuntu Focal (20.04), over Bionic (18.04), moving from GCC 7.5 to GCC 8.4 for native Linux builds, mingw-w64 GCC 7.3 to mingw-w64 GCC 9.3 for Windows builds, while continuing to use GCC 8.4 for all cross builds and Clang 8.0.0 for macOS builds.

  It also drops the `-Wl,-z,noexecstack` workaround we've been using for the riscv64 and powerpc64le hosts, as it's no-longer needed. One new package is installed in the osx build, `libtinfo5`, as libtinfo5.so is required by our downloaded Clang 8.

  A bump to Focal will at least be required if we want to update to a newer Qt (5.15, #19716) for 22.0, as we need a newer version of [`g++-mingw-w64`](https://packages.ubuntu.com/focal/g++-mingw-w64-x86-64) and the [`mingw-w64`](https://mingw-w64.org/doku.php) headers. This can still be done while continuing to use GCC 8.4 for Linux builds (see below), however the newer `g++-mingw-w64` will be based off of GCC 9.3.

  **Some considerations**

  GCC 9 is affected by #20005 "memcmp with constants that contain zero bytes are broken in GCC", and the newer `g++-mingw-w64` will be based off of GCC 9.3.

  The `--no-*` variants of the Windows linker flags (i.e `--no-dynamicbase`) we use to [test our `security-check.py` script](16b784d953/contrib/devtools/test-security-check.py (L53)) are not patched into the mingw binutils in Focal (they have been re-added in Groovy (20.10)). This isn't currently an issue, however, we might add a call to `test-security-check` for Guix (#20980), and if we wanted to do the same for gitian, it would not work. Note how it's quite "easy" for us to apply the `--no-*` variant patch to our Guix build; it would be quite a bit harder to do in Gitian.

  Gitian Builds @ 2ecaf21433

  #### Linux
  ```bash
  8882ea78486fbae4fac574b9089eb1107c6372d0dd7dfcda4f0f930576f9d6c1  bitcoin-2ecaf214331b-aarch64-linux-gnu-debug.tar.gz
  50a9e30943b4eee5163edff3331241e745ff32a2c4463c21a6fdc5986e2d0383  bitcoin-2ecaf214331b-aarch64-linux-gnu.tar.gz
  ec4e55a447fddf033fee33cd5f22bfeda3c3612f059194bcf6238859f7989d7a  bitcoin-2ecaf214331b-arm-linux-gnueabihf-debug.tar.gz
  444fe1b3b933c00bcbd4a9d86888cff3b61c1215b1debccd2843e842d1224777  bitcoin-2ecaf214331b-arm-linux-gnueabihf.tar.gz
  88e486ff465980dc1a4aab9687d142ec6f727ed2c52cf539f69db2877dee83b2  bitcoin-2ecaf214331b-powerpc64-linux-gnu-debug.tar.gz
  66144ac264c65cada9d86446e6026c85b04fb88198b8f41b42840f6031db3e6c  bitcoin-2ecaf214331b-powerpc64-linux-gnu.tar.gz
  34bcc13d78d929d575e34e77a6672f23ca7ea23230b28ec2eed563889352ba86  bitcoin-2ecaf214331b-powerpc64le-linux-gnu-debug.tar.gz
  b4c5f959664f3063df4330edfe343c17120eb6b556ee1c15c4aeb2c1c54ffd49  bitcoin-2ecaf214331b-powerpc64le-linux-gnu.tar.gz
  918fa72ab6f6ebce4e9663c93f72fe26651c260477cbb54749f7eb61438b5cc1  bitcoin-2ecaf214331b-riscv64-linux-gnu-debug.tar.gz
  f704f9f8c053ffe37d854e2e81e0f4c0614c435dad7f5d82518c681b73a76ae6  bitcoin-2ecaf214331b-riscv64-linux-gnu.tar.gz
  b59e3a62f1df9d79f30e916b3c9655f654036fe3a420040c53acc8dd9f4162c5  bitcoin-2ecaf214331b-x86_64-linux-gnu-debug.tar.gz
  a4dc9ca877cc97544e65db11be38406d16f15d74fcdcd2318bb92474729bc60d  bitcoin-2ecaf214331b-x86_64-linux-gnu.tar.gz
  b40ba2d5da498330ade92a4ccebcceb1452b94c8ffeacb336f87e93b5c88d8af  src/bitcoin-2ecaf214331b.tar.gz
  af6ebc91147778e4e6705eade62608dde4d6e60522d79087fa9129bdb7c01199  bitcoin-core-linux-22-res.yml
  ```

  #### Windows
  ```bash
  121a3970a6911cb8c453b2ce37d03f6cbb43333e29db8fa516c68563fb367f43  bitcoin-2ecaf214331b-win-unsigned.tar.gz
  6294e9efebe935092f9ba119dc60ad4094f18b51c4181324e54d3057524d6101  bitcoin-2ecaf214331b-win64-debug.zip
  5b5a236b63e67f5f6c07ad9aa716aa7b72fb63722c96798b332c6d164738f9cf  bitcoin-2ecaf214331b-win64-setup-unsigned.exe
  c1fa5894c5e02a201637567c80b9bde9024f44673dcd06fd4d489c1709179279  bitcoin-2ecaf214331b-win64.zip
  b40ba2d5da498330ade92a4ccebcceb1452b94c8ffeacb336f87e93b5c88d8af  src/bitcoin-2ecaf214331b.tar.gz
  665fd7eb61aed368150db58a254f15fb5efb51a4efa5abcc52571cb7a1a5de22  bitcoin-core-win-22-res.yml
  ```

  #### macOS
  ```bash
  6a1deae7662aa782baa82a42590f862c6bcdc4f4e38daa9b8c2a9eed1fbb5397  bitcoin-2ecaf214331b-osx-unsigned.dmg
  1ee843266e84928a4323fa255c833528c2617a2c9fd2f98fb26ba19bbfc1227b  bitcoin-2ecaf214331b-osx-unsigned.tar.gz
  097b64dadc167d8e5b733421bf1541a40760ad952990f7cf3f35adc6ae2616d0  bitcoin-2ecaf214331b-osx64.tar.gz
  b40ba2d5da498330ade92a4ccebcceb1452b94c8ffeacb336f87e93b5c88d8af  src/bitcoin-2ecaf214331b.tar.gz
  6e378fb543928e40c7119b96be6ff773d38506a9a888f8b02c7f1b8a0801a80e  bitcoin-core-osx-22-res.yml
  ```

ACKs for top commit:
  laanwj:
    Build script changes review ACK 2ecaf21433

Tree-SHA512: 975d5830b787d2e08988f43cbc6e839294171c1d94c8219636308b05f9b77041421612ae67be24a631674670cfc9c2d96d8177f2b3158a78fc3deea19631febf
2021-02-08 10:44:37 +01:00
MarcoFalke
c969ab43c3
Merge #21084: test: fix timeout decrease in feature_assumevalid
0d39b5848a test: fix timeout decrease in feature_assumevalid (Bruno Garcia)

Pull request description:

  This PR fixes the timeout decrease in assert_blockchain_height function.

ACKs for top commit:
  practicalswift:
    cr ACK 0d39b5848a: patch looks correct
  theStack:
    ACK 0d39b5848a ⏲️

Tree-SHA512: ae3c83420b4de4ad41f1b20b6e77c3a26a8c5ac4fb136b2645fde119545a413c61312f76a16473141774bc955d30ac4fc86e5ca6cf729f8978a17d0dab520feb
2021-02-08 10:38:52 +01:00
MarcoFalke
fac726b1b8
doc: Fixup docs in fuzz/script_assets_test_minimizer.cpp 2021-02-08 10:12:22 +01:00
MarcoFalke
fafca47adc
fuzz: Hide script_assets_test_minimizer
Can be reviewed with --ignore-all-space
2021-02-08 10:11:59 +01:00