fix(minibf): source address-utxo tx_hash from TxoRef, not archive block_data#1009
fix(minibf): source address-utxo tx_hash from TxoRef, not archive block_data#1009adrian1-dot wants to merge 1 commit into
Conversation
…ck_data
GET /addresses/{address}/utxos returned an empty tx_hash for any UTxO whose
source block aged out of the archive window: tx_hash was built from a
block_data archive lookup, and on a miss (block_data == None, governed by
max_history) unwrap_or_default yields "". Source it from the UTxO's own
TxoRef (always present) instead.
📝 WalkthroughWalkthroughThe PR changes how ChangesUTxO tx_hash derivation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/minibf/src/mapping.rs (1)
484-487: ⚡ Quick winAdd a regression test for the archive-miss path.
This mapping change looks correct, but the exact failure mode here was
block_data == None, so it should be covered with an assertion thattx_hashstill comes fromTxoRefand is non-empty when history has aged out. Please also run the required Rust checks for this change before merge. As per coding guidelines, "Runcargo test --workspace --all-featuresto verify functionality of all changes".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/minibf/src/mapping.rs` around lines 484 - 487, Add a regression test that exercises the archive-miss path where block_data == None and asserts that the produced mapping's tx_hash is taken from the UTxO's TxoRef (i.e., non-empty and equal to self.txo_ref.0.to_string()); locate the mapping code in mapping.rs that sets tx_hash and write a test that simulates aged-out history / missing block_data and verifies tx_hash comes from TxoRef, then run cargo test --workspace --all-features to validate the change before merging.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/minibf/src/mapping.rs`:
- Around line 484-487: Add a regression test that exercises the archive-miss
path where block_data == None and asserts that the produced mapping's tx_hash is
taken from the UTxO's TxoRef (i.e., non-empty and equal to
self.txo_ref.0.to_string()); locate the mapping code in mapping.rs that sets
tx_hash and write a test that simulates aged-out history / missing block_data
and verifies tx_hash comes from TxoRef, then run cargo test --workspace
--all-features to validate the change before merging.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3b1b4f65-bed0-49cf-8a17-0e1e7a867c09
📒 Files selected for processing (1)
crates/minibf/src/mapping.rs
GET /addresses/{address}/utxosreturns an emptytx_hashfor any UTxO whose source block has aged out of the archive: the handler derivestx_hashfrom ablock_dataarchive lookup, and on a miss (block_data == None, governed bymax_history).unwrap_or_default()yields"". With the defaultmax_history = 10000this hits any UTxO older than the window; a Blockfrost client then rejects the 0-length hash.Fix: source
tx_hashfrom the UTxO's ownTxoRef(always present) instead of the archive lookup — identical value when the block is archived, correct value when it isn't.Repro: set a small
[sync] max_history, sync, query an address holding a UTxO created before the window →"tx_hash": "".Summary by CodeRabbit