Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #177 conflictions fix #197

Open
wants to merge 133 commits into
base: rel-1.9.0
Choose a base branch
from

Conversation

wqking
Copy link
Collaborator

@wqking wqking commented Nov 11, 2021

No description provided.

KolbyML and others added 30 commits May 6, 2020 13:06
This includes some improvements and fixes for the CMake build system.

* Use explicit per-target includes instead of global includes for dependencies.
* Don't assume the availability of optional dependencies.
* Fix Ubuntu build issues relating to endian/byteswap.
* Ignore the qt subdir for windows WSL based builds.
* Add TravisCI stage to test CMake builds.

Windows support is still a work in progress, with the qt subdir being ignored
due to an issue with CMake linking against a static Qt library.

CMake Builds on TravisCI are allowed to fail for the time being.
Requires VcXsrv for running of resulting builds.
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: bitcoin#9676
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.
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.
There are only a few uses of `insecure_random` outside the tests.
This PR replaces uses of insecure_random (and its accompanying global
state) in the core code with an FastRandomContext that is automatically
seeded on creation.

This is meant to be used for inner loops. The FastRandomContext
can be in the outer scope, or the class itself, then rand32() is used
inside the loop. Useful e.g. for pushing addresses in CNode or the fee
rounding, or randomization for coin selection.

As a context is created per purpose, thus it gets rid of
cross-thread unprotected shared usage of a single set of globals, this
should also get rid of the potential race conditions.

- I'd say TxMempool::check is not called enough to warrant using a special
  fast random context, this is switched to GetRand() (open for
  discussion...)

- The use of `insecure_rand` in ConnectThroughProxy has been replaced by
  an atomic integer counter. The only goal here is to have a different
  credentials pair for each connection to go on a different Tor circuit,
  it does not need to be random nor unpredictable.

- To avoid having a FastRandomContext on every CNode, the context is
  passed into PushAddress as appropriate.

There remains an insecure_random for test usage in `test_random.h`.
FastRandomContext now provides all functionality that the real Rand* functions
provide.
Fuzzbawls and others added 30 commits May 6, 2020 13:08
Move the two CMake build tests further up in the test order so we don't
have to manually restart them due to caching/timeouts.
to check balances in a reorganization of PoS blocks, and verify that the
input of an orphan block's coinstake is spendable after.
…mpool check code cleanup in IsTrusted method.

 Comes from bitcoin b2b3619
- qualify as constants the arguments of CWallet's functions:
IsLockedCoin, LockCoin and UnlockCoin.

- Diagnose unsuitable outputs in lockunspent (backports bitcoin/bitcoin
bitcoin#11087)
… the tip, preventing possible multi-threading shared resource problem.

Remove duplicated tip check.
When the build number (CLIENT_VERSION_BUILD) is non-zero, we want
to include that in the package version number so the resulting binaries
are named with the correct version.
# Conflicts:
#	src/Makefile.am
#	src/crypto/common.h
#	src/main.cpp
#	src/masternode.cpp
#	src/miner.cpp
#	src/primitives/block.h
#	src/qt/walletview.cpp
#	src/rpc/masternode-budget.cpp
#	src/spork.cpp
#	src/spork.h
#	src/test/benchmark_zerocoin.cpp
#	src/version.h
#	src/wallet/crypter.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.