Closed Sjors closed 1 month ago
@sdaftuar @sipa repeating my comment from https://github.com/bitcoin/bitcoin/pull/30443 (with updated code).
I made a branch sv2-cluster that combines https://github.com/bitcoin/bitcoin/pull/28676 with https://github.com/bitcoin/bitcoin/pull/29432:
The main commit is https://github.com/bitcoin/bitcoin/commit/625e44445531f58c523e1c8c893a431ab5376e0b. The waitFeesChanged()
interface 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?
You can see it in action using src/bitcoind -sv2 -debug=sv2 -loglevel=sv2:trace
Once the node is at the tip you'll see frequent [sv2:trace] Assemble template: ...ms
messages. (this even works without a connected SRI client, which is a convenient bug)
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.
Reopening this on the main repo at https://github.com/bitcoin/bitcoin/pull/31003
This adds
waitFeesChanged()
to theMining
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 https://github.com/bitcoin/bitcoin/pull/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 checksgetTransactionsUpdated
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 usewaitFeesChanged()
, which is why this PR does not touch the longpolling code.TODO: