Ports of Core's PR 7888, 8166, 8914#1004
Merged
Merged
Conversation
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`.
c2715d3 Do not shadow local variables (Pavel Janík)
| { | ||
| item_ptr(size() - 1)->~T(); | ||
| _size--; | ||
| erase(item_ptr(new_size), end()); |
Collaborator
There was a problem hiding this comment.
shouldn't _size be set to new_size?
EDIT: nevermind, happens inside the erase() member function
sickpig
added a commit
to sickpig/BitcoinUnlimited
that referenced
this pull request
Jun 15, 2018
The latter definition was introduced by PR BitcoinUnlimited#1004, the former (SipHash) since commit 77deb4e was introduced (rel bucash 1.1.2.0)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This a start to get our QA framework up-to-date importing enhancements made by Core on functional and unut tests frameworks.
Port Core's #8914: Kill insecure_random and associated global state
Port Core's #7888: prevector: fix 2 bugs in currently unreached code paths
Port Core's #8166: src/test: Do not shadow local variables