Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Jun 25, 2024

Based on #30315 and #30205, parent PR #29432.

This PR introduces Sv2Connman which is somewhat similar to CConnman. It uses the Sv2Transport introduced in #30315 to enable incoming connections from other Stratum v2 roles.

It's main target user is the Template Provider role introduced in #29432.

There may be other Stratum v2 roles we want to support in the future.

A remaining issue is that the code in ThreadSv2Handler reuses a lot of code from CConnman::SocketHandlerConnected. I'd like to find a way to extract this common functionality and put it somewhere else.

TODO:

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 25, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #30205 (test: add mocked Sock that can read/write custom data and/or CNetMessages by vasild)
  • #26812 (test: add end-to-end tests for CConnman and PeerManager by vasild)
  • #26697 (logging: use bitset for categories by LarryRuane)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/26648048745

ryanofsky added a commit that referenced this pull request Jun 27, 2024
…t rpc bug fix

a74b0f9 Have testBlockValidity hold cs_main instead of caller (Sjors Provoost)
f6dc6db refactor: use CHECK_NONFATAL to avoid single-use symbol (Sjors Provoost)
5fb2b70 Drop unneeded lock from createNewBlock (Sjors Provoost)
75ce763 refactor: testBlockValidity make out argument last (Sjors Provoost)
83a9bef Add missing include for mining interface (Sjors Provoost)

Pull request description:

  Followups from #30200

  Fixes:
  - `std::unique_ptr` needs `#include <memory>` (noticed while working on #30332, which has fewer includes than its parent PR that I originally tested with)
  - Drop lock from createNewBlock that was spuriously added
  - Have testBlockValidity hold cs_main instead of caller (also fixes a race condition in test-only code)

  Refactor:
  - Use CHECK_NONFATAL to avoid single-use symbol (refactor)
  - move output argument `state` to the end of `testBlockValidity`, see #30200 (comment)

ACKs for top commit:
  AngusP:
    Code Review ACK a74b0f9
  itornaza:
    Tested ACK a74b0f9
  ryanofsky:
    Code review ACK a74b0f9. Just new error string is added since last review, and a commit message was updated

Tree-SHA512: 805e133bb59303fcee107d6f02b3e2761396c290efb731a85e6a29ae56b4b1b9cd28ada9629e979704dcfd98cf35034e7e6b618e29923049eb1eca2f65630e41
@Sjors Sjors force-pushed the 2024/06/sv2_connection branch 2 times, most recently from 5dd22ee to b0b4851 Compare June 28, 2024 15:23
@Sjors Sjors force-pushed the 2024/06/sv2_connection branch from b0b4851 to 10e8373 Compare July 1, 2024 15:28
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 1, 2024

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/26898716492

@Sjors Sjors force-pushed the 2024/06/sv2_connection branch from 10e8373 to 45908be Compare July 2, 2024 08:21
@DrahtBot DrahtBot removed the CI failed label Jul 2, 2024
@glozow glozow added the Mining label Jul 2, 2024
@Sjors Sjors force-pushed the 2024/06/sv2_connection branch 3 times, most recently from 1bef7f4 to 441b081 Compare July 2, 2024 18:37
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 2, 2024

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the
documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin/bitcoin/runs/26955543098

@Sjors Sjors force-pushed the 2024/06/sv2_connection branch from 441b081 to 4cc9cfe Compare July 2, 2024 18:49
@Sjors Sjors changed the title Stratum v2 connectivity Stratum v2 connman Jul 2, 2024
@Sjors Sjors force-pushed the 2024/06/sv2_connection branch from c1509ca to a3a0637 Compare July 11, 2024 10:35
@Sjors Sjors force-pushed the 2024/06/sv2_connection branch from a3a0637 to 0459ea8 Compare July 11, 2024 14:14
@TheBlueMatt
Copy link
Contributor

This seems like a lot of additional code that is very Sv2-specific. Is there no way to DRY a lot of this code up with connman itself? @pinheadmz may also have some thoughts here as I believe he's looking at replacing libevent with stuff that uses the common Core socket code anyway.

@Sjors
Copy link
Member Author

Sjors commented Jul 11, 2024

DRY a lot of this code up with connman itself?

Yes, I think the key is to make the copy-pasted parts of CConnman::SocketHandlerConnected reusable.

@pinheadmz
Copy link
Member

I am working on a libevent-replacing HTTP server using netbase primitives and yeah, I have some functions that look a lot like the sv2connamn in this branch.

I think it would be cool if possible to abstract the mechanisms in ThreadSocketHandler to work on "abstract clients" and I'd be happy to review and collaborate on that.

@Sjors
Copy link
Member Author

Sjors commented Jul 15, 2024

Removed the accidentally included src/common/sv2_messages.cpp.

@Sjors Sjors force-pushed the 2024/06/sv2_connection branch from 04e89ba to 648f793 Compare July 17, 2024 07:19
@Sjors
Copy link
Member Author

Sjors commented Jul 17, 2024

Now using mock sockets #30205, thanks @vasild!

Sjors and others added 10 commits July 19, 2024 09:00
Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
This commit adds the simplest stratum v2 message. The remaining messages are introduced in later commits.

Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
This allows us to subclass Transport.
Implemented starting from a copy of V2Transport and the V2TransportTester, modifying it to fit Stratum v2 and Noise Protocol requirements.

Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
Co-Authored-By: Fi3
Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
…lass

This allows reusing them in other mocked implementations.

Also move the implementation (method definitions) to
`test/util/net.cpp` to make the header `test/util/net.h` easier to follow.
…o it

And also allows gradually providing the data to be returned by `Recv()`
and sending and receiving net messages (`CNetMessage`).
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
@Sjors Sjors force-pushed the 2024/06/sv2_connection branch from 648f793 to 3cf779b Compare July 19, 2024 07:10
@Sjors Sjors mentioned this pull request Jul 19, 2024
3 tasks
@Sjors
Copy link
Member Author

Sjors commented Jul 19, 2024

I moved this PR to my own fork at Sjors#50 to reduce CI load, which apparently was becoming too much: #30475 (comment)

@Sjors Sjors closed this Jul 19, 2024
@maflcko
Copy link
Member

maflcko commented Jul 22, 2024

reduce CI load

Some more machines were added a few weeks back to deal with increased overall activity, so I think the load should be handleable now, unless someone pushes to 10 different pull requests every 20 minutes in a loop.

Looks like you fixed it in the meantime, but if CI load comes up again, you may create an issue so that it can be fixed.

@bitcoin bitcoin locked and limited conversation to collaborators Jul 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants