Skip to content

refactor(omni-relayer): error handling#37

Open
frolvanya wants to merge 11 commits into
mainfrom
refactor/error-handling
Open

refactor(omni-relayer): error handling#37
frolvanya wants to merge 11 commits into
mainfrom
refactor/error-handling

Conversation

@frolvanya

@frolvanya frolvanya commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Closes Near-One/omni-bridge#443

This pull request introduces significant improvements to error handling and message processing in the omni-relayer service, focusing on making event handling more robust and predictable. The main changes involve standardizing how unprocessable or malformed events are handled (favoring removal over retries), simplifying error branches, and refining the NATS message acknowledgment logic for better reliability and maintainability.

Error Handling and Event Removal Improvements:

  • Changed event handlers (process_init_transfer_event, process_evm_transfer_event, process_deploy_token_event) to log a warning and return EventAction::Remove for routing mismatches or parsing errors, instead of failing with an error. This ensures that malformed or unexpected events are cleanly removed from the queue. [1] [2] [3] [4] [5] [6]
  • Simplified error handling in event processing by removing complex error matching and retries for certain bridge errors, opting to bail out immediately with a concise error message when necessary. [1] [2] [3]

NATS Message Acknowledgment Logic:

  • Introduced the NatsAckDecision enum and compute_ack_decision function to centralize and clarify how NATS message acknowledgments are decided based on event processing results, message age, and delivery attempts. This makes the retry/backoff/termination logic more maintainable and predictable. [1] [2]
  • Updated handle_nats_ack to use the new acknowledgment decision logic, ensuring that only removable events are acknowledged and others are retried or terminated as appropriate.

General Code Consistency and Robustness:

  • Standardized the removal of fee keys in process_message to only occur when EventAction::Remove is returned, preventing unnecessary removals on generic errors. [1] [2] [3] [4]
  • Improved handling of missing configuration (e.g., missing nonce manager for fast transfers) by logging a warning and removing the event, instead of returning an error.
  • Added required arguments (jsonrpc_client, signer) to various event handler calls for consistency and future extensibility. [1] [2] [3]

Other:

  • Bumped omni-relayer crate version from 0.6.22 to 0.6.23.
  • Minor import cleanup in evm.rs.

These changes collectively make the relayer more resilient to malformed events and external errors, and improve the maintainability of the event processing and message acknowledgment code.

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.

Pull request overview

This PR refactors relayer worker error handling across multiple chain-specific flows, aiming to standardize retry vs remove behavior and improve NEAR transaction outcome resolution using JSON-RPC.

Changes:

  • Replace many bail!() paths with warn!() + EventAction::Remove for routing mismatches / invalid inputs.
  • Route successful NEAR tx submissions through utils::near::resolve_tx_action(...) to decide whether to retry based on receipt outcomes.
  • Refactor NATS ack/nak/term decision logic into a shared helper with unit tests, and bump omni-relayer version to 0.6.23.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
omni-relayer/src/workers/mod.rs Centralizes JetStream ack decision logic and adjusts fee-mapping cleanup behavior; adds tests.
omni-relayer/src/workers/near.rs Refines fast-transfer initiation and “non-retryable” handling in NEAR-side worker logic.
omni-relayer/src/workers/utxo.rs Updates UTXO-related flows to remove on routing/parse mismatches and to resolve tx outcomes via JSON-RPC.
omni-relayer/src/workers/evm.rs Aligns EVM flow behavior with new “remove vs retry” approach and NEAR receipt resolution.
omni-relayer/src/workers/solana.rs Aligns Solana flow behavior with new “remove vs retry” approach and NEAR receipt resolution.
omni-relayer/src/workers/starknet.rs Aligns Starknet flow behavior with new “remove vs retry” approach and NEAR receipt resolution.
omni-relayer/Cargo.toml Bumps relayer crate version.
Cargo.lock Updates lockfile for the version bump.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread omni-relayer/src/workers/mod.rs
Comment thread omni-relayer/src/workers/mod.rs Outdated
Comment thread omni-relayer/src/workers/mod.rs Outdated
Comment thread omni-relayer/src/workers/mod.rs Outdated
Comment thread omni-relayer/src/workers/mod.rs Outdated
Comment thread omni-relayer/src/workers/mod.rs Outdated

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.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.

Comment thread omni-relayer/src/workers/mod.rs
Comment thread omni-relayer/src/workers/mod.rs
Comment thread omni-relayer/src/workers/mod.rs Outdated
Comment thread omni-relayer/src/workers/mod.rs Outdated
@frolvanya
frolvanya requested a review from Copilot June 4, 2026 16:03
@frolvanya
frolvanya marked this pull request as ready for review June 4, 2026 16:03
@frolvanya
frolvanya requested a review from a team as a code owner June 4, 2026 16:03

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.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Comment thread omni-relayer/src/workers/mod.rs
Comment thread omni-relayer/src/workers/near.rs

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.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Comment thread omni-relayer/src/workers/mod.rs

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.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Comment thread omni-relayer/src/workers/near.rs
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.

[OmniRelayer]: refactor current error handling approach

2 participants