diff options
author | fanquake <fanquake@gmail.com> | 2023-09-08 10:06:32 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-09-08 10:24:03 +0100 |
commit | 4e1a38c6df91f96ca8a2ef07413ffdb1d59c30cc (patch) | |
tree | b34b18a1ff5cd9d7e1d534951090d75dd5c5eda0 /src/test/bip324_tests.cpp | |
parent | 238d29aff9b43234e340a9cf17742b2be5d1e97d (diff) | |
parent | db9888feec48c6220a2fcf92865503bbbdab02a4 (diff) |
Merge bitcoin/bitcoin#28196: BIP324 connection support
db9888feec48c6220a2fcf92865503bbbdab02a4 net: detect wrong-network V1 talking to V2Transport (Pieter Wuille)
91e1ef8684997fb4b3e8b64ef3935a936445066b test: add unit tests for V2Transport (Pieter Wuille)
297c8889975a18258d6cc39b1ec1e94fed6630fb net: make V2Transport preallocate receive buffer space (Pieter Wuille)
3ffa5fb49ee4a6d9502aa957093bd94058630282 net: make V2Transport send uniformly random number garbage bytes (Pieter Wuille)
0be752d9f8ca27320bc3e82498c7640fabd7e8de net: add short message encoding/decoding support to V2Transport (Pieter Wuille)
8da8642062fa2c7aa2f49995b832c3d0897e37ed net: make V2Transport auto-detect incoming V1 and fall back to it (Pieter Wuille)
13a7f01557272db652b3f333af3f06af6897253f net: add V2Transport class with subset of BIP324 functionality (Pieter Wuille)
dc2d7eb810ef95b06620f334c198687579916435 crypto: Spanify EllSwiftPubKey constructor (Pieter Wuille)
5f4b2c6d79e81ee0445752ad558fcc17831f4b2f net: remove unused Transport::SetReceiveVersion (Pieter Wuille)
c3fad1f29df093e8fd03d70eb43f25ee9d531bf7 net: add have_next_message argument to Transport::GetBytesToSend() (Pieter Wuille)
Pull request description:
This is part of #27634.
This implements the BIP324 v2 transport (which implements all of what the BIP calls transport layer *and* application layer), though in a non-exposed way. It is tested through an extensive fuzz test, which verifies that v2 transports can talk to v2 transports, and v1 transports can talk to v2 transports, and a unit test that exercises a number of unusual scenarios. The transport is functionally complete, including:
* Autodetection of incoming V1 connections.
* Garbage, both sending and receiving.
* Short message type IDs, both sending and receiving.
* Ignore packets (receiving only, but tested in a unit test).
* Session IDs are visible in `getpeerinfo` output (for manual comparison).
Things that are not included, left for future PRs, are:
* Actually using the v2 transport for connections.
* Support for the `NODE_P2P_V2` service flag.
* Retrying downgrade to V1 when attempted outbound V2 connections immediately fail.
* P2P functional and unit tests
ACKs for top commit:
naumenkogs:
ACK db9888feec48c6220a2fcf92865503bbbdab02a4
theStack:
re-ACK db9888feec48c6220a2fcf92865503bbbdab02a4
mzumsande:
Code Review ACK db9888feec48c6220a2fcf92865503bbbdab02a4
Tree-SHA512: 8906ac1e733a99e1f31c9111055611f706d80bbfc2edf6a07fa6e47b21bb65baacd1ff17993cbbf588063b2f5ad30b3af674a50c7bc8e8ebf4671483a21bbfeb
Diffstat (limited to 'src/test/bip324_tests.cpp')
-rw-r--r-- | src/test/bip324_tests.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/test/bip324_tests.cpp b/src/test/bip324_tests.cpp index 04472611ec..1ed7e23bcf 100644 --- a/src/test/bip324_tests.cpp +++ b/src/test/bip324_tests.cpp @@ -38,14 +38,8 @@ void TestBIP324PacketVector( { // Convert input from hex to char/byte vectors/arrays. const auto in_priv_ours = ParseHex(in_priv_ours_hex); - const auto in_ellswift_ours_vec = ParseHex<std::byte>(in_ellswift_ours_hex); - assert(in_ellswift_ours_vec.size() == 64); - std::array<std::byte, 64> in_ellswift_ours; - std::copy(in_ellswift_ours_vec.begin(), in_ellswift_ours_vec.end(), in_ellswift_ours.begin()); - const auto in_ellswift_theirs_vec = ParseHex<std::byte>(in_ellswift_theirs_hex); - assert(in_ellswift_theirs_vec.size() == 64); - std::array<std::byte, 64> in_ellswift_theirs; - std::copy(in_ellswift_theirs_vec.begin(), in_ellswift_theirs_vec.end(), in_ellswift_theirs.begin()); + const auto in_ellswift_ours = ParseHex<std::byte>(in_ellswift_ours_hex); + const auto in_ellswift_theirs = ParseHex<std::byte>(in_ellswift_theirs_hex); const auto in_contents = ParseHex<std::byte>(in_contents_hex); const auto in_aad = ParseHex<std::byte>(in_aad_hex); const auto mid_send_garbage = ParseHex<std::byte>(mid_send_garbage_hex); |