Skip to content

Conversation

@Sjors
Copy link
Member

@Sjors Sjors commented Jul 12, 2024

This adds waitFeesChanged() to the Mining interface.

The Stratum v2 protocol allows pushing out templates as fees in the mempool increase. This interface lets us know when it's time to do so.

Without Cluster Mempool however the implementation is "fake", instead returning every time a transaction is added to the mempool. So for now I'm keeping this draft. It's here to provide a complete and stable Mining interface for #30437 to build on.

Unlike the entire Mining interface so far, this is not a refactor. It adds new functionality.

The current implementation is very similiar to how longpolling in getblocktemplate works, which checks getTransactionsUpdated every 10 seconds.

However once Cluster Mempool is added it will be cheap enough to frequently generate a block template, check if the fees have gone up enough and then return. That would cause a behaviour change if getblocktemplate were to use waitFeesChanged(), which is why this PR does not touch the longpolling code.

TODO:

  • try with (draft) cluster mempool branch

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 12, 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:

  • #30437 (multiprocess: add bitcoin-mine test program by ryanofsky)
  • #30409 (Introduce waitTipChanged() mining interface, replace RPCNotifyBlockChange and drop CRPCSignals by Sjors)
  • #29432 (Stratum v2 Template Provider (take 3) by Sjors)

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.

@Sjors Sjors force-pushed the 2024/07/mining-fees-changed branch 3 times, most recently from 3efa63f to cd0d9fc Compare July 15, 2024 15:53
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 16, 2024
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 17, 2024
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 17, 2024
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 17, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit changes the C++ Mining interface without changing the corresponding
Capn'Proto interface. The capnp interface is updated the next commit.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 17, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
@Sjors
Copy link
Member Author

Sjors commented Jul 18, 2024

@sdaftuar @sipa I made a branch sv2-cluster that combines #28676 with #29432:

The main commit is f646977. It slightly changes the waitFeesChanged() interface. The implementation now frequently creates a new template.

The Template Provider then uses that to see if sending a new NewTemplate message is justified.

It still takes 20-30ms on mainnet to create a template, without or the cluster mempool changes. I guess BlockAssembler::CreateNewBlock doesn't actually take advance of it? How would I go about getting the total fees for the first block?

It doesn't have to be very precise. The user can configure -sv2delta as a threshold for when to send out new templates, but we can be off by a bit. The actual block is constructed later.

@Sjors Sjors force-pushed the 2024/07/mining-fees-changed branch from cd0d9fc to b9da31b Compare July 18, 2024 16:54
@Sjors
Copy link
Member Author

Sjors commented Jul 18, 2024

Rebased after #30356 landed. Changed fees_before to be a reference to CAmount based on the above experience of using it.

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 18, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit changes the C++ Mining interface without changing the corresponding
Capn'Proto interface. The capnp interface is updated the next commit.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 18, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 18, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit changes the C++ Mining interface without changing the corresponding
Capn'Proto interface. The capnp interface is updated the next commit.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 18, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
@Sjors Sjors force-pushed the 2024/07/mining-fees-changed branch from b9da31b to 57e8908 Compare July 19, 2024 08:55
@Sjors
Copy link
Member Author

Sjors commented Jul 19, 2024

Added bool& tip_changed.

Sjors pushed a commit to Sjors/bitcoin that referenced this pull request Jul 19, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
Sjors added a commit to Sjors/bitcoin that referenced this pull request Jul 19, 2024
@Sjors
Copy link
Member Author

Sjors commented Jul 22, 2024

I'm moving this to Sjors#52.

Since it's astronomically unlikely multiprocess will be in the upcoming v28.0 release, we have at least half a year to flesh out this interface. Hopefully cluster mempool will be further along by then, since that will inform the design.

@Sjors Sjors closed this Jul 22, 2024
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 24, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 24, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit changes the C++ Mining interface without changing the corresponding
Capn'Proto interface. The capnp interface is updated the next commit.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Jul 24, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Sep 6, 2024
Add interface changes from

bitcoin#30409
bitcoin#30356
bitcoin#30440
bitcoin#30443

This commit updates the Cap'n Proto Mining interface after updating the C++
Mining interface last commit.
@Sjors Sjors reopened this Sep 24, 2024
@Sjors Sjors closed this Sep 24, 2024
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Sep 26, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Sep 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants