Skip to content

Fix buy/sell transactions silently failing on-chain#157

Merged
smypmsa merged 3 commits intomainfrom
fix/buy-transaction-failures
Feb 17, 2026
Merged

Fix buy/sell transactions silently failing on-chain#157
smypmsa merged 3 commits intomainfrom
fix/buy-transaction-failures

Conversation

@smypmsa
Copy link
Member

@smypmsa smypmsa commented Feb 17, 2026

Summary

  • Disabled account_data_size limit in all bot configs — causes MaxLoadedAccountsDataSizeExceeded with Token-2022
  • Added meta.err check in confirm_transaction() so failed txs are no longer reported as successful
  • Added meta.err check in get_buy_transaction_details() for clearer error messages with tx signature

What 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:

  • Buys that paid fees but received no tokens
  • Sells that appeared to work but didn't actually sell
  • ATA cleanup failing because token balance was still non-zero

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

  • Bug Fixes
    • Fixed account data size configuration that could trigger MaxLoadedAccountsDataSizeExceeded (Token-2022) across trading bot configs.
    • Strengthened transaction confirmation to detect and report on-chain execution failures, not just inclusion.
    • Improved transaction parsing error messages by including the transaction reference for easier investigation.

smypmsa and others added 2 commits February 17, 2026 10:17
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>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

Disabled 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

Cohort / File(s) Summary
Bot Configuration Settings
bots/bot-sniper-1-geyser.yaml, bots/bot-sniper-2-logs.yaml, bots/bot-sniper-3-blocks.yaml, bots/bot-sniper-4-pp.yaml
Commented out/disabled account_data_size: 12_500_000 under compute_units across four bot configs with inline notes citing MaxLoadedAccountsDataSizeExceeded on Token-2022.
Transaction Execution Verification
src/core/client.py
confirm_transaction() now fetches the on-chain transaction result and checks meta.err to ensure execution succeeded; get_buy_transaction_details() also inspects meta.err and returns (None, None) if the tx errored. Docstrings updated to reflect execution check.
Error Message Enhancement
src/trading/platform_aware.py
Augmented buy parsing failure message to include the transaction signature and a note suggesting the transaction may have failed on-chain.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 I poked the ledger, sniffed the trace,

Checked meta.err in every place.
Account sizes tucked away,
Errors named so they can't stray.
A tiny hop for safer play.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing transactions that were silently failing on-chain by adding validation checks and config adjustments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/buy-transaction-failures

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@smypmsa smypmsa self-assigned this Feb 17, 2026
@smypmsa smypmsa added the bug Something isn't working label Feb 17, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/trading/platform_aware.py (1)

157-161: Slightly misleading error message given the new confirm_transaction check.

With confirm_transaction() now returning False for on-chain failures (via meta.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>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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).

@smypmsa smypmsa merged commit 0b6779c into main Feb 17, 2026
1 check passed
@smypmsa smypmsa deleted the fix/buy-transaction-failures branch February 17, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant