backport: merge bitcoin#21817, #21966, #21824, #21969, #23653, #23438, #24190, #24253, #24231, #26258, #28012, partial bitcoin#25001, #25296, #23595, #27927 (serialization updates)#5901
Merged
PastaPastaPasta merged 17 commits intodashpay:developfrom Feb 28, 2024
Conversation
5 tasks
a73a01d to
b3d204e
Compare
|
This pull request has conflicts, please rebase. |
PastaPastaPasta
approved these changes
Feb 28, 2024
Member
PastaPastaPasta
left a comment
There was a problem hiding this comment.
utACK for merging via merge commit
this is required to prevent the tests introduced in bitcoin#27927 from failing to compile because boost::has_left_shift<std::ostream,T>::value returns false for the std::byte specialization, resulting in a static assertion failure in Boost.Test this change was introduced in f7086fd in bitcoin#23497
…, Allow std::byte serialization
731d28a to
2b26a87
Compare
PastaPastaPasta
added a commit
that referenced
this pull request
Mar 6, 2024
, bitcoin#28267, bitcoin#28374, bitcoin#28100 (p2p primitives) b60c493 merge bitcoin#28100: more Span<std::byte> modernization & follow-ups (Kittywhiskers Van Gogh) c2aa01c merge bitcoin#28374: python cryptography required for BIP 324 functional tests (Kittywhiskers Van Gogh) 7c5edf7 merge bitcoin#28267: BIP324 ciphersuite follow-up (Kittywhiskers Van Gogh) 1b1924e merge bitcoin#28008: BIP324 ciphersuite (Kittywhiskers Van Gogh) ff54219 merge bitcoin#27993: Make poly1305 support incremental computation + modernize (Kittywhiskers Van Gogh) d7482eb merge bitcoin#27985: Add support for RFC8439 variant of ChaCha20 (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Dependent on #5900 * Dependent on #5901 * Without modifications, tests introduced in [bitcoin#28008](bitcoin#28008) will fail due to salt comprising of a fixed string (`bitcoin_v2_shared_secret`) and network bytes ([source](https://github.com/sipa/bitcoin/blob/1c7582ead6e1119899922041c1af2b4169b0bc74/src/bip324.cpp#L39-L40)). Bitcoin uses [`{0xf9, 0xbe, 0xb4, 0xd9}`](https://github.com/sipa/bitcoin/blob/1c7582ead6e1119899922041c1af2b4169b0bc74/src/kernel/chainparams.cpp#L114-L117) for mainnet while Dash uses [`{0xbf, 0x0c, 0x6b, 0xbd}`](https://github.com/dashpay/dash/blob/37f43e4e56de0d510110a7f790df34ea77748dc9/src/chainparams.cpp#L238-L241). * The replacement parameters are generated by: * Cloning https://github.com/bitcoin/bips (as of this writing, at bitcoin/bips@b3701fa) * Editing `bip-0324/reference.py` * Changing `NETWORK_MAGIC` to Dash's network magic * Running `gen_test_vectors.py` to get a new `packet_encoding_test_vectors.csv` * Using [this python script](https://github.com/bitcoin/bitcoin/blob/1c7582ead6e1119899922041c1af2b4169b0bc74/src/test/bip324_tests.cpp#L174-L196) mentioned in a comment in `src/test/bip324_tests.cpp`, generate the values that will be used to replace the ones in `bip324_tests.cpp` (it will print to `stdout` so it's recommended to pipe it to a file) * Paste the new values over the old ones ## Breaking Changes None. Changes are restricted to BIP324 cryptosuite, tests and associated logic. ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)** - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ Top commit has no ACKs. Tree-SHA512: bb056de8588026adae63e78d56878274ff3934a439e2eae81606fa9c0a37dab432a129315bb9c1b754400b5c883bf460eea3a0c857a3be0816c8fbf55c479843
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.
Additional Information
Dependency for backport: merge bitcoin#27985, #27993, #28008, #28267, #28374, #28100 (p2p primitives) #5902
bitcoin#24231 is merged after bitcoin#24253 due to a MinGW bug (comment)
bitcoin#25001 is listed as unmerged despite being committed upstream as bitcoin@132d5f8
bitcoin#25296 is listed as unmerged despite being committed upstream as bitcoin@79e007d
bitcoin#21966 was partially backported in dash#4197 as f946c68, including only 2be4cd9.
The excluded commits have been backported, marking the pull request as fully merged.
bitcoin#23438 was partially backported in dash#5574 as de54b87, including only fa65bbf.
The excluded commits have been backported, marking the pull request as fully merged.
bitcoin#27927 opened a fresh can of hell thanks to being (possibly?) the first pull request to include
std::byteBOOST_CHECK's to the unit test suite. For reasons still unbeknownst to me, it refused to compile, despite being perfectly happy when checked-out as a commit directly and built as-is from upstream.The compile error was like this (edited for brevity):
No such error was present on Bitcoin.
It is true, that no
std::ostream& operator<<(std::ostream& a, const std::byte& b)is present by default but attempting togrepfor any specializations didn't show anything relevant that Dash didn't have. Searching on GitHub didn't help either.Then, assuming that perhaps Boost's assertion logic may have changed, upgraded the version of Boost to match the pull request at the time, Boost 1.81. That also did not do anything (and actually, caused a trailing slashes unit test to fail but doesn't cause any problem in Bitcoin because they got rid of their
boost::filesystemusage by then).If that isn't it, then let's try building Bitcoin with Dash's depends. It built successfully, ran successfully. The problem isn't in the dependency, it's in the codebase.
Since it seemed to be
std::byterelated, pull requests that are related tostd::byteserialization were backported andstd::byteserialization related changes needed for dash#5902 were cherry-picked. That's why this pull request came to be. But it didn't help this particular issue (though it did smooth out the cherry-picks).Running out of ideas,
gdbis used to step throughserialize_tests'sclass_methodsand understand whyBOOST_CHECK_EQUAL(out.at(0), std::byte{'a'});is valid in Bitcoin but not Dash by finding the elusiveoperator<<. This is where things go from bad to worse.Turns out, when you build with
clang,gdbloses the ability to do breakpoints by file. So, an attempt is made to uselldb(which btw, is calledlldb-16, runninglldbwith yield an error if you're using the develop container) and it refuses to work, erroringpersonality set failed: Operation not permitted.Turns out, the
docker-compose.ymlneeds the following additions:After making these changes,
lldbworks and then we resume trying to findoperator<<. After too many hours and nimbly alternating betweennextandstep, tried making a return togdb(compiling withgccthis time with the appropriateCXXFLAGS) hoping for different results and a while later, realized that it cannot step through Boost's headers (it doesn't recognize the filenames) and then recompile it withclangand return tolldb.This was a wild goose chase.
After a lot of futile efforts to find the operator by stepping through
BOOST_CHECK_EQUAL, a basic example addressing the static assertion (that a left shift operator must exist of<type>(herestd::byte) forstd::ostream) was added instd::ostream& ostr = std::cout; ostr << std::byte{'a'};...and it compiled in both codebases.
So the left shift that Boost is asserting doesn't exist does exist but it isn't being detected for some reason. Upon hovering the
<<, VSCode highlighted the source of the definition assetup_common.hthanks to the comment above it.Diffing between Bitcoin and Dash revealed the secret, the
operator<<definition was placed under namespacestdby bitcoin#23497 in bitcoin@f7086fd (see change).That change has now been made in a separate commit.
Breaking Changes
Changes in serialization APIs will make backports predating bitcoin#23438 annoying but will not change how data is stored on disk.
Checklist:
Go over all the following points, and put an
xin all the boxes that apply.