-
Notifications
You must be signed in to change notification settings - Fork 37
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
addrman fixes #59
addrman fixes #59
Conversation
…ency with original SHA256 algorithms - this now produces the same hashes as bitcoin's CHashWriter's GetCheapHash function
…tion behaviour is consistent with expected results
…atest in bitcoin core master
Great Job. |
… on par with bitcoin core
…ond parameter was responsible for erroneous nTime being passed as a test before evict param. Addrman tests now pass
I understand that there's a general policy to use keccak for hashing; however, the algorithms used in addrman are not for generating public-facing hashes of addresses; the change I made applies specifically to the logic selecting buckets for addresses, which must be performed in a predictable way. The implementation in bitcoin core works well for this, and the scattergun change that was made to this was of zero benefit, and some detriment. Please note that the changes here do not alter the use of keccak in any role associated with address or other data hashing in the blockchain. It is purely an internal implementation detail of addrman, that should never have been allowed to be broken to begin with. |
Note that we would not accept this PR. It doesn't bring value to us because it used a Hash algorithm that is not meant for this purpose(BGL). |
Your response does not make much sense to me. My solution uses precisely the hash algorithm intended for this purpose, as written by the Bitcoin developers who created addrman, with the intention of correctly balancing the address buckets. In fact, an unrelated algorithm had been inserted in its place by a previous contributor - this change failed the bucket balance tests, and rightly so, because that implementation was broken and inappropriate for this use case. My change repairs the implementation, in line with the Bitcoin core codebase algorithms, and achieves your stated aim - "We want to be as close as possible to Bitcoin codebase.". As a result, the tests all pass. As discussed at #52 (comment), if you insist on the alternative - taking a broken algorithm, and changing the tests so they pass it, instead of fixing the algorithm so the (already valid) tests pass - then I can do this, but please confirm you are authorised by the project's stakeholders to mandate such a decision; especially considering the security implications of altering the bucket-balancing algorithm in addrman. |
Description
Addrman tests currently fail for a number of reasons. This PR addresses them, repairing the underlying functionality as much as possible, while keeping tests as consistent with Bitcoin Core as possible, for easier maintenance in future.
Please note this PR is targeted against the janus/release-0.1.7 branch, not master.
This PR fixes all addrman issues, enabling the
addrman_tests
test suite to pass. Run the test suite withsrc/test/test_BGL --log_level=all --run_test=addrman_tests -- DEBUG_LOG_OUT
Changes:
CheapHash
back to SHA256 to provide a consistent backwards-compatible algorithm for bucket selection.CheapHash
implementation to be consistent with the algorithm used in bitcoin core, so addrman bucket selection behaviour is consistent with expected probabilities and results. This is important, as addrman's stochastic bucket selection depends on a consistently applied hash mechanism, and the arbitrary change to switch to Keccak and then create a new untested hash algorithm (rightly) broke tests, while providing zero benefit.Good()
function to always test before evict; this was the cause of a crucial bug. Accepting a bool as a second parameter meant that in at least one case, an nTime was passed to the function in the bool slot by mistake, which led to entries not being evicted when they should have - this was tested for by the evictionworks test.Test status updated progressively in comments below.
BTC/BGL PR reward address
ETH/USDT: 0x50b92AB67A3D3DE8c3506D9287893D9a52655486