Skip to content

test: Horizon duplicate-hash chaos with idempotency - #789

Open
Derekwalter999 wants to merge 1 commit into
RevoraOrg:masterfrom
Derekwalter999:test/horizon-duplicate-hash-chaos
Open

test: Horizon duplicate-hash chaos with idempotency#789
Derekwalter999 wants to merge 1 commit into
RevoraOrg:masterfrom
Derekwalter999:test/horizon-duplicate-hash-chaos

Conversation

@Derekwalter999

@Derekwalter999 Derekwalter999 commented Jul 31, 2026

Copy link
Copy Markdown

Description

Resolves #707 Stellar Horizon chaos: submit-endpoint duplicate-hash returns with idempotency assertion.

Context

When the Stellar submission worker encounters a timeout or is aggressively scaling, it might attempt to re-submit a transaction that has already been ingested by the network, resulting in a DUPLICATE status response from the Horizon endpoint. Alternatively, a client-side bug could trigger an actual true-duplicate submission.

Previously, StellarSubmissionService would throw an Errors.conflict upon receiving this status. This PR modifies the service to treat DUPLICATE responses as successes to prevent double-persisting, preserving idempotency without propagating a conflict error upstream.

Changes Made

  • StellarSubmissionService Update: Modified the sendTransactionWithRetry block to catch DUPLICATE responses, immediately returning the pending/successful result to the caller instead of tossing a conflict exception.
  • Metric Emission: Added the submission.duplicate.recovered counter metric via globalMetrics.increment() when a duplicate hash is gracefully recovered.
  • Chaos Testing Harness: Created src/__tests__/chaos/horizonDuplicateHash.test.ts to assert against:
    • First-attempt duplicates (Retry recovery scenarios where the transaction was already successful).
    • True-duplicates (Simulating a client bug resulting in a double-submit).
    • Concurrent duplicate submissions (Two decoupled workers racing to submit the exact same transaction hash; one gets pending, one gets duplicate, but they both accurately coalesce and resolve gracefully).

Security & Correctness Assumptions Validated

  • The cache size and deduplication sets are appropriately bypassed and checked.
  • No duplicate database/ledger commits occur downstream because the service normalizes the DUPLICATE response as a standard, already processed success.
  • Minimum 95% test coverage maintained.

Checklist

  • Code successfully simulates and handles Horizon returning a duplicate hash.
  • Includes both retry recovery and true-duplicate tests.
  • Asserts concurrency coalescing (single ledger outcome).
  • The submission.duplicate.recovered metric counter is actively emitted.
  • Test suite executes without failure.

@drips-wave

drips-wave Bot commented Jul 31, 2026

Copy link
Copy Markdown

@Derekwalter999 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Stellar Horizon chaos: submit-endpoint duplicate-hash returns with idempotency assertion

1 participant