[Core] Migrate uint160 (CKeyID/CScriptID) to opaque blobs#2092
Merged
random-zebra merged 3 commits intoJan 22, 2021
Merged
Conversation
furszy
approved these changes
Dec 21, 2020
Fuzzbawls
approved these changes
Jan 22, 2021
furszy
added a commit
that referenced
this pull request
May 10, 2021
722759d [Refactor] Remove arith_uint256::GetCheapHash() and fix uint256 implem. (random-zebra) a640051 [Refactor] uint256: update GetHex() and SetHex() (random-zebra) bce58ac [Refactor] uint256: raname data --> m_data and make it protected (random-zebra) 4ddd8f1 [BUG] Use arith_uint256 for old modifier's block sorting (random-zebra) b1c0afb [Trivial] Log stake modifier and timeBlockFrom in CheckKernelHash() (random-zebra) ddf0dcb [arith_uint256] Do not destroy *this content if passed-in operator may reference it (Karl-Johan Alm) 8fe19b1 [Refactor] uint256 add missing explicit instantiation for base_blob<512> (random-zebra) 22213ff [Refactor] Migrate uint256.h/.cpp to blob_uint implementation (random-zebra) 957f529 [Refactor] pow/pos: use arith_uint256 for difficulty targets (random-zebra) 9663d99 [Refactoring] GUI/RPC: use uint256S() to construct uint256 from string (random-zebra) b02a67b [Refactor] Use arith_uint256 for masternode ranking computations (random-zebra) 990072e [Refactor] Move trim256 and use arith_uint512 for HashQuark calculations (random-zebra) f8c41ca [Refactor] zerocoin: use arith_uint256 where needed (random-zebra) bce0583 [Refactor] zc ParamGeneration: pass big args by ref and use arith_uint (random-zebra) 6488f24 [Tests] Fix arith in pedersen_hash_/skiplist_/pmt_/transaction_tests (random-zebra) 86e177b [Tests] Replace uint256 tests with blob_uint256 tests (random-zebra) b4a459b [Refactoring] BIP38: init uint from string and use arith where needed (random-zebra) Pull request description: Finally out of an old rabbit hole, started with #1395, #1414, and #2092. As per title, complete the migration: - use `arith_uint*` classes whenever the uint is interpreted as a number - make `uint*` classes child of `base_blob`, and use it everywhere else - remove `blob_uint*` temporary class - update tests ACKs for top commit: furszy: Have been running this since the last rebase and all good, ACK 722759d Fuzzbawls: ACK 722759d Tree-SHA512: cf593243c2f2dbba1a7534cacb7ed261518b4969498dfc703ea875faf87ad94a3ee25eb587aebda225d8617a94301bff5017bb7f00b04d91e0f3e3fbbd04e0f3
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.
Keep going with the migration started in #1395 and #1414.
This time migrate the whole class
uint160, so it is defined as a child ofbase_blob(essentially replaceuint160withblob_uint160), thus migratingCKeyIDandCScriptIDas well.Since opaque blobs (unlike the
arith_uintclasses) have trivial copy-assignment operator, this fixes the "scary"-Wclass-memaccesswarning reported in #2076 (tested before/after patch, with gcc v9.3.0)Bonus: this fixes also a minor bug found along the way: few places where we are checking the result of
boost::get<CKeyID>over the pointedCKeyID, which shouldn't even have abool operator(), and might even be un-initialized (though we always verifyIsValidDestinationbefore, so this is mostly redundant) instead of checking the pointer itself.