Skip to content

Conversation

@arepala-uml
Copy link
Contributor

@arepala-uml arepala-uml commented Dec 7, 2025

  1. Made changes to emit an input event without the resolved inputs along with a log error message when kupo fails to give us data.

Closes #400


Summary by cubic

Emit input events even when Kupo fails to resolve transaction inputs, logging the error and sending events without resolved inputs. Fixes #400.

  • Migration
    • Consumers should handle nil resolvedInputs in input events.

Written for commit 45394a1. Summary will update automatically on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Improved transaction processing resilience. The system now logs errors and continues processing transactions even when input resolution fails, instead of aborting the entire flow. This ensures transaction processing remains functional in the presence of problematic inputs.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 7, 2025

📝 Walkthrough

Walkthrough

This change modifies error handling in transaction input resolution within the chain synchronization process. When resolveTransactionInputs(tx) fails in either handleRollForward or handleBlockFetchBlock, the code now logs the error and continues processing by emitting the transaction with resolvedInputs set to nil, rather than terminating execution immediately. This allows the processing pipeline to remain tolerant of transient resolution failures while still recording the failure event.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that all downstream code safely handles resolvedInputs being nil
  • Confirm both handleRollForward and handleBlockFetchBlock implement the error handling consistently
  • Check that the error logging via slog provides sufficient context for debugging (Kupo failure attribution)
  • Ensure the change doesn't mask unrecoverable errors or lead to unexpected nil pointer dereferences in transaction processing

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: Failure to fetch information from Kupo prevents output' accurately summarizes the main change: converting a failure path to emit events with nil resolvedInputs instead of terminating.
Linked Issues check ✅ Passed The code changes directly address all requirements from issue #400: emit input events when Kupo fails, log errors, and allow nil resolvedInputs in those events.
Out of Scope Changes check ✅ Passed All changes in chainsync.go are narrowly scoped to handling Kupo fetch failures by converting error returns to error logging with nil input emission, directly addressing the linked issue.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kupo_events_fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arepala-uml arepala-uml marked this pull request as ready for review December 7, 2025 20:23
@arepala-uml arepala-uml requested a review from a team as a code owner December 7, 2025 20:23
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
input/chainsync/chainsync.go (2)

410-418: Kupo resolution failures now logged and tolerated (matches PR intent)

Turning resolveTransactionInputs failures into a logged error while emitting the transaction with resolvedInputs = nil achieves the goal of not blocking chainsync/blockfetch when Kupo is unavailable or misbehaving, while still surfacing the problem via logs. Semantically this is consistent in both handleRollForward and handleBlockFetchBlock.

As a small polish, you might want to add the transaction hash/index as structured fields in this log to make it easier to correlate problematic inputs in production.

Also applies to: 497-505


664-668: Avoid defer cancel() inside the per-input loop

defer cancel() inside the for _, input := range transaction.Inputs() loop means earlier contexts aren’t canceled until resolveTransactionInputs returns, which keeps more timers/goroutines alive than necessary. It’s more efficient and idiomatic to call cancel() immediately after k.Matches returns:

-        ctx, cancel := context.WithTimeout(
-            context.Background(),
-            defaultKupoTimeout,
-        )
-        defer cancel()
-
-        // Create a simple transaction identifier
-        txID := fmt.Sprintf("%d@%s", txIndex, txId)
-        matches, err := k.Matches(ctx, kugo.Transaction(txID))
+        ctx, cancel := context.WithTimeout(
+            context.Background(),
+            defaultKupoTimeout,
+        )
+
+        // Create a simple transaction identifier
+        txID := fmt.Sprintf("%d@%s", txIndex, txId)
+        matches, err := k.Matches(ctx, kugo.Transaction(txID))
+        cancel()

This keeps behavior the same while tightening resource usage per input.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22f50b0 and 45394a1.

📒 Files selected for processing (1)
  • input/chainsync/chainsync.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@arepala-uml arepala-uml merged commit 02a47b2 into main Dec 8, 2025
11 checks passed
@arepala-uml arepala-uml deleted the kupo_events_fix branch December 8, 2025 05:56
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.

Failure to fetch information from Kupo prevents output

3 participants