Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FreshEyes] Fee Estimation: Ignore all transactions with an in-block child #16

Open
wants to merge 3 commits into
base: bitcoin-fresheyes-staging-master-30079
Choose a base branch
from

Conversation

adamjonas
Copy link
Owner

The author ismaelsadeeq wrote the following PR called Fee Estimation: Ignore all transactions with an in-block child, issue number 30079 in bitcoin/bitcoin cloned by FreshEyes below:

Another attempt at #25380 with an alternate approach

This PR updates CBlockPolicyEstimator to ignore all transactions with an in-block child when a new block is received.
This fixes the assumption that all transactions are confirmed solely because of their fee rate.
As some transactions are confirmed due to a CPFP by some child.

The downside of this approach is that transactions that are not CPFP’d will also be ignored.

The correct approach is to linearize all transactions removed from the mempool because of the new block, and only ignore transactions whose mining score is not the same with their the fee rate.

I have a branch that implements this using a mini miner:

  • mini miner: Linearize should also return package fees and sizes

  • fees: Add function computing ancestors and descendants of transactions

  • fees: Ignore transactions that are CPFP'd

The implication of the approach in this branch is that the constructor used and the linearization code will be removed post-cluster mempool implementation:

Rework mini_miner to utilize cluster mempool features

Another approach I contemplated was to replicate the linearization code into policy/fees.cpp and use it but this means having duplicate code in policy/fees.cpp and node/mini_miner.cpp. Considering that post-cluster mempool, we will transition to tracking chunks rather than individual transactions and the specification for this is already under discussion here.

This PR is an interim solution, focusing on ignoring transactions with in-block children this is safe to use considering that the majority of transactions are individual transactions. Upon implementing the cluster mempool, we will just track chunks and make the fee estimator package aware.

Copy link

There were 37 issue comments left by 6 reviewers for the pull request

txs.append(tx)
batch_send_tx = (broadcaster.sendrawtransaction.get_request(tx["hex"]) for tx in txs)
broadcaster.batch(batch_send_tx)
self.sync_mempools(wait=0.1, nodes=[broadcaster, miner])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 authors commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1599579906 at 2024/05/14, 08:13:00 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1600088583 at 2024/05/14, 13:54:38 UTC.

@@ -129,6 +129,15 @@ def make_tx(wallet, utxo, feerate):
)


def send_tx(wallet, node, utxo, feerate):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 authors commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1599589458 at 2024/05/14, 08:19:59 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1600383232 at 2024/05/14, 17:07:24 UTC.

return wallet.send_self_transfer(
from_node=node,
utxo_to_spend=utxo,
fee_rate=Decimal(feerate * 1000) / COIN,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 authors commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1599591670 at 2024/05/14, 08:21:34 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1600311972 at 2024/05/14, 16:13:46 UTC.

"txid": tx["txid"],
"vout": 0,
"value": Decimal(tx["tx"].vout[0].nValue) / COIN
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 authors commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1599602598 at 2024/05/14, 08:29:20 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1600400559 at 2024/05/14, 17:22:12 UTC.

"""
# The broadcaster and block producer
broadcaster = self.nodes[0]
miner = self.nodes[1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An author commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1599613474 at 2024/05/14, 08:37:13 UTC.

@@ -383,6 +401,79 @@ def test_acceptstalefeeestimates_option(self):
assert_equal(self.nodes[0].estimatesmartfee(1)["feerate"], fee_rate)


def send_and_mine_child_tx(self, broadcaster, miner, parent_tx, feerate):
u = {"txid": parent_tx["txid"], "vout": 0, "value": Decimal(parent_tx["tx"].vout[0].nValue) / COIN}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 authors commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1602965411 at 2024/05/16, 09:20:33 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1602989484 at 2024/05/16, 09:33:04 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1603035220 at 2024/05/16, 10:00:53 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1603130595 at 2024/05/16, 10:57:04 UTC.

@@ -662,6 +662,22 @@ bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const Remo
return true;
}

void CBlockPolicyEstimator::removeParentTxs(const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 authors commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1603028373 at 2024/05/16, 09:56:18 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1603098402 at 2024/05/16, 10:32:57 UTC
  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1603108416 at 2024/05/16, 10:39:03 UTC.

@@ -303,6 +303,9 @@ class CBlockPolicyEstimator : public CValidationInterface
/** Process a transaction confirmed in a block*/
bool processBlockTx(unsigned int nBlockHeight, const RemovedMempoolTransactionInfo& tx) EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);

/* Remove transactions with child from fee estimation tracking stats */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An author commented here with:

  • comment link https://github.com/bitcoin/bitcoin/pull/30079#discussion_r1603032016 at 2024/05/16, 09:58:36 UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants