Skip to content

Conversation

@Sjors
Copy link
Owner

@Sjors Sjors commented Dec 29, 2023

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.

@Sjors
Copy link
Owner Author

Sjors commented Dec 29, 2023

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.

@Sjors Sjors force-pushed the 2023/12/sv2-transport branch 3 times, most recently from 624f0a5 to 7e89e1b Compare January 5, 2024 16:20
@Sjors Sjors force-pushed the 2023/11/sv2-poll branch from 0b82b7c to 5d47c5a Compare January 8, 2024 20:54
@Sjors Sjors closed this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants