Skip to content

Commit d580b44

Browse files
authored
Merge pull request #143 from brunoerg/2026-06-cmpctblock-fix
Avoid O(prefills × block-txs) work when compiling cmpctblocks
2 parents 852cd8d + 51b9834 commit d580b44

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

fuzzamoto-ir/src/compiler.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,12 +1789,16 @@ impl Compiler {
17891789
});
17901790
}
17911791
Operation::AddPrefillTx => {
1792-
let block = self
1793-
.get_input::<bitcoin::Block>(&instruction.inputs, 1)?
1794-
.clone();
1795-
let tx_to_prefill = self.get_input::<Tx>(&instruction.inputs, 2)?;
1796-
let tx_to_prefill_id = tx_to_prefill.id;
1792+
let prefill_len = self
1793+
.get_input::<PrefillTransactions>(&instruction.inputs, 0)?
1794+
.indices
1795+
.len();
1796+
let block = self.get_input::<bitcoin::Block>(&instruction.inputs, 1)?;
1797+
if prefill_len >= block.txdata.len().saturating_sub(1) {
1798+
return Ok(());
1799+
}
17971800

1801+
let tx_to_prefill_id = self.get_input::<Tx>(&instruction.inputs, 2)?.id;
17981802
// Find the position of this tx within the block's non-coinbase transactions.
17991803
// If the tx is not part of this block, skip it silently.
18001804
let Some(position) = block.txdata[1..]

0 commit comments

Comments
 (0)