AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 59 Cryptographic libraries

cryptonote_core: improve block template backlog handling

Public commit record

What the developer wrote

Authored by jeffro256

93/100 · Strong
cryptonote_core: improve block template backlog handling

Addresses several issues with miner block template:

1. Fixes key image conflict issue due to lazy transaction prefix
- This line checks whether the next tx candiates has conflicting key images with the rest of the block template:
https://github.com/monero-project/monero/blob/0f84863feda75574788e15c9691abecf57bc3f8f/src/cryptonote_core/tx_pool.cpp#L1744
- The function takes in a transaction prefix and parses the key images from it
- However, the transaction may or may not actually ever be deserialized, depending on the state of `m_input_cache`:
https://github.com/monero-project/monero/blob/0f84863feda75574788e15c9691abecf57bc3f8f/src/cryptonote_core/tx_pool.cpp#L1455-L1466
2. Deduplicates code between `tx_memory_pool::fill_block_template()` and `tx_memory_pool::get_block_template_backlog()`,
and thus converging the backlog lists between the 2 functions
3. Saves time creating block templates by skipping transaction blob readings and deserializations for some txs
4. Stops template candidate search after block is reasonably full and we are iterating through txs which lower coinbase reward
or exceed size limit by a "smallish" amount. Prevents us from unnecessarily reading thousands of useless tx metadatas under load.
May help https://github.com/seraphis-migration/monero/issues/293
5. Fixes block templates when coinbase transactions are > 600 bytes
6. Fills closer to block weight limit for small coinbase transactions
7. Fixes "Invalidating block template cache" spam while popping blocks / during reorgs
8. More accurate "expected block reward" field in RPC

Co-authored-by: SChernykh <15806605+SChernykh@users.noreply.github.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This Monero commit fixes a bug in how mining software picks transactions for the next block. The old code could accidentally include two transactions that spend the same 'key image' (like the same coin being spent twice), which would create an invalid block. It also cleans up and speeds up the transaction selection logic. The commit message explicitly calls this a 'key image conflict issue' and says it is fixed.

Recommended action

Treat this as a security-relevant correctness fix and include it in the next release. Mining pools, solo miners, and RPC consumers of get_miner_data should upgrade. Review the new get_block_template_backlog() behavior with overpick ratios to ensure RPC clients do not misinterpret non-profitable backlog entries as guaranteed inclusions.

Security signals we found

01

Fixes key image conflict in block template construction (commit message)

02

Replaces lazy transaction-prefix parsing with direct TXID-key_image index lookup for conflict detection

03

Changes key_images_container to boost::bimap for consistent bidirectional key-image/TXID mapping

04

Hardens insert_key_images and remove_transaction_keyimages against duplicate or mismatched entries

05

Adds overflow checks in block weight/fee accumulation

06

Removes deprecated DEBUG_CREATE_BLOCK_TEMPLATE validation block

Risk score

Why this scored 59/100

Our methodology →
Potential impact 18/30
Exploitability 10/25
Stealth signal 8/15
Affected reach 12/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.