Fix buy/sell transactions silently failing on-chain#157
Conversation
The 12.5MB setLoadedAccountsDataSizeLimit was causing all buy transactions to fail with MaxLoadedAccountsDataSizeExceeded since pump.fun migrated to Token-2022. Transactions landed on-chain (fees paid) but inner instructions were rejected — the bot paid gas for nothing. Changes: - Disable account_data_size in all bot configs (Token-2022 needs >12.5MB) - Add meta.err check in get_buy_transaction_details() for clear error reporting when transactions fail on-chain - Include tx signature in platform_aware.py error messages for debugging Tested: full buy→sell→cleanup cycle works on pump_fun with geyser listener. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Solana transactions can be "confirmed" (included in a block) but still fail execution if inner program instructions are rejected. Previously, confirm_transaction only checked that the tx landed on-chain, causing silent failures in buy, sell, and cleanup operations. Now fetches the transaction result after confirmation and checks meta.err, returning False when the transaction failed. This fixes the ATA cleanup issue where sells were silently failing with Custom: 6003 errors, leaving non-zero token balances. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughDisabled account_data_size in four bot configs due to Token-2022 errors and tightened transaction confirmation to require successful on-chain execution by checking transaction metadata for errors. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/trading/platform_aware.py (1)
157-161: Slightly misleading error message given the newconfirm_transactioncheck.With
confirm_transaction()now returningFalsefor on-chain failures (viameta.err), this code path is only reached when the transaction succeeded on-chain but detail parsing failed (e.g., unexpected account layout, missing token balance entries). The hint "may have failed on-chain" could send developers on a wrong debugging trail.Consider adjusting the message to reflect the more likely cause:
Suggested tweak
else: raise ValueError( f"Failed to parse transaction details: tokens={tokens_raw}, " - f"sol_spent={sol_spent} (tx: {tx_signature}). " - f"The transaction may have failed on-chain — check explorer." + f"sol_spent={sol_spent} (tx: {tx_signature}). " + f"Check explorer for unexpected account layout." )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/trading/platform_aware.py` around lines 157 - 161, The ValueError message raised in the transaction parsing code (the raise in platform_aware.py that includes tokens_raw, sol_spent and tx_signature) is misleading now that confirm_transaction() filters out on-chain failures; update the message in that raise to state that the transaction succeeded on-chain but parsing of transaction details failed (e.g., unexpected account layout or missing token balance entries), keep the existing context variables (tokens_raw, sol_spent, tx_signature) in the message, and optionally advise inspecting the transaction format or account layouts rather than suggesting an on-chain failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/core/client.py`:
- Around line 306-316: The current logic in the caller of
_get_transaction_result treats a None result as success; update the method
handling (the function containing the call to await
self._get_transaction_result(str(signature))) to treat a None response as a
failure: if result is None, either perform a small retry loop (call
_get_transaction_result up to N times with short backoff) or immediately log an
error and return False; ensure the code paths around tx_err still run when
result is truthy (keep using result.get("meta", {}).get("err")) and reference
the existing symbols _get_transaction_result and the local variable
result/signature when implementing the change.
---
Nitpick comments:
In `@src/trading/platform_aware.py`:
- Around line 157-161: The ValueError message raised in the transaction parsing
code (the raise in platform_aware.py that includes tokens_raw, sol_spent and
tx_signature) is misleading now that confirm_transaction() filters out on-chain
failures; update the message in that raise to state that the transaction
succeeded on-chain but parsing of transaction details failed (e.g., unexpected
account layout or missing token balance entries), keep the existing context
variables (tokens_raw, sol_spent, tx_signature) in the message, and optionally
advise inspecting the transaction format or account layouts rather than
suggesting an on-chain failure.
When _get_transaction_result returns None (RPC failure, timeout, etc.), the function was falling through to return True — silently treating an unknown state as success. Now returns False with a warning log. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/core/client.py`:
- Around line 306-322: The transaction verification previously could treat a
failed fetch or execution error as success; fix it in the method that checks
transaction results by calling await
self._get_transaction_result(str(signature)), checking if result is falsy and
logging a warning then return False, extracting tx_err via result.get("meta",
{}).get("err") and if tx_err is truthy log an error and return False, otherwise
return True (references: self._get_transaction_result, result, tx_err,
signature).
Summary
account_data_sizelimit in all bot configs — causesMaxLoadedAccountsDataSizeExceededwith Token-2022meta.errcheck inconfirm_transaction()so failed txs are no longer reported as successfulmeta.errcheck inget_buy_transaction_details()for clearer error messages with tx signatureWhat was broken
Transactions were landing on-chain and getting confirmed, but inner instructions were rejected (e.g.
MaxLoadedAccountsDataSizeExceeded,Custom: 6003). The bot treated them as successful, leading to:Tested
All 4 listener types (geyser, logs, blocks, pumpportal) on pump_fun — full buy→sell→cleanup cycle passed.
🤖 Generated with Claude Code
Summary by CodeRabbit