Skip to content

Add PredicateTxGenerator#87

Open
tokatoka wants to merge 1 commit into
oss-garage:masterfrom
tokatoka:tx_collision
Open

Add PredicateTxGenerator#87
tokatoka wants to merge 1 commit into
oss-garage:masterfrom
tokatoka:tx_collision

Conversation

@tokatoka

@tokatoka tokatoka commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

This PR adds PredicateTxGenerator that

  1. probes the transactions inside the mempools
  2. based on the mempools's utxos, we decide to chain more transactions to it. How we choose the transactions to put onto is decided by a predicate given by the user of this module

for example:

  • PredicateTxGenerator::double_spend() is the same as the previous DoubleSpendGenerator that spends a transaction who has another existing transactions that spend it.
  • PredicateTxGenerator::chain_spend() extends the chain of transactions, it looks for a transaction that nobody spends, and if it is found, it just spends it.

@tokatoka tokatoka force-pushed the tx_collision branch 4 times, most recently from 26c99aa to 2711ac8 Compare December 19, 2025 13:24
@tokatoka tokatoka changed the title Add DoubleSpendGenerator Add PredicateTxGenerator Dec 19, 2025
@tokatoka tokatoka force-pushed the tx_collision branch 2 times, most recently from 9ad7b6d to 185b1dc Compare December 19, 2025 13:39
// Map from blockhash to (block variable index, list of transaction variable indices)
block_tx_var_map: HashMap<bitcoin::BlockHash, (usize, usize, Vec<usize>)>,
// Map from txid to tx variable index
txo_var_map: HashMap<Txid, VariableIndex>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should track outpoints (txid + index) instead of txid since the first insert will always be the 0-index of a tx and because of this I think the generator will only ever choose to build off of the 0-index even if there are other outputs.

Ok((const_tx_var, outputs))
}

/// `PredicateTxGenerator` generates transactions that spends the transactions in mempool depending on the given predicate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feel free to correct me, but PredicateTxGenerator is choosing txs based on mempool state. So the insertion anchor has to correspond to the point where that mempool state is already true, or at least can reasonably be true. Isn't anchoring on TakeTxo too early?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Too early since the tx it's building off of might not have been sent yet? It does use get_random_instruction_index_from after the TakeTxo point, so it would succeed sometimes. To be correct all the time, it would need to track where SendTx for the tx is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants