-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
backport: merge bitcoin#21817, #21966, #21824, #21969, #23653, #23438, #24190, #24253, #24231, #26258, #28012, partial bitcoin#25001, #25296, #23595, #27927 (serialization updates) #5901
Conversation
a73a01d
to
b3d204e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
This pull request has conflicts, please rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-utACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
, 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
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::byte
BOOST_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 togrep
for 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::filesystem
usage 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::byte
related, pull requests that are related tostd::byte
serialization were backported andstd::byte
serialization 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,
gdb
is used to step throughserialize_tests
'sclass_methods
and 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
,gdb
loses the ability to do breakpoints by file. So, an attempt is made to uselldb
(which btw, is calledlldb-16
, runninglldb
with 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.yml
needs the following additions:After making these changes,
lldb
works and then we resume trying to findoperator<<
. After too many hours and nimbly alternating betweennext
andstep
, tried making a return togdb
(compiling withgcc
this 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 withclang
and 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.h
thanks to the comment above it.Diffing between Bitcoin and Dash revealed the secret, the
operator<<
definition was placed under namespacestd
by 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
x
in all the boxes that apply.