Skip to content

Refactor and improve transaction error retry logic in ViemBlockchainClientAdapter #1775

@kyzooghost

Description

@kyzooghost

Description

Refactor and improve the _shouldRetryViemSendRawTranasctionError function in ViemBlockchainClientAdapter to enhance maintainability, readability, and testability. The function currently contains hardcoded error codes, complex nested conditionals, and a typo in its name ("Tranasction" → "Transaction").

Motivation

This function is critical for transaction retry logic and determines which errors should trigger retries. We want to improve

  • Maintainability and readability
  • Correctness
  • Documentation

Tasks

  • Fix typo in function name from _shouldRetryViemSendRawTranasctionError to _shouldRetryViemSendRawTransactionError
  • Create constants/enums file for RPC error codes, HTTP status codes, and error type names with documentation
  • Refactor function to use extracted constants instead of magic numbers
  • Restructure function logic to reduce nesting (consider early returns, helper functions, or lookup tables)
  • Default retry behavior: Current default to retry unknown errors might be too aggressive - consider documenting or reviewing this decision

Risks

  • Refactoring might inadvertently change retry logic - ensure comprehensive test coverage

Remember to

  • Add the documentation label in case there is an impact on the documentation
  • Add priority and team labels
  • Add Task for updating the Runbook or adding/updating existing metrics and alerts.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions