Skip to content

fix: process all batch pegout members when one is missing from the db - #482

Open
ronaldsg20 wants to merge 1 commit into
release/4.2.0from
fix/daemon-sync
Open

fix: process all batch pegout members when one is missing from the db#482
ronaldsg20 wants to merge 1 commit into
release/4.2.0from
fix/daemon-sync

Conversation

@ronaldsg20

Copy link
Copy Markdown
Member

processBatchPegouts walks the releaseRskTxHashes concatenation from a batch_pegout_created event and hit break as soon as a member had no matching record. Every remaining member of that batch was silently abandoned, including members that were present in the db.

This triggers whenever a batch straddles the daemon's sync start block: requests made before the anchor were never indexed, so the first of them aborts the loop. Observed on mainnet batch 0x76d01052...627e65 (block 9219132), whose members 0 and 1 predate anchor 9216715. Members 2, 3 and 4 were left stuck at RECEIVED indefinitely even though the daemon had synced well past every later stage of their lifecycle.

Skip only the missing member instead. The index still has to advance, because it maps to the btc tx output index — leaving it in place would misalign batchPegoutIndex and the generated rskTxHash key.

Log the batch size and a matched/skipped tally around the loop so an incomplete walk is visible without enabling debug logging.

Add a regression test built from the five real members of that mainnet batch, asserting that all members are visited, that only those found are written, and that the surviving pegouts keep indices 2, 3 and 4.

Copilot AI balanced review requested due to automatic review settings September 10, 2026 17:24
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ronaldsg20
ronaldsg20 marked this pull request as ready for review September 10, 2026 17:30
processBatchPegouts walks the releaseRskTxHashes concatenation from a
batch_pegout_created event and hit `break` as soon as a member had no
matching record. Every remaining member of that batch was silently
abandoned, including members that were present in the db.

This triggers whenever a batch straddles the daemon's sync start block:
requests made before the anchor were never indexed, so the first of them
aborts the loop. Observed on mainnet batch 0x76d01052...627e65 (block
9219132), whose members 0 and 1 predate anchor 9216715. Members 2, 3 and
4 were left stuck at RECEIVED indefinitely even though the daemon had
synced well past every later stage of their lifecycle.

Skip only the missing member instead. The index still has to advance,
because it maps to the btc tx output index — leaving it in place would
misalign batchPegoutIndex and the generated rskTxHash key.

Log the batch size and a matched/skipped tally around the loop so an
incomplete walk is visible without enabling debug logging.

Add a regression test built from the five real members of that mainnet
batch, asserting that all members are visited, that only those found are
written, and that the surviving pegouts keep indices 2, 3 and 4.

Point .env.test at the current testnet blockbook host so CI matches the
updated assertion in btc-last-block.service.unit.ts. The workflow copies
.env.test over .env before running the suite, so the stale blockbook-01
hostname failed the pipeline.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 10, 2026 17:36

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lserra-iov lserra-iov left a comment

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.

How can a member end up without a matching record? The description blames the daemon's sync start block, but was actually the daemon behind at that point? What happens with those pegouts, are the statuses processed correctly? I think this is an improvement, but I'm afraid it might not fix the root cause of the reported issue.

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