Bug: Terra->Solana withdraw_execute fails -- token_mapping AccountNotInitialized (3012) #104

Closed
opened 2026-04-10 04:14:36 +00:00 by Brouie · 8 comments
Brouie commented 2026-04-10 04:14:36 +00:00 (Migrated from gitlab.com)

Mainnet v0.1.82 (7cb18b3 + operator hotfix 4/10)

Terra->Solana 0.997 testa nonce 53 (hash 0xfda305a034140568...). Deposit OK, withdrawSubmit OK, operator approved, but withdraw_execute simulation fails:

AnchorError caused by account: token_mapping. Error Code: AccountNotInitialized. Error Number: 3012.
Program 4XX8ndYXupw4Sb4SsRgAPTmBJJjfZbg8rWjj87iKEhVt consumed 11653 of 200000 compute units

BSC->Solana works fine (same token, same wallet). Likely the token_mapping PDA for the Terra->Solana path was never registered on the bridge program.

Also affects the 4/9 stuck transfer: Terra->Solana 1.994 testa nonce 52 (0x12b359b812c0e805...).

Acceptance criteria:

  • token_mapping PDA registered for Terra->Solana testa path
  • withdraw_execute succeeds for Terra-origin transfers
Mainnet v0.1.82 (7cb18b3 + operator hotfix 4/10) Terra->Solana 0.997 testa nonce 53 (hash 0xfda305a034140568...). Deposit OK, withdrawSubmit OK, operator approved, but withdraw_execute simulation fails: ``` AnchorError caused by account: token_mapping. Error Code: AccountNotInitialized. Error Number: 3012. Program 4XX8ndYXupw4Sb4SsRgAPTmBJJjfZbg8rWjj87iKEhVt consumed 11653 of 200000 compute units ``` BSC->Solana works fine (same token, same wallet). Likely the token_mapping PDA for the Terra->Solana path was never registered on the bridge program. Also affects the 4/9 stuck transfer: Terra->Solana 1.994 testa nonce 52 (0x12b359b812c0e805...). Acceptance criteria: - [ ] token_mapping PDA registered for Terra->Solana testa path - [ ] withdraw_execute succeeds for Terra-origin transfers
PlasticDigits commented 2026-04-13 03:58:06 +00:00 (Migrated from gitlab.com)

@brouie Triage (repo main): token_mapping PDAs use seeds [b"token", src_chain_4, remote_token_32] consistently in withdraw_submit and withdraw_execute. The repo already has packages/contracts-solana/scripts/register-mainnet-tokens.ts registering BSC, opBNB, and Terra rows (including Terra testa). If mainnet still hits 3012, please verify the on-chain account exists for the failing (src_chain, src_token) pair and re-run that script with the bridge admin signer if needed; also confirm the execute UI resolves the same src_token bytes as submit (transfer record / Terra encoding). No program change expected from this triage. Please verify and close if resolved.

@brouie Triage (repo `main`): `token_mapping` PDAs use seeds `[b"token", src_chain_4, remote_token_32]` consistently in `withdraw_submit` and `withdraw_execute`. The repo already has `packages/contracts-solana/scripts/register-mainnet-tokens.ts` registering BSC, opBNB, and Terra rows (including Terra testa). If mainnet still hits 3012, please verify the on-chain account exists for the failing `(src_chain, src_token)` pair and re-run that script with the bridge admin signer if needed; also confirm the execute UI resolves the same `src_token` bytes as submit (transfer record / Terra encoding). No program change expected from this triage. Please verify and close if resolved.
Brouie commented 2026-04-13 04:05:32 +00:00 (Migrated from gitlab.com)

mentioned in issue #105

mentioned in issue #105
Brouie commented 2026-04-13 04:06:07 +00:00 (Migrated from gitlab.com)

@PlasticDigits Fresh Terra->Solana 0.997 testa nonce 54 tested today (4/13). Steps 1-3 all pass (deposit, withdrawSubmit, operator approval). Execute fails with same token_mapping AccountNotInitialized (3012).

Hash: 0x50ce0a31c2b2d666d868b13fc02518a6be1f464bda6101f6c8715adc3048e4ea
Terra tx: BAF7C8E784D18825856A1002F2219C672FCAF7D624651AB8F0911DA192385B6B

@PlasticDigits Fresh Terra->Solana 0.997 testa nonce 54 tested today (4/13). Steps 1-3 all pass (deposit, withdrawSubmit, operator approval). Execute fails with same token_mapping AccountNotInitialized (3012). Hash: 0x50ce0a31c2b2d666d868b13fc02518a6be1f464bda6101f6c8715adc3048e4ea Terra tx: BAF7C8E784D18825856A1002F2219C672FCAF7D624651AB8F0911DA192385B6B
PlasticDigits commented 2026-04-13 04:16:50 +00:00 (Migrated from gitlab.com)

mentioned in commit 2b2e6f6f8d

mentioned in commit 2b2e6f6f8db38e0ef25fe774b560caf689274bab
PlasticDigits commented 2026-04-13 04:16:51 +00:00 (Migrated from gitlab.com)

@brouie Fix merged (frontend): Terra→Solana withdraw_execute was building the token_mapping PDA from the wrong 32-byte value — queryTerraDeposit exposes dest_token_address (the destination token word in the V2 hash, e.g. SPL mint), while Solana TokenMapping / withdraw_submit use encode_token_address of the locked Terra CW20/denom. The UI now resolves the mapping key via resolveSolanaMappingSrcTokenKey (prefer transfer.token, skip raw 0x+64 deposit token for cosmos), and when the record only has the SPL hex it loads the real Terra token id from queryTerraBridgeTransactionByNonce on Transfer Status + Verify pages. Please re-test Terra→Solana execute on staging/mainnet with a current build; if simulation succeeds, close #104.

@brouie **Fix merged (frontend):** Terra→Solana `withdraw_execute` was building the `token_mapping` PDA from the wrong 32-byte value — `queryTerraDeposit` exposes `dest_token_address` (the **destination** token word in the V2 hash, e.g. SPL mint), while Solana `TokenMapping` / `withdraw_submit` use `encode_token_address` of the **locked Terra** CW20/denom. The UI now resolves the mapping key via `resolveSolanaMappingSrcTokenKey` (prefer `transfer.token`, skip raw `0x`+64 deposit `token` for cosmos), and when the record only has the SPL hex it loads the real Terra token id from `queryTerraBridgeTransactionByNonce` on Transfer Status + Verify pages. Please re-test Terra→Solana execute on staging/mainnet with a current build; if simulation succeeds, close #104.
PlasticDigits commented 2026-04-13 06:29:53 +00:00 (Migrated from gitlab.com)

Issue is due to incorrect encoding of address when simulating the solana tx, fix incoming

Issue is due to incorrect encoding of address when simulating the solana tx, fix incoming
Brouie commented 2026-04-13 06:33:04 +00:00 (Migrated from gitlab.com)

Verified fixed on 4/13. Terra->Solana 1.819026 testa nonce 55 executed successfully with Phantom wallet. Tokens received (7.78903 testa total across 3 paths). Fix: commit 2b2e6f6 corrected the token_mapping PDA derivation in the frontend. All 3 inbound Solana paths (BSC, opBNB, Terra) now pass E2E with Phantom.

Verified fixed on 4/13. Terra->Solana 1.819026 testa nonce 55 executed successfully with Phantom wallet. Tokens received (7.78903 testa total across 3 paths). Fix: commit 2b2e6f6 corrected the token_mapping PDA derivation in the frontend. All 3 inbound Solana paths (BSC, opBNB, Terra) now pass E2E with Phantom.
Brouie (Migrated from gitlab.com) closed this issue 2026-04-13 06:33:20 +00:00
PlasticDigits commented 2026-04-13 06:57:29 +00:00 (Migrated from gitlab.com)

mentioned in commit a8c2b2ed00

mentioned in commit a8c2b2ed00b951b6eb0565e69bd6d269a06bf5f1
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#104
No description provided.