Reduces complexity in processing of orphans when receiving tx
messages over p2p. and isolate the functionality in its own
function ProcessOrphanTx
Backported from: 9453018f
6e051f3d
Original Author: Pieter Wuille <pieter.wuille@gmail.com>
Removes crosslinking of documentation in favor of a link hierarchy:
- main README.md links to doc/intl/README.md
- doc/intl/README.md links to individual translated documents
This reduces conflicts between translations.
This will allow compiling with the c++17 standard, which on some
distributions (macOS, FreeBSD) is required when using system
dependencies.
The ./configure script will now allow specifying --enable-c++17 to
enable c++17. The default remains c++11, and c++14 also remains
available.
random_shuffle is deprecated since c++11 and removed in c++17. Use
the shuffle function instead, now that we have a standardized
interface available on FastRandomContext.
This enables c++17 compilation
This makes it possible to plug it into the various standard C++11 random
distribution algorithms and other functions like std::shuffle.
Cherry-picked from: 1ec1602a4549f6b68586cead8eff701bceb624f5
-add msvc ssize_t definition in compat.h
-change NUM_OS_RANDOM_BYTES to int from ssize_t in random.h
Includes squashed commit: f7dc99244c8e78dbd0196f612690efcc449c37dc
Inspired by: fbf327b13868861c2877c5754caf5a9816f2603c
change sys/random.h to random.h in AC_MSG_CHECK
remove definitions that are applicable to macos which include unistd.h
additionally change comparator argument from NULL to nullptr when evaluating &getentropy
Inspired by: c13c97dbf846cf0e6a5581ac414ef96a215b0dc6
If the code was compiled with newer (>=3.17) kernel headers but executed
on a system without the system call, every use of random would crash the
program. Add a fallback for that case.
Cherry-picked from: 7e6dcd9995b99e894b8017f09016c405b066ca36
Move the OS random test to a sanity check function that is called every
time bitcoind is initialized.
Keep `src/test/random_tests.cpp` for the case that later random tests
are added, and keep a rudimentary test that just calls the sanity check.
Cherry-picked from: 7cad84929907c4294f07377453aa77887911b486
These are available in sandboxes without access to files or
devices. Also [they are safer and more straightforward](https://en.wikipedia.org/wiki/Entropy-supplying_system_calls)
to use than `/dev/urandom` as reading from a file has quite a few edge
cases:
- Linux: `getrandom(buf, buflen, 0)`. [getrandom(2)](http://man7.org/linux/man-pages/man2/getrandom.2.html)
was introduced in version 3.17 of the Linux kernel.
- OpenBSD: `getentropy(buf, buflen)`. The [getentropy(2)](http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/getentropy.2)
function appeared in OpenBSD 5.6.
- FreeBSD and NetBSD: `sysctl(KERN_ARND)`. Not sure when this was added
but it has existed for quite a while.
Alternatives:
- Linux has sysctl `CTL_KERN` / `KERN_RANDOM` / `RANDOM_UUID`
which gives 16 bytes of randomness. This may be available
on older kernels, however [sysctl is deprecated on Linux](https://lwn.net/Articles/605392/)
and even removed in some distros so we shouldn't use it.
Add tests for `GetOSRand()`:
- Test that no error happens (otherwise `RandFailure()` which aborts)
- Test that all 32 bytes are overwritten (initialize with zeros, try multiple times)
Discussion:
- When to use these? Currently they are always used when available.
Another option would be to use them only when `/dev/urandom` is not
available. But this would mean these code paths receive less testing,
and I'm not sure there is any reason to prefer `/dev/urandom`.
Closes: #9676
Cherry-picked from: 224e6eb089a0f4977d22f3803fc27e44b5e7eea5
Contains squashed commit of aa09ccbb74ea9febd83ce3362238ac5339069909 squashme: comment that NUM_OS_RANDOM_BYTES should not be changed lightly