Stratum v2 Template Provider (take 3) #29432

pull Sjors wants to merge 29 commits into bitcoin:master from Sjors:sv2 changing 61 files +5679 −72
  1. Sjors commented at 11:34 am on February 14, 2024: member

    Based on on @Fi3’s https://github.com/bitcoin/bitcoin/compare/master...Fi3:bitcoin:PatchTemplates which is based on @ccdle12’s #27854. I rebased it and re-wrote the commit history. Compared to #28983 it introduces EllSwift in the handshake and fixes various bugs. I used that opportunity to change the branch name, which makes testing against SRI slightly easier. There’s no conceptual discussion on #28983 so it can be ignored by reviewers.

    See docs/stratum-v2.md for a brief description of Stratum v2 and the role of Bitcoin Core in that system..

    What to test and review?

    I’ll make separate pull requests for parts that are ready for detailed review.

    See the testing guide for various ways to test this PR. This branch is actively used by (testnet) pools, so it should be ready for high level review.

    Exploratory / experimental stuff

    Implementation notes

    There’s roughly three layers:

    1. Noise encryption #29346
    2. Messages and transport layer #30315
    3. The Template Provider

    I might need another layer between 2 and 3 similar to ConnMan, see #30332.

    • the ci: commits (#29274) are there to facilitate PR’s against this branch, but they are not blocking for Stratum v2

    Contributing

    If you want to help out with any of the issues below, please open a PR to my fork. I will then squash your commits into my own where needed.

    Things left todo

    Spec

    • modify spec to use ProvideMissingTransactions? (followup?)
    • pick a good default for default_coinbase_tx_additional_output_size (see getblocktemplate RPC)

    Networking

    • add -sv2bind and -sv2allowip
    • optional -sv2cert
    • drop Sv2TemplateProvider::SendBuf, reuse p2p socket handling if possible
    • limit number of connected clients
    • maybe limit (number of) coinbase_output_max_additional_size
    • TMP / TODO comments at the top of sv2_messages.h

    Testing

    • expand sv2_template_provider_tests
    • add transport fuzzer
    • add template provider fuzzer

    Template generation and updating

    • group templates with the same coinbase_tx_additional_output_size
    • don’t generate templates when no client is connected

    Misc

    Potential followups

    • implement Noise protocol and mock client in Python, add functional tests (based on test/sv2_template_provider_tests.cpp)
    • use process separation, e.g. a bitcoin-tp binary, see multiprocess.md
    • make template updates push based, on top of Cluster Mempool, see docs/stratum-v2.md (for new blocks it’s already push based)
    • push empty template for the next block (downstream can ignore or use, https://github.com/stratum-mining/stratum/issues/715)
      • send prevhash for this template as soon as any new block arrives
    • push optimistic template for the next block
      • send prevhash if and only if our template won (i.e. we got a SubmitSolution message)
  2. DrahtBot commented at 11:34 am on February 14, 2024: contributor

    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.

    Type Reviewers
    Approach NACK stickies-v

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30356 (refactor: add coinbase constraints to BlockAssembler::Options by Sjors)
    • #30203 (Enhance signet chain configuration in bitcoin.conf by BrandonOdiwuor)
    • #30141 (kernel: De-globalize validation caches by TheCharlatan)
    • #30130 (contrib/signet/miner: increase miner search space by edilmedeiros)
    • #30051 (crypto, refactor: add new KeyPair class by josibake)
    • #29838 (Feature: Use different datadirs for different signets by BrandonOdiwuor)
    • #29775 (Testnet4 including PoW difficulty adjustment fix by fjahr)
    • #29686 (Update manpage descriptions by willcl-ark)
    • #29415 (Broadcast own transactions only via short-lived Tor or I2P connections by vasild)
    • #28710 (Remove the legacy wallet and BDB dependency by achow101)
    • #28417 (contrib/signet/miner updates by ajtowns)
    • #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.

  3. DrahtBot added the label CI failed on Feb 14, 2024
  4. DrahtBot commented at 12:27 pm on February 14, 2024: 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/21562393655

  5. Sjors force-pushed on Feb 14, 2024
  6. Sjors force-pushed on Feb 14, 2024
  7. Sjors force-pushed on Feb 14, 2024
  8. in src/test/sv2_template_provider_tests.cpp:37 in 684890f900 outdated
    31+
    32+    bool start()
    33+    {
    34+        bool started = m_tp->Start(Sv2TemplateProviderOptions { .port = 18447 });
    35+        if (! started) return false;
    36+        // Avoid "Connection refused" on CI:
    


    Sjors commented at 2:17 pm on February 14, 2024:
    The template provider tests are quite brittle because they use a real socket.

    Sjors commented at 3:57 pm on February 14, 2024:

    For the time being I just added handling for MSG_MORE (on e.g. macOS sequential messages are sent separately while on Linux they’re combined). I also made the timeouts a bit longer.

    Hopefully that does the trick. This can be revisited closer to the time when the Template Provider is ready for its own PR.


    Sjors commented at 6:54 pm on February 14, 2024:

    Sjors commented at 7:25 pm on February 14, 2024:

    Sjors commented at 8:53 pm on February 14, 2024:
    I should probably look into using StaticContentsSock

    Sjors commented at 11:20 am on February 15, 2024:
    @vasild any thoughts on how to make mock Socks that can be used to play messages in two directions?

    vasild commented at 5:20 pm on February 16, 2024:

    Yes! See the first two commits in #26812:

    bee6bdf0a5 test: put the generic parts from StaticContentsSock into a separate class f42e4f3b3b test: add a mocked Sock that allows inspecting what has been Send() to it

    and then how to use that in the last commit of the same PR:

    8b10990aa0 test: add unit tests exercising full call chain of CConnman and PeerManager

    With those it is possible to send/receive raw bytes to/from the (mocked) socket, or NetMsgs, e.g.:

    0pipes->recv.PushNetMsg(NetMsgType::GETBLOCKS, block_locator, hash_stop);
    
  9. Sjors force-pushed on Feb 14, 2024
  10. Sjors force-pushed on Feb 14, 2024
  11. in src/test/sv2_template_provider_tests.cpp:255 in 1bacb89987 outdated
    221+        // Get serialized transaction size
    222+        DataStream ss;
    223+        ss << TX_WITH_WITNESS(tx);
    224+        tx_size = ss.size();
    225+    }
    226+
    


    Sjors commented at 8:04 pm on February 14, 2024:
    TSAN is tripping up somewhere around here. The last thing it logs is - Connect 2 transactions:. It doesn’t get to - Verify ... txins:. I wonder if this is related to mock time, which I’m testing in https://github.com/Sjors/bitcoin/pull/34

    Sjors commented at 11:15 am on February 15, 2024:

    @maflcko shouldn’t TSan on CI output something useful about why it crashed? I currently only says “error 2”: https://cirrus-ci.com/task/5124733717446656?logs=ci#L3531

    When running this locally on Ubuntu with clang 16.0.6 I get a WARNING: ThreadSanitizer: data race and significantly more details (still a bit cryptic, but hopefully enough to figure out what’s happening).


    maflcko commented at 11:39 am on February 15, 2024:
    Ah, I guess the unit tests don’t capture the tsan output?

    maflcko commented at 11:41 am on February 15, 2024:
    But they should. At least back when I tested https://github.com/bitcoin/bitcoin/pull/27667

    maflcko commented at 11:42 am on February 15, 2024:
    Maybe good to re-check this when/after the cmake migration is done?
  12. Sjors force-pushed on Feb 15, 2024
  13. Sjors force-pushed on Feb 15, 2024
  14. Sjors commented at 2:07 pm on February 15, 2024: member
    Added m_tp_mutex to Sv2TemplateProvider.
  15. Sjors commented at 3:12 pm on February 15, 2024: member

    Bumping macOS to 14 on the CI does not help (tried in https://github.com/Sjors/bitcoin/pull/35). I also can’t reproduce this failure on my own Intel macOS machines, not on 13.6.4 and not on 14.2.1. A Sock mock is probably the most robust solution, but it’d be nice to find another workaround.

    This extra delay seems to do the trick for now: https://github.com/Sjors/bitcoin/commit/c8d10afd4d3152a665ab96f1a8d39293e02d8410

    Another option to consider is using the functional test framework instead, since these are not really unit tests. However that involves implementing the sv2 noise protocol in Python and a bunch of other work to export transport functions to the functional test framework. If anyone feels up to that challenge, let me know…

  16. Sjors force-pushed on Feb 15, 2024
  17. DrahtBot removed the label CI failed on Feb 15, 2024
  18. Sjors force-pushed on Feb 16, 2024
  19. Sjors commented at 1:05 pm on February 16, 2024: member
    Added m_clients_mutex similar to the one in Connman. Fixed a deadlock on g_best_block_mutex when we receive a fresh block simultaneously from a peer and a client (SubmitSolution message).
  20. Sjors commented at 2:28 pm on February 16, 2024: member

    Windows test fails with:

    0test/sv2_noise_tests.cpp(62): fatal error: in "sv2_noise_tests/certificate_test": critical check !alice_certificate.Validate(XOnlyPubKey(alice_authority_key.GetPubKey())) has failed
    

    Odd. Part of #29346 so can be debugged there.

  21. DrahtBot added the label CI failed on Feb 16, 2024
  22. DrahtBot commented at 2:46 pm on February 16, 2024: 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/21654131515

  23. Sjors force-pushed on Feb 16, 2024
  24. Sjors commented at 7:08 pm on February 16, 2024: member
    With https://github.com/stratum-mining/stratum/pull/737, https://github.com/stratum-mining/stratum/pull/752 (allowing me to drop 2469053d31f11f5edc766108d9a67ed7572d5b61), https://github.com/stratum-mining/stratum/pull/729 and https://github.com/stratum-mining/stratum/pull/722 merged this PR is now compatible with SRI’s main branch. This should make testing a lot easier.
  25. DrahtBot removed the label CI failed on Feb 16, 2024
  26. DrahtBot added the label CI failed on Feb 29, 2024
  27. DrahtBot commented at 8:21 pm on February 29, 2024: 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/21668951058

  28. Sjors force-pushed on Mar 1, 2024
  29. Sjors commented at 11:52 am on March 1, 2024: member

    Rebased and hopefully satisfied new bitcoin-config.h linter rule.

    The kind of incidental failure in sv2_template_provider_tests can probably be avoided with the mock socket introduced / improved in ##26812.

  30. DrahtBot removed the label CI failed on Mar 1, 2024
  31. DrahtBot added the label CI failed on Mar 17, 2024
  32. DrahtBot commented at 6:23 am on March 17, 2024: 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/22448274349

  33. Sjors force-pushed on Mar 18, 2024
  34. Sjors commented at 8:01 pm on March 18, 2024: member

    Rebased after #27375. Changed the default binding from 0.0.0.0 to 127.0.0.1 to make it abundantly clear that it’s currently unsafe to expose this to the big bad internet. The previous behaviour can be achieved with the new -sv2bind=0.0.0.0

    Finally, we immediately listen for new client connections. Previously we’d wait for IBD to finish. However we hold off on sending template updates. Except for Signet, because you may be the only miner and after a day of not mining the chain would get stuck.

  35. DrahtBot removed the label CI failed on Mar 19, 2024
  36. DrahtBot added the label Needs rebase on Mar 20, 2024
  37. Sjors force-pushed on Mar 22, 2024
  38. DrahtBot removed the label Needs rebase on Mar 22, 2024
  39. DrahtBot added the label Needs rebase on Apr 2, 2024
  40. Sjors force-pushed on Apr 5, 2024
  41. DrahtBot removed the label Needs rebase on Apr 5, 2024
  42. DrahtBot added the label CI failed on Apr 5, 2024
  43. DrahtBot commented at 11:17 pm on April 5, 2024: 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/23496058028

  44. DrahtBot added the label Needs rebase on Apr 22, 2024
  45. Sjors force-pushed on May 1, 2024
  46. DrahtBot removed the label Needs rebase on May 1, 2024
  47. DrahtBot added the label Needs rebase on May 2, 2024
  48. Sjors force-pushed on May 2, 2024
  49. DrahtBot removed the label Needs rebase on May 2, 2024
  50. Sjors commented at 8:05 am on May 3, 2024: member
    (ignoring CI failure, as I mentioned above I plan on making the tests more robust after #26812)
  51. Sjors referenced this in commit 2125fc5616 on May 3, 2024
  52. DrahtBot added the label Needs rebase on May 15, 2024
  53. Sjors force-pushed on May 30, 2024
  54. Sjors commented at 9:20 am on May 30, 2024: member

    I dropped 3559085dcc9ee687c347383a0c2a63f3ea16f001 and 3f4c1d1e515a840c4b119e3ba65a8391d4fc7f6b which introduced common/transport.h. It’s difficult to maintain such a large diff and it’s currently causing a link error. Here’s a branch with both of them: https://github.com/Sjors/bitcoin/tree/2024/05/transport

    I’d still like to move Transport out of libbitcoin_node into libbitcoin_common, but this is probably better done in a parallel PR.

    At the request of people testing Stratum v2 I’m adding testnet4 to this branch, but bear in mind it’s not final.

    I still need to do some manual testing on this last push, so be careful.

  55. Sjors force-pushed on May 30, 2024
  56. DrahtBot removed the label Needs rebase on May 30, 2024
  57. Sjors force-pushed on Jun 7, 2024
  58. Sjors commented at 2:25 pm on June 7, 2024: member
    Updated to use the interface proposed in #30200. This also fixes a small bug: -blockmintxfee and -blockmaxweight are no longer ignored. When the latter argument is unset, by default blocks have a 4000 byte safety margin, just like with getblocktemplate.
  59. Sjors force-pushed on Jun 7, 2024
  60. Sjors force-pushed on Jun 7, 2024
  61. Sjors force-pushed on Jun 7, 2024
  62. DrahtBot added the label Needs rebase on Jun 12, 2024
  63. Sjors force-pushed on Jun 18, 2024
  64. Sjors commented at 3:29 pm on June 18, 2024: member
    Rebased, squashed Mining interface usage into the existing commits and fixed the usage of coinbase_output_max_additional_size.
  65. DrahtBot removed the label Needs rebase on Jun 18, 2024
  66. Sjors force-pushed on Jun 18, 2024
  67. Sjors force-pushed on Jun 18, 2024
  68. Sjors force-pushed on Jun 18, 2024
  69. Sjors force-pushed on Jun 20, 2024
  70. Sjors force-pushed on Jun 20, 2024
  71. Sjors commented at 1:56 pm on June 20, 2024: member

    I split the commit that introduces sv2_messages.h in two parts:

    • 9fcc95d837dbd20c1003b4c2d3c90b202e0629bd: introduces a single simple message Sv2CoinbaseOutputDataSizeMsg and the plumbing it needs
    • 00d1408cc7cb263fb6e956649a41e0b02e2378aa: adds the other messages

    This makes it easier to introduce Sv2Transport in a separate PR, which only needs the first commit.

  72. DrahtBot removed the label CI failed on Jun 20, 2024
  73. stickies-v commented at 1:45 pm on June 21, 2024: contributor

    I’m strongly in favour of having Template Provider (TP) support for SV2, so thank you for your hard work on this @Sjors. I am very concerned about the scope of this approach though, and therefore leaning to an Approach NACK (but open to being persuaded otherwise).

    From my reading of the discussion in #27854, it seems the main technical hurdle to just having a separate sv2tpd daemon using bitcoind’s existing interfaces is getblocktemplates having serious limitations as outlined here. That’s a sensible concern, and one we need to address.

    Can the getblocktemplate concerns not (at least largely) be addressed by upgrading the existing RPC method, or adding a new one that’s minimal in scope and not SV2 opinionated? I understand this will still be a pretty significant overhaul, but probably still significantly smaller than what is proposed at the moment?

    I’m happy to be convinced otherwise, but as it stands, implementing a separate sv2tpd process that uses bitcoinds (minimally) improved interfaces seems like a much more sensible approach to me, and afaict would still address all points listed in https://github.com/Sjors/bitcoin/blob/sv2/doc/stratum-v2.md#advantage-over-getblocktemplate-rpc . I’m curious to hear your thoughts on this.

  74. DrahtBot added the label Needs rebase on Jun 21, 2024
  75. Sjors commented at 4:11 pm on June 21, 2024: member

    upgrading the existing RPC method, or adding a new one that’s minimal in scope and not SV2 opinionated

    I don’t think our RPC is suitable for this, because it’s inherently poll based. We want to push out new block templates as soon as something better is found.

    Another major change compared to the getblocktemplate RPC is that the TP holds on to templates for a while (currently until after the next block is found, though could be shorter). It needs to do this because solutions for custom block templates have to be submitted by the node that created it. The pool will try, but it might fail if it’s missing transactions.

    implementing a separate sv2tpd process

    This PR also aims to run in a separate process, eventually anyway. I guess you’re saying it should be separate software altogether, like SRI?

    It would move some of the complexity from this PR elsewhere, mainly the encryption and transport layers. It could poll once a second, we’d need changes to hold on to previously generated templates, a new RPC to submit a solution that refers to a previous template and a few other things.

    As a practical matter I’m not sure who would be implementing that; SRI is already a pretty complicated codebase with a shortage of developer resources. Some people have been testing this branch in combination with SRI and seem quite happy with it, despite the code being nowhere near merge-ready. But in principle it’s possible.

  76. Sjors force-pushed on Jun 21, 2024
  77. Sjors commented at 4:58 pm on June 21, 2024: member
    Rebased after #30314 and #30202. Incorporated the (light) transport refactor from #30315 to make sure that didn’t break anything.
  78. DrahtBot removed the label Needs rebase on Jun 21, 2024
  79. stickies-v commented at 5:48 pm on June 21, 2024: contributor

    I don’t think our RPC is suitable for this, because it’s inherently poll based. We want to push out new block templates as soon as something better is found.

    What about a combination of extending the zmq and rest interface and/or using longpollid, as suggested e.g. here? It seems like that would already improve things significantly, without having to add the encryption and transport layer?

    It needs to do this because solutions for custom block templates have to be submitted by the node that created it. The pool will try, but it might fail if it’s missing transactions.

    I’m not sure I understand this. This PR is not an sv2 discussion, so if my understanding is wrong we don’t need to talk about it here, but are you saying the pool will approve a proposed block template without having/keeping all the transactions? That seems undesired?

    Regardless, I’m not sure the TP necessarily needs to hold on to block templates when sv2tpd caches all block template transactions and add any missing ones back to core through RPC before submitting a block? Perhaps the existing interfaces aren’t sufficient currently, but then again - perhaps we could improve them instead of wholesale implementing sv2 logic?

    I guess you’re saying it should be separate software altogether

    Yes, a separate project and a separate process would be my strong preference. Again, I do think it’s important Bitcoin Core supports SV2 well. But if the bitcoind interfaces are lacking for sv2tpd to be a separate project, I think we should first exhaust the possibilities of improving the interfaces before just incorporating (part of) the downstream project into Bitcoin Core.

    As a practical matter I’m not sure who would be implementing that

    Wouldn’t it be more straightforward to implement this as a separate sv2tpd daemon versus incorporating it into Core, giving more freedom in terms of language, dependencies, review, release process, …?

  80. sipa commented at 6:02 pm on June 21, 2024: member

    But if the bitcoind interfaces are lacking for sv2tpd to be a separate project, I think we should first exhaust the possibilities of improving the interfaces before just incorporating (part of) the downstream project into Bitcoin Core.

    FWIW, my view is that indeed the current Bitcoin Core interfaces are inadequate for implementing template providers, and while it’s probably possible to make a number of improvements to existing ones to improve the situation, the result will either be far from ideal still (RPC is not binary, ZMQ is only one-directional, …), or quite different from anything we have now. And if we’re going to make a substantially different interface for the purpose of template providing, it probably makes sense to just pick Sv2 to be that interface as it’s designed exactly for that purpose. The encryption aspect of Sv2 isn’t necessary for that, but if all sv2tpd would do is be an Sv2 encrypting proxy, it might be logistically just simpler to have Bitcoin Core also do the encryption aspect.

    So this doesn’t exclude the possibility that future block template providing protocols be implemented in external proxy servers, which then talk still talk Sv2 to Bitcoin Core, if that is still appropriate.

  81. Sjors commented at 6:40 pm on June 21, 2024: member

    I’m not sure I understand this. This PR is not an sv2 discussion, so if my understanding is wrong we don’t need to talk about it here, but are you saying the pool will approve a proposed block template without having/keeping all the transactions? That seems undesired?

    The Job Declaration Protocol has a param async_mining_allowed which, if set, allows miners to immediately submit work even before the template has been approved. Afaik SRI currently just hardcodes this to true for simplicity (cc @fi3).

    Approval takes time, because we have to send the pool any transactions it’s missing, and it needs to check those (SRI currently only checks that all transactions are present, no additional checks - I suspect that’s a can of worms on its own, since there may be conflicts with the pool node mempool). During this time you would either have to mine on a pool template, or solo mine.

    Regardless of the merits of async mining, it’s more robust for the miner to broadcast a found block themselves (this is done via the SubmitSolution message).

    Example of this actually going wrong (in testing): #912

    I’m not sure the TP necessarily needs to hold on to block templates when sv2tpd caches all block template transactions and add any missing ones back to core through RPC before submitting a block?

    Maybe. But we also need to hold on to everything that was in the mempool at the time (an aspect I haven’t thoroughly tested yet). From what I’ve seen in SRI, the Job Declarator Server (pool side) implements some sort of pseudo-mempool for that purpose.

    Wouldn’t it be more straightforward to implement this as a separate sv2tpd daemon versus incorporating it into Core

    I’m not sure if it is. The two most practical approaches are improving this PR vs. expanding SRI. Building something from scratch is probably more work. Using a language other than Rust of c++ means re-writing the Noise implementation and other reusable code. The Bitcoin Core codebase has some very useful building blocks, e.g. the Transport class, BIP324 implementation (which we use parts of), well tested TCP socket handling code (unfortunately very tightly coupled with p2p, but refactoring that can be orthogonally useful), process separation in the pipeline (so it can crash without taking the node down - though so can a separate tool), good CI, and deterministic builds (so I can easily and relatively safely ship this PR as its own binary).

  82. DrahtBot added the label CI failed on Jun 21, 2024
  83. DrahtBot commented at 8:34 pm on June 21, 2024: 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/26528227399

  84. DrahtBot added the label Needs rebase on Jun 24, 2024
  85. ryanofsky referenced this in commit 323b0acfcb on Jun 24, 2024
  86. Sjors force-pushed on Jun 25, 2024
  87. Sjors commented at 12:18 pm on June 25, 2024: member
    Rebased after #30200 landed! 🎉 Reorganized commits so it’s now based on #30332.
  88. DrahtBot removed the label Needs rebase on Jun 25, 2024
  89. stickies-v commented at 1:43 pm on June 25, 2024: contributor

    …it probably makes sense to just pick Sv2 to be that interface as it’s designed exactly for that purpose

    I agree we shouldn’t reinvent the wheel and just implement the parts of sv2 that we need to improve our getblocktemplate functionality. I would just prefer to be much more strict in cutting out all the parts that Core doesn’t require to support sv2 downstream, i.e. I don’t think the “out-of-the-box” aspect should at at all be a priority when that can reasonably be addressed with external tooling.

    …it might be logistically just simpler to have Bitcoin Core also do the encryption aspect.

    It probably would be, but I’d much rather we keep the scope of Core limited. Where we draw the line is up for debate, but tooling for a highly specialized process (I think we’re only expecting a small minority of nodes to be running SV2?) that can be kept outside of Core absolutely should be, in my view.

    …well tested TCP socket handling code (unfortunately very tightly coupled with p2p, but refactoring that can be orthogonally useful), process separation in the pipeline (so it can crash without taking the node down - though so can a separate tool), good CI, and deterministic builds (so I can easily and relatively safely ship this PR as its own binary).

    As much as I sympathize that setting up a new project includes a bunch of painful overhead that requires even more scarce developer resources, I don’t think any of these are good reasons to bundle more code than necessary into Core, where it has a massive maintenance cost - even if it’s less visible now.


    I think I’m going to withdraw from the conceptual discussion until I have more in-depth knowledge of the relevant code and protocol. To summarize: I think Core should have good support for being a SV2 Template Provider, and implementing parts of SV2 to do that makes sense. It still seems to me like the current approach is too invasive and too much of an unnecessary maintenance burden on this project.

  90. DrahtBot removed the label CI failed on Jun 25, 2024
  91. Sjors commented at 3:05 pm on June 25, 2024: member

    a highly specialized process (I think we’re only expecting a small minority of nodes to be running SV2?)

    I’d like to see a lot more users mine, and do so with their own block template. In order to achieve that we have to lower the barrier to entry.

    There’s a generic case to be made for reducing the scope of Bitcoin Core, and not further increasing it. I think we still lack the tooling for this. Something like a plugin system, or a convenient way to ship a release tag plus custom functionality.

    Having the user download and install two things is fine in theory, as long as it just works(tm). HWI is a working example of that, but that specific approach won’t work here.

    I’m not very keen on starting from scratch with a new approach myself, but I can test and review alternative approaches that others work on.

    For now I plan to keep rebasing this PR, occasionally releasing a binary. As long as I can get some prerequisite refactoring merged, that should be sustainable for a while.

  92. DrahtBot added the label Needs rebase on Jun 27, 2024
  93. Add sv2 log category for Stratum v2 3f25575ecc
  94. Sjors force-pushed on Jun 28, 2024
  95. DrahtBot removed the label Needs rebase on Jun 28, 2024
  96. Sjors commented at 9:00 am on June 28, 2024: member
    I opened #30356 with some BlockAssembler::Options and mining interface refactoring that should make this PR smaller.
  97. Add sv2 noise protocol
    Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
    4778bb7049
  98. Add sv2 message CoinbaseOutputDataSize
    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>
    1bfa3fbbc6
  99. Convert between Sv2NetMsg and CSerializedNetMsg
    This allows us to subclass Transport.
    86e6746fdb
  100. Introduce Sv2Transport
    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
    aaad8d116a
  101. Add sv2 SETUP_CONNECTION messages
    Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
    4ca63a662c
  102. Chainparams: add default sv2 port
    Co-authored-by: Christopher Coverdale <chris.coverdale24@gmail.com>
    59fbe8e24e
  103. Stratum v2 template provider scaffold
    Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
    ae14ae4f4a
  104. fixme: make Sv2NetMsg m_msg public
    The Template Provider does stuff like this:
    
    DataStream ss (sv2_net_msg.m_msg);
    try {
                ss >> setup_conn;
            } catch (const std::exception& e) {
    ...
    
    Such error checking should be moved inside Sv2Message.
    c64d24238d
  105. Template provider sv2 connection support
    The template provider will listen for a Job Declarator client.
    It can establish a connection and detect various protocol errors.
    
    Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
    Co-Authored-By: Fi3
    7281a23515
  106. test: Template Provider connection establishment b0b4851aec
  107. Add remaining sv2 messages for TemplateProvider edb8f50bae
  108. CKey: add Serialize and Unserialize
    Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
    149b0ad52c
  109. testnet: Introduce Testnet4 4e1453b8c5
  110. testnet: Add Testnet4 difficulty adjustment rules fix 25856de485
  111. testnet: Add timewarp attack prevention for Testnet4 e2c8451b3e
  112. Persist static key for Template Provider 7cd1402179
  113. refactor: add coinbase constraints to options
    Stratum v2 requires pools to communicate the maximum bytes they intend to add to the coinbase outputs, as well as the maximum number of sigops.
    
    This commit adds them to BlockAssembler::Options, so they can be set later.
    22dd8ff489
  114. Add util/mining.h for default coinbase constraints
    These defaults are needed by the Mining interface in the next commit.
    a0b696c594
  115. Account for reserved bytes in createNewBlock d9a9aeb6ba
  116. Sv2: construct and submit block templates
    Co-Authored-By: Christopher Coverdale <chris.coverdale24@gmail.com>
    248d7c6c72
  117. Incrementally update sv2 block template 19eefe1d75
  118. Reject RequestTransactionData for stale templates 72dd99d2b5
  119. test: additional template provider tests e3cd8fae6f
  120. signet: miner skips PSBT step for OP_TRUE 392e0e6259
  121. doc: explain Stratum v2 design, testing and usage a10e4dce26
  122. ci: forks can opt-out of CI branch push (Cirrus only) 87720f4f77
  123. ci: test-each-commit merge base optional
    The ci "test-each-commit" job fetches the PR branch being tested with a depth of (# of commits in PR + 2), and then tries to run tests on commits after the most recent merge commit.
    
    When a PR is opened against a bitcoin core branch, a merge commit is always guaranteed to exist within the fetch depth, because bitcoin core branches always point at merge commits.
    
    However, in fork repositories, pull requests can be opened based on other branches that don't contain recent merge commits, and this will currently cause git rev-list to fail with fatal: bad revision '^^@'.
    
    Work around this problem by not requiring a recent merge commit, and just testing on all fetched commits if a merge commit can't be found.
    
    Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
    8f57ab3a98
  124. ci: skip Github CI on branch pushes for forks
    Similar to the previous commit, however the behavior isn't opt-in
    with NO_BRANCH, because Github CI lacks custom variables.
    2a62e5e364
  125. Sjors force-pushed on Jun 28, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 10:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me