14570 Commits

Author SHA1 Message Date
chromatic
d099258fdc
Merge pull request #3568 from patricklodder/net/inv-buffer
p2p: reduce amount of getheaders sent per inv
2024-07-07 16:55:23 -07:00
chromatic
63d2d8a2d7
Merge pull request #3567 from patricklodder/bugfix/timedata
bugfix: avoid the use of abs in time data
2024-07-07 16:55:10 -07:00
Patrick Lodder
cedbbeba96
p2p: enforce cs_main lock when requesting headers 2024-07-03 14:01:44 -04:00
Patrick Lodder
3e64e6f226
p2p: Only send a getheaders for one block in an INV
Headers-first is the primary method of announcement on the network.
If a node fell back sending blocks by inv, it's probably for a
re-org. The final block hash provided should be the highest, so
send a getheaders and then fetch the blocks we need to catch up.

Backported from: 74673663
Original Author: John Newbery <john@johnnewbery.com>
2024-07-03 14:01:36 -04:00
Patrick Lodder
846812cdde
cleanup: remove BOOST_FOREACH from timedata.cpp 2024-07-03 12:35:17 -04:00
Pieter Wuille
f88f9ddee2
Avoid the use of abs64 in timedata
Cherry-picked from: d1292f25
2024-07-03 12:16:46 -04:00
Old Dip Tracker
962b0205f4
Merge pull request #3194 from thisiskeanyvy/master
Translation and addition of the README.md file in French
2024-06-29 16:30:52 +02:00
thisiskeanyvy
a9e6621935
Translation and addition of the README.md file in French (fr/README.md) 2024-06-28 00:04:47 +02:00
chromatic
2a16b17825
Merge pull request #3459 from patricklodder/1.15.0-organize-intl-docs
Organize internationalized documentation
2024-06-25 17:12:30 -07:00
chromatic
fdf534c133
Merge pull request #3561 from patricklodder/compat/std17
build: allow c++17 standard to be used for compilation
2024-06-25 06:59:28 -07:00
Old Dip Tracker
929078f842
Merge pull request #3514 from chromatic/1.15.0-rename-qa-dogecoin-constants
Change Bitcoin to Dogecoin in qa/ files
2024-06-25 02:55:06 +02:00
Patrick Lodder
09f92efee3
doc: hierarchical link international docs
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.
2024-06-24 13:29:19 -04:00
Patrick Lodder
268a412a9b
doc: move internationalized docs 2024-06-24 13:29:18 -04:00
Patrick Lodder
83af7b3b6e
doc: Organize documentation internationalization 2024-06-24 13:29:18 -04:00
chromatic
e2b3c7eabb
Merge pull request #3393 from patricklodder/1.14.7-blockstats-dust
Add dust metrics to getblockstats
2024-06-23 18:11:16 -07:00
Patrick Lodder
4196748d27
build: allow c++17 standard to be used for compilation
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.
2024-06-23 17:51:52 -04:00
chromatic
1cabf8dfb1 Change Bitcoin to Dogecoin in qa/ files
This changes all occurrences of `BITCOIN` to `DOGECOIN` and `bitcoind`
to `dogecoind` in all files in `qa/`. It does not change copyright
information.
2024-06-22 09:07:27 -07:00
chromatic
5bbb1fa1d8
Merge pull request #3557 from patricklodder/doc/security
doc: add security policy
2024-06-22 08:58:12 -07:00
chromatic
2e37a3a1ba
Merge pull request #3560 from patricklodder/compat/shuffle
random: use std::shuffle instead of std::random_shuffle
2024-06-22 00:13:50 -07:00
Patrick Lodder
caa79bd1a1
random: use std::shuffle instead of std::random_shuffle
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
2024-06-20 10:32:21 -04:00
Old Dip Tracker
da22f3312d
Merge pull request #3521 from xanimo/1.15.0-dev-next-random-pre-14955
backport: random.h/.cpp cherry-picks
2024-06-20 15:20:35 +02:00
Pieter Wuille
47b48521bb
Make FastRandomContext support standard C++11 RNG interface
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
2024-06-18 16:38:09 -07:00
Aaron Clauson
3606c85c7d
Minimal code changes to allow msvc compilation.
-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
2024-06-18 16:06:52 -07:00
Dag Robole
90d1972d81
Fix resource leak
Cherry-picked from: a8ae0b252a2007568e77f5aca1c7fa3ec5941b72
2024-06-18 15:19:51 -07:00
Pieter Wuille
60bd389823
Use rdrand as entropy source on supported platforms
Includes squashed commits:
5155d1101eb4fc9d4d797b583bb29f71807bd10b
a9e82f6512662054f64ed2bde590b2bb0831fc9d
674848fe1c43fb88870cf5ba16fca4e2524da793

Cherry-picked from: cb24c8539d1098d1a61605b452ecfa11a693320d
2024-06-18 15:19:25 -07:00
Pieter Wuille
23bc7a072e
Use sanity check timestamps as entropy
Cherry-picked from: 2c0a6f157da3c6bb3b0a1e77f003caf0d9cb9d6c
2024-06-18 14:37:52 -07:00
Pieter Wuille
4a3c6ddc11
Test that GetPerformanceCounter() increments 2024-06-18 14:37:51 -07:00
Pieter Wuille
930acbfe49
Use hardware timestamps in RNG seeding 2024-06-18 14:37:44 -07:00
Old Dip Tracker
5ac4640a48
Merge pull request #3511 from xanimo/1.15.0-dev-91e3035-10321
backport: Use FastRandomContext for all tests
2024-06-15 15:26:16 +02:00
xanimo
d693d4a008
random: getentropy on macOS does not need unistd.h
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
2024-06-13 11:44:33 -07:00
James Hilliard
743c3acd3d
Check if sys/random.h is required for getentropy on OSX.
Cherry-picked from: ee2d10ad0c0e04d0b9da4535a6fff265ac2501e5
2024-06-13 11:42:50 -07:00
Pieter Wuille
265f258540
scripted-diff: Use new naming style for insecure_rand* functions
-BEGIN VERIFY SCRIPT-
sed -i 's/\<insecure_randbits(/InsecureRandBits(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randbool(/InsecureRandBool(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randrange(/InsecureRandRange(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randbytes(/InsecureRandBytes(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_rand256(/InsecureRand256(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_rand(/InsecureRand32(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<seed_insecure_rand(/SeedInsecureRand(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
-END VERIFY SCRIPT-

Cherry-picked from: e945848582160b23fa0bc6f797e2bd8ac676ee0e
2024-06-13 11:42:49 -07:00
Pieter Wuille
7abc3c6c6d
scripted-diff: Use randbits/bool instead of randrange where possible
-BEGIN VERIFY SCRIPT-
sed -i 's/insecure_randbits(1)/insecure_randbool()/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(2)/insecure_randbool()/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(4)/insecure_randbits(2)/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(32)/insecure_randbits(5)/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(256)/insecure_randbits(8)/g' src/test/*_tests.cpp
-END VERIFY SCRIPT-

Cherry-picked from: 2fcd9cc86bfce944e3312e9a24685403250f3bdc
2024-06-13 11:42:49 -07:00
Pieter Wuille
046cbb0091
Use randbits instead of ad-hoc emulation in prevector tests
Cherry-picked from: 2ada67852174a76753080d65a7adbe27241a9caa
2024-06-13 11:42:49 -07:00
Pieter Wuille
9fa9876e4c
Replace rand() & ((1 << N) - 1) with randbits(N)
Cherry-picked from: 5f0b04eedc5bbdb9319c9f1f1a6c599337f5bbe3
2024-06-13 11:42:48 -07:00
Pieter Wuille
a36981dec6
Replace more rand() % NUM by randranges
Cherry-picked from: 3ecabae36364e905e7821fba3e60aa7f8418de6c
2024-06-13 11:42:48 -07:00
Pieter Wuille
fe5b701634
scripted-diff: use insecure_rand256/randrange more
-BEGIN VERIFY SCRIPT-
sed -i "s/\<GetRandHash(/insecure_rand256(/" src/test/*_tests.cpp
sed -i "s/\<GetRand(/insecure_randrange(/" src/test/*_tests.cpp src/test/test_bitcoin.cpp
sed -i 's/\<insecure_rand() % \([0-9]\+\)/insecure_randrange(\1)/g' src/test/*_tests.cpp
-END VERIFY SCRIPT-

Cherry-picked from: efee1db21a652019e0ab18fffc233d91bb7f1816
2024-06-13 11:42:48 -07:00
Pieter Wuille
2ee602e3ce
Add various insecure_rand wrappers for tests
Cherry-picked from: 1119927df03c94f9306e4d92f55d147b900522fb
2024-06-13 11:42:47 -07:00
Pieter Wuille
9feb51fe9d
Merge test_random.h into test_bitcoin.h
Cherry-picked from: 124d13a58cdcd9f66eeffc7e6281e3eb129e3398
2024-06-13 11:42:47 -07:00
Pieter Wuille
a8cad7ed4c
Add FastRandomContext::rand256() and ::randbytes()
FastRandomContext now provides all functionality that the real Rand* functions
provide.

Cherry-picked from: 37e864eb9fee4b592bd61c5ec3555b00a2de2cf7
2024-06-13 11:42:47 -07:00
Pieter Wuille
3f511675be
Add a FastRandomContext::randrange and use it
Cherry-picked from: 4fd2d2fc97e21efceab849576e544160fd5e3e3d
2024-06-13 11:42:46 -07:00
Pieter Wuille
b2dc5e349b
Switch FastRandomContext to ChaCha20
Cherry-picked from: 16329224e70d0525208f6b0ba00c5e1531a4f5ea
2024-06-13 11:42:46 -07:00
Wladimir J. van der Laan
74888ca567
random: Add fallback if getrandom syscall not available
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
2024-06-13 11:42:46 -07:00
Wladimir J. van der Laan
18a8fd4506
sanity: Move OS random to sanity check function
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
2024-06-13 11:42:45 -07:00
Wladimir J. van der Laan
f75d5ea728
util: Specific GetOSRandom for Linux/FreeBSD/OpenBSD
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
2024-06-13 11:42:45 -07:00
Pieter Wuille
e25cad0012
Add ChaCha20
Cherry-picked from: e04326fe6652543dc26d90eba4a48fbdc935fd0c
2024-06-13 11:42:45 -07:00
Pieter Wuille
6ec0fe4acb
FastRandom benchmark
Cherry-picked from: 663fbae7776b0c238f6f27d73811b4bc627d0b6b
2024-06-13 11:42:44 -07:00
Pieter Wuille
cab3eb10ab
Introduce FastRandomContext::randbool()
Cherry-picked from: c21cbe61c6249bcfca098705df6f9b4baab9f296
2024-06-13 11:42:44 -07:00
Old Dip Tracker
0879cb86e7
Merge pull request #3529 from mazyaryousefinia/master
fix: update Persian readme
2024-06-12 13:38:28 +02:00
Patrick Lodder
0d2ce0a1e8
doc: add security policy with contacts 2024-06-11 01:36:51 -04:00