Skip to content

Conversation

NumberFour8
Copy link
Contributor

Fixes errors like logical error: inconsistent key-id binding, caused by re-announcements.

Now the key-id binding is inserted only when the announcement is made for the first time, as subsequent updates of key-binding are not necessary.

Fixes errors like `logical error: inconsistent key-id binding`, caused by re-announcements.

Now the key-id binding is inserted only when the announcement is made for the first time, as subsequent updates of key-binding are not necessary.
@NumberFour8 NumberFour8 added this to the 3.0.0 milestone Jun 19, 2025
@NumberFour8 NumberFour8 requested a review from a team June 19, 2025 14:59
@NumberFour8 NumberFour8 self-assigned this Jun 19, 2025
Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

📝 Walkthrough

Walkthrough

The changes update log message formatting in chain/indexer/src/handlers.rs, refine result handling and cache update conditions in db/sql/src/accounts.rs, and clarify comments in db/sql/src/cache.rs. No logic or control flow is altered, and no public interfaces are changed.

Changes

File(s) Change Summary
chain/indexer/src/handlers.rs Updated log formatting specifiers for address and public key fields in two log statements.
db/sql/src/accounts.rs Made cache update conditional on successful DB insert and changed error handling to log warnings only.
db/sql/src/cache.rs Improved comments in update_key_id_binding to clarify match arm scenarios; no logic changes.

Possibly related PRs

Suggested labels

crate:chain-indexer, crate:hopr-db-entity

Suggested reviewers

  • Teebor-Choka

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 85aece6 and 311e951.

📒 Files selected for processing (3)
  • chain/indexer/src/handlers.rs (2 hunks)
  • db/sql/src/accounts.rs (2 hunks)
  • db/sql/src/cache.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: hoprd / docker
  • GitHub Check: hopli / docker
  • GitHub Check: Docs / Rust docs
  • GitHub Check: Linter
  • GitHub Check: zizmor
  • GitHub Check: Build Candidate Binaries (hoprd)
  • GitHub Check: Build Candidate Binaries (hopli)
  • GitHub Check: tests-unit
  • GitHub Check: tests-unit-nightly
  • GitHub Check: tests-smart-contracts
  • GitHub Check: Add PR labels
🔇 Additional comments (5)
chain/indexer/src/handlers.rs (2)

138-138: LGTM: Improved log formatting for address display.

Changing from debug formatting (?) to display formatting (%) makes the address more readable in warning logs, which is appropriate for user-facing log messages.


166-167: LGTM: Consistent formatting improvements for debugging logs.

The changes improve log readability by:

  • Using display formatting (%) instead of debug formatting (?) for both address and public key
  • Simplifying key_binding.ed25519_pub_key instead of accessing the inner field .0, suggesting the type now implements Display directly

These formatting improvements will help with debugging the key-binding issues mentioned in the PR objectives.

db/sql/src/cache.rs (1)

250-252: LGTM! Improved comment clarity.

The updated comment provides valuable context about when this scenario occurs during re-announcements, helping developers understand the expected behavior rather than treating it as an unexpected case.

db/sql/src/accounts.rs (2)

243-243: LGTM! Proper result handling.

Capturing the insert result enables the conditional cache update logic that follows, which is essential for the fix.


255-261: Excellent fix for the key-binding error issue.

This change correctly implements the solution described in the PR objectives:

  1. Prevents re-announcement issues: The key-id binding is only updated on successful account insertion (res.is_ok()), not on re-announcements where the record already exists.

  2. Improved error handling: Cache update failures are logged as warnings rather than propagating errors, which is appropriate since cache updates are not critical for the operation's success.

This should resolve the "logical error: inconsistent key-id binding" errors mentioned in the PR objectives.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@NumberFour8 NumberFour8 marked this pull request as ready for review June 19, 2025 15:00
@NumberFour8 NumberFour8 changed the title Fix key-binding errors fix(indexer): key-binding errors Jun 19, 2025
@NumberFour8 NumberFour8 enabled auto-merge (squash) June 19, 2025 15:18
@NumberFour8 NumberFour8 merged commit ea300b2 into master Jun 19, 2025
44 of 48 checks passed
@NumberFour8 NumberFour8 deleted the lukas/fix-key-binding-errors branch June 19, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants