You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces Sv2Transport, a new subclass of Transport.
It's most similar to V2Transport, though with a simpler state machine.
In order to make it easier in the future to move the Stratum v2 integration to its own process, this PR also moves Transport out of net.h and makes it part of bitcoin-common.
This also makes for a nice decluttering of net.{h,cpp}, and useful for utilities that need a one-shot p2p connection, e.g. to fetch a specific block.
It would also allow the wallet to make a one-shot tor connection to broadcast a transaction without going through the node mempool. Though this would require a lot more changes.
Once the Sv2Transport class in this PR works, and the Template Provider switched to use it, I plan to rewrite the history of the main PR bitcoin#28983. The move-only commits should not change in that process.
CI on my fork can be ignored (I wonder if I can just turn it off).
In terms of progress, I'm half-way the handshake phase. Next step is implement Act 2 of the handshake, which should be a simple call to WriteMsgES of Sv2HandshakeState m_handshake_state; and updating the cipher like Sv2NoiseSession::ProcessMaybeHandshake does. The test harness can already write it, just needs to read it.
The next challenge is actual message parsing / serialising. The Transport abstract class converts between Span<const uint8_t> and CNetMessage / CSerializedNetMsg, while sv2_messages.h introduces Sv2NetMsg with its own serialisation. I'll have to study both in more detail to figure out if Sv2NetMsg can be made into a subclass of CNetMessage, or if there's another approach.
Finally, the Sv2TemplateProvider comes with its own SendBuf and GenerateWaitSockets. This has a lot of overlap with CConnman in net.h, but CConnman has too much p2p specific stuff to be used as a whole. I might therefore extract its socket handling code into another class.
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
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.
This PR introduces
Sv2Transport, a new subclass ofTransport.It's most similar to
V2Transport, though with a simpler state machine.In order to make it easier in the future to move the Stratum v2 integration to its own process, this PR also moves
Transportout ofnet.hand makes it part ofbitcoin-common.This also makes for a nice decluttering of net.{h,cpp}, and useful for utilities that need a one-shot p2p connection, e.g. to fetch a specific block.
It would also allow the wallet to make a one-shot tor connection to broadcast a transaction without going through the node mempool. Though this would require a lot more changes.
Once the
Sv2Transportclass in this PR works, and the Template Provider switched to use it, I plan to rewrite the history of the main PR bitcoin#28983. The move-only commits should not change in that process.