<p>As you describe, you cannot distinguish the reason for the divergence between the block you received and the block you get from <code>getblocktemplate</code>.</p>
<p>It may be helpful to isolate the reasons:</p>
<ul>
<li>If you are trying to compare algorithms, you should try building a block with <code>getblocktemplate</code> (<code>gbt</code>) and with your own algorithm from the same mempool.</li>
<li>If you're trying to compare network propagation, you may want to run multiple nodes, and assume that the miner built with <code>gbt</code> given everything that they had seen at this point. You may even want to keep track of when a transaction was seen, to reason about whether it is fathomable that it hasn't been seen by the miner.<br />
I think it's reasonable to assume that miners are building the best
possible block according to <code>gbt</code>, although odd ordering of transactions may indicate some manual prioritization of transactions. However, you will have at least two
sources of error: the latency from block propagation, and the delay between the mining pool operator giving out a template and the executing miner discovering the block and announcing it. However, these two delays may be too high for the block content to be an accurate representation of the mining pool's mempool content.</li>
</ul>
<p>From what I understand, other research projects looking into transaction propagation measure it by keeping track of when nodes announce txids/block ids to them. It wouldn't be trivial to identify the nodes operated by miners to measure their network quality, though, if they are even part of the open network and not moated by border nodes.</p>

CC BY-SA 4.0
2022-01-27T16:52:00.050Z
Thanks for the elaborate answer Murch. Sorry if the msg I sent you via twitter confused you. I want to compare the mining pools for how good they are choosing its transactions, not to algorithms between them as you have done with ASB/CSB algorithms. I now have understood the way you have compared both and it's not the same approach as mine.

As you says, I have to run multiple nodes in different geographic localizations and compare the results to see if there is some difference in lost reward from my point(s) of view. And that is the most I can do I think.
dev7ba
CC BY-SA 4.0
2022-01-26T16:07:30.380Z
2022-01-26T16:15:51.490Z
2022-01-26T16:15:51.490Z
Murch
<p>Well, this is the way I've tried:</p>
<p>When a mined block arrives to my node, I compare it against a transaction selection algorithm using my mempool. (I know my mempool is different than the miner's, and that's the point so keep reading ;-) )</p>
<p>The transaction selection algorithm sorts transactions in the usual greedy way: using the regular Ancestor Set Based (ASB) algorithm described <a href="https://gist.github.com/murchandamus/5cb413fe9f26dbce57abfd344ebbfaf2#file-candidate-set-based-block-building-md" rel="nofollow noreferrer">here</a>, and considering transaction dependencies and <a href="https://bitcoinops.org/en/topics/cpfp/" rel="nofollow noreferrer">CPFP</a>, so basically is the same as invoking <code>getblockTemplate</code> with the state of my mempool just before the block arrives. (I also compare the incoming block by using the last <code>getBlockTemplate</code> result of bitcoind but as it's only calculated each 30s the results are not accurate).</p>
<p>An example of a comparison is shown <a href="https://mempoolexplorer.com/block/last/OURS" rel="nofollow noreferrer">here</a>, (my webpage, in development). I divide the transactions in sets whether they were ignored by the miner (from my node point of view), are in common with me, ignored by me, relayed to me, or not relayed to me.</p>
<p>And, of course, I also measure the fees I would have collected compared to the miner's block (taking into account the incoming block coinbase transaction size for better accuracy). You can check the results of the last blocks <a href="https://mempoolexplorer.com/block/OURS" rel="nofollow noreferrer">here</a>, and an aggregate for the miners <a href="https://mempoolexplorer.com/miner" rel="nofollow noreferrer">here</a>.</p>
<p>This could give me an idea about how good a miner is selecting its transactions and/or has good network connectivity (in average, and against my mempool), but as I have no way of knowing the state of the miners mempool before they mine a block (nor when I receive it), this effort seems inaccurate.</p>
<p>I make the assumption that a received block and my block template can be compared. But as the block propagation time is not, by any means, negligible, the comparison is skewed giving the idea that my algorithm/network situation is better. The reality is that I am receiving transactions while the block is being propagated to me, and thus, I have normally a bigger mempool than the miner when the block was mined. A bigger mempool gives my algorithm the opportunity to search for better transactions which had no opportunity to be mined by miners.</p>
<p>So, is the accuracy of this methodology worthy? I've assumed its not. But as block propagation time is getting smaller (see <a href="https://www.dsn.kastel.kit.edu/bitcoin/?ref=hackernoon.com#latency" rel="nofollow noreferrer">this</a>) And the results for some blocks/miners seems really different (see <a href="https://mempoolexplorer.com/block/719478/BITCOIND" rel="nofollow noreferrer">this</a> block for example) I have my doubts.</p>
<p>Thanks in advance.</p>

<mining-pools><mining-theory><mining-profitability><mining-reward><mempool>
Is there a way to know how good a miner is choosing its transactions to be mined from a fee maximization point of view?
dev7ba
# Is there a way to know how good a miner is choosing its transactions to be mined from a fee maximization point of view?

(Asked by: username_0 on 2022-01-20)

Well, this is the way I've tried:

When a mined block arrives to my node, I compare it against a transaction selection algorithm using my mempool. (I know my mempool is different than the miner's, and that's the point so keep reading ;-) )

The transaction selection algorithm sorts transactions in the usual greedy way: using the regular Ancestor Set Based (ASB) algorithm described [here](https://gist.github.com/murchandamus/5cb413fe9f26dbce57abfd344ebbfaf2#file-candidate-set-based-block-building-md), and considering transaction dependencies and [CPFP](https://bitcoinops.org/en/topics/cpfp/), so basically is the same as invoking `getblockTemplate` with the state of my mempool just before the block arrives. (I also compare the incoming block by using the last `getBlockTemplate` result of bitcoind but as it's only calculated each 30s the results are not accurate).

An example of a comparison is shown [here](https://mempoolexplorer.com/block/last/OURS), (my webpage, in development). I divide the transactions in sets whether they were ignored by the miner (from my node point of view), are in common with me, ignored by me, relayed to me, or not relayed to me.

And, of course, I also measure the fees I would have collected compared to the miner's block (taking into account the incoming block coinbase transaction size for better accuracy). You can check the results of the last blocks [here](https://mempoolexplorer.com/block/OURS), and an aggregate for the miners [here](https://mempoolexplorer.com/miner).

This could give me an idea about how good a miner is selecting its transactions and/or has good network connectivity (in average, and against my mempool), but as I have no way of knowing the state of the miners mempool before they mine a block (nor when I receive it), this effort seems inaccurate.

I make the assumption that a received block and my block template can be compared. But as the block propagation time is not, by any means, negligible, the comparison is skewed giving the idea that my algorithm/network situation is better. The reality is that I am receiving transactions while the block is being propagated to me, and thus, I have normally a bigger mempool than the miner when the block was mined. A bigger mempool gives my algorithm the opportunity to search for better transactions which had no opportunity to be mined by miners.

So, is the accuracy of this methodology worthy? I've assumed its not. But as block propagation time is getting smaller (see [this](https://www.dsn.kastel.kit.edu/bitcoin/?ref=hackernoon.com#latency)) And the results for some blocks/miners seems really different (see [this](https://mempoolexplorer.com/block/719478/BITCOIND) block for example) I have my doubts.

Thanks in advance.

**Tags:** mining-pools, mining-theory, mining-profitability, mining-reward, mempool


---

## 1 answers

### Answer by username_1 on 2022-01-26. Score: 2 | Accepted answer

As you describe, you cannot distinguish the reason for the divergence between the block you received and the block you get from `getblocktemplate`.

It may be helpful to isolate the reasons:

* If you are trying to compare algorithms, you should try building a block with `getblocktemplate` (`gbt`) and with your own algorithm from the same mempool.
* If you're trying to compare network propagation, you may want to run multiple nodes, and assume that the miner built with `gbt` given everything that they had seen at this point. You may even want to keep track of when a transaction was seen, to reason about whether it is fathomable that it hasn't been seen by the miner.  
  I think it's reasonable to assume that miners are building the best
  possible block according to `gbt`, although odd ordering of transactions may indicate some manual prioritization of transactions. However, you will have at least two
  sources of error: the latency from block propagation, and the delay between the mining pool operator giving out a template and the executing miner discovering the block and announcing it. However, these two delays may be too high for the block content to be an accurate representation of the mining pool's mempool content.

From what I understand, other research projects looking into transaction propagation measure it by keeping track of when nodes announce txids/block ids to them. It wouldn't be trivial to identify the nodes operated by miners to measure their network quality, though, if they are even part of the open network and not moated by border nodes.

> **Comments:**
> **username_0**: Thanks for the elaborate answer username_1. Sorry if the msg I sent you via twitter confused you. I want to compare the mining pools for how good they are choosing its transactions, not to algorithms between them as you have done with ASB/CSB algorithms. I now have understood the way you have compared both and it's not the same approach as mine.  As you says, I have to run multiple nodes in different geographic localizations and compare the results to see if there is some difference in lost reward from my point(s) of view. And that is the most I can do I think.  

---

