Bug: auto-withdraw retries after successful Terra submit, shows FAILED #87

Closed
opened 2026-03-30 06:21:32 +00:00 by Brouie · 6 comments
Brouie commented 2026-03-30 06:21:32 +00:00 (Migrated from gitlab.com)

Anvil->LocalTerra E2E: auto-withdraw submits withdraw_submit to Terra successfully (txHash D668A506..., 'Transaction confirmed successfully' in console). But useAutoWithdrawSubmit fires again immediately, gets 'Withdrawal already submitted' rejection from Terra bridge, and TransferStatusPage shows HASH SUBMISSION FAILED from the retry error — hiding the successful first submission.

Console shows:

  1. submitOnTerra success: txHash=D668A506...
  2. Immediately re-enters triggerSubmit for same transfer
  3. Second submit rejected: 'Withdrawal already submitted'
  4. UI shows FAILED

The transfer actually succeeded on-chain but the user sees a failure. Found on v0.1.197/84cf7e4, Anvil->LocalTerra 99.50 TKNA nonce 5.

Anvil->LocalTerra E2E: auto-withdraw submits withdraw_submit to Terra successfully (txHash D668A506..., 'Transaction confirmed successfully' in console). But useAutoWithdrawSubmit fires again immediately, gets 'Withdrawal already submitted' rejection from Terra bridge, and TransferStatusPage shows HASH SUBMISSION FAILED from the retry error — hiding the successful first submission. Console shows: 1. submitOnTerra success: txHash=D668A506... 2. Immediately re-enters triggerSubmit for same transfer 3. Second submit rejected: 'Withdrawal already submitted' 4. UI shows FAILED The transfer actually succeeded on-chain but the user sees a failure. Found on v0.1.197/84cf7e4, Anvil->LocalTerra 99.50 TKNA nonce 5.
Brouie commented 2026-03-30 06:21:57 +00:00 (Migrated from gitlab.com)

mentioned in issue #67

mentioned in issue #67
PlasticDigits commented 2026-03-30 08:18:19 +00:00 (Migrated from gitlab.com)

mentioned in commit 19299b8d84

mentioned in commit 19299b8d84e9b325239df7a7963b1d10482755ac
PlasticDigits commented 2026-03-30 08:47:14 +00:00 (Migrated from gitlab.com)

Fix (landed on feat/solana-integration)

Cause: The Terra contract returns Withdrawal already submitted (with “withdrawal”), but the frontend only matched withdraw already submitted, so the duplicate-submit path was classified as a generic contract error. That skipped the recovery branch and surfaced Hash Submission Failed even when the first tx had succeeded.

What we changed:

  • Map withdrawal already submitted (and wasm-wrapped logs) to WITHDRAW_ALREADY_SUBMITTED, including inside the generic “execute wasm contract failed” handler.
  • Recover in useAutoWithdrawSubmit when a CONTRACT_ERROR still clearly indicates duplicate withdraw.
  • Harden destination polling: if localStorage already has a successful hash-submit tx for this transfer, do not treat transient “not found on chain” as failure or clear the submit guard (avoids a second auto-submit).

Tests: packages/frontend/src/services/terra/transaction.test.ts covers the contract wording and wasm-wrapped case.

@Brouie — could you re-run Anvil → LocalTerra auto-withdraw on a build that includes this commit and confirm you no longer see FAILED after a successful first submit? If anything still flakes, paste console + lifecycle steps. Thanks!

## Fix (landed on `feat/solana-integration`) **Cause:** The Terra contract returns *Withdrawal already submitted* (with “withdraw**al**”), but the frontend only matched *withdraw already submitted*, so the duplicate-submit path was classified as a generic contract error. That skipped the recovery branch and surfaced **Hash Submission Failed** even when the first tx had succeeded. **What we changed:** - Map *withdrawal already submitted* (and wasm-wrapped logs) to `WITHDRAW_ALREADY_SUBMITTED`, including inside the generic “execute wasm contract failed” handler. - Recover in `useAutoWithdrawSubmit` when a `CONTRACT_ERROR` still clearly indicates duplicate withdraw. - Harden destination polling: if localStorage already has a successful hash-submit tx for this transfer, do not treat transient “not found on chain” as failure or clear the submit guard (avoids a second auto-submit). **Tests:** `packages/frontend/src/services/terra/transaction.test.ts` covers the contract wording and wasm-wrapped case. @Brouie — could you re-run **Anvil → LocalTerra** auto-withdraw on a build that includes this commit and confirm you no longer see FAILED after a successful first submit? If anything still flakes, paste console + lifecycle steps. Thanks!
PlasticDigits commented 2026-04-01 01:55:18 +00:00 (Migrated from gitlab.com)

Implemented fix in useAutoWithdrawSubmit: per-transfer async lock (survives Strict Mode / double effects), early exit when localStorage already has a successful hash submit, and broader duplicate-withdraw error recovery (plain Error messages with the same wording).

Pushed on feat/solana-integration (commit 7d21f4c).

@Brouie could you review when you have a chance?

Implemented fix in `useAutoWithdrawSubmit`: per-transfer async lock (survives Strict Mode / double effects), early exit when localStorage already has a successful hash submit, and broader duplicate-withdraw error recovery (plain `Error` messages with the same wording). Pushed on `feat/solana-integration` (commit 7d21f4c). @Brouie could you review when you have a chance?
PlasticDigits commented 2026-04-01 01:55:19 +00:00 (Migrated from gitlab.com)

mentioned in commit 7d21f4cfa3

mentioned in commit 7d21f4cfa386ccc1b1c044232d52e9b242ade95f
Brouie commented 2026-04-01 04:52:25 +00:00 (Migrated from gitlab.com)

verified -- no duplicate auto-withdraw observed on today's session. Terra->EVM auto-withdraw fires once, 'Withdrawal already submitted' correctly caught on retry. duplicate prevention commit 7d21f4c confirmed working.

verified -- no duplicate auto-withdraw observed on today's session. Terra->EVM auto-withdraw fires once, 'Withdrawal already submitted' correctly caught on retry. duplicate prevention commit 7d21f4c confirmed working.
Brouie (Migrated from gitlab.com) closed this issue 2026-04-01 04:52:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-bridge-monorepo#87
No description provided.