Skip to content

Conversation

@smypmsa
Copy link
Member

@smypmsa smypmsa commented Oct 28, 2025

Summary by CodeRabbit

  • New Features

    • Added an account data size limit optimization (default 512 KB) across bot configs to reduce compute unit cost and improve transaction priority.
    • Transaction builder now applies account data size limits for buy/sell flows with platform-specific override support.
  • Style

    • Minor formatting/whitespace cleanups in example and parser code (no behavioral changes).

@smypmsa smypmsa self-assigned this Oct 28, 2025
@smypmsa smypmsa added the enhancement New feature or request label Oct 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds support for limiting loaded account data size as a Solana Compute Budget parameter. Four bot YAML configs add account_data_size: 512_000. The core Solana client gains an instruction builder and a new account_data_size_limit parameter to build_and_send_transaction(). Platform-aware trading flows pass platform overrides into the client.

Changes

Cohort / File(s) Summary
Bot configuration updates
bots/bot-sniper-1-geyser.yaml, bots/bot-sniper-2-logs.yaml, bots/bot-sniper-3-blocks.yaml, bots/bot-sniper-4-pp.yaml
Add compute_units.account_data_size: 512_000 (512 KB) with comments describing CU cost / priority improvements and tradeoffs.
Core Solana client
src/core/client.py
Add set_loaded_accounts_data_size_limit(bytes_limit: int) -> Instruction. Extend SolanaClient.build_and_send_transaction(...) signature with `account_data_size_limit: int
Platform-aware trading layer
src/trading/platform_aware.py
Read platform override _get_cu_override("account_data_size", ...) and pass resulting account_data_size_limit into build_and_send_transaction() for buy/sell flows.
Formatting / minor edits
learning-examples/*, src/platforms/letsbonk/*
Cosmetic reformatting changes (multiline strings/expressions, condition reflow) with no behavioral changes.

Sequence Diagram

sequenceDiagram
    participant Config as Bot Config
    participant Platform as PlatformAware
    participant Client as SolanaClient
    participant Solana as Solana Network

    Config->>Platform: account_data_size = 512_000
    Platform->>Platform: _get_cu_override("account_data_size", platform)
    Platform->>Client: build_and_send_transaction(..., account_data_size_limit)
    Client->>Client: set_loaded_accounts_data_size_limit(limit)
    Client->>Client: Prepend size-limit instruction (discriminator 4)
    Client->>Client: Add compute-unit & priority-fee instructions
    Client->>Solana: Send transaction
    Solana-->>Client: Confirm / Response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • New instruction builder and API surface change in src/core/client.py require attention.
  • Verify correct instruction ordering, discriminator value, and logging.
  • Confirm platform override retrieval and propagation in src/trading/platform_aware.py.
  • Review bot YAML additions for consistent formatting and comments.

Possibly related PRs

Poem

🐰 I tunneled through bytes and found a seam,
512K to tidy the stream.
I stitched the budget, small and neat,
so transactions dance light on their feet. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat(core): integrate account data size limit" is directly related to the main changes in the pull request. The changeset adds a new set_loaded_accounts_data_size_limit function to the core client module, updates the build_and_send_transaction method to accept an account_data_size_limit parameter, integrates this parameter into platform-aware trading logic, and configures the setting across multiple bot configuration files. The title accurately captures the primary objective of the PR—integrating account data size limit functionality—using clear, specific language that allows a developer reviewing the commit history to understand the change's purpose.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99f3ad9 and 9edc86a.

📒 Files selected for processing (6)
  • learning-examples/bonding-curve-progress/poll_bonding_curve_progress.py (1 hunks)
  • learning-examples/fetch_price.py (1 hunks)
  • src/core/client.py (5 hunks)
  • src/platforms/letsbonk/curve_manager.py (1 hunks)
  • src/platforms/letsbonk/event_parser.py (1 hunks)
  • src/trading/platform_aware.py (5 hunks)

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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/trading/platform_aware.py (2)

156-170: Update documentation to reflect new "account_data_size" operation.

The docstring and inline comment state that operation is limited to "buy" or "sell", but the method now also accepts "account_data_size" as shown in line 114. The implementation correctly handles any key via self.compute_units.get(operation), but the documentation is misleading.

Apply this diff to update the documentation:

 def _get_cu_override(self, operation: str, platform: Platform) -> int | None:
     """Get compute unit override from configuration.
     
     Args:
-        operation: "buy" or "sell"
+        operation: "buy", "sell", or "account_data_size"
         platform: Trading platform (unused - each config is platform-specific)
         
     Returns:
         CU override value if configured, None otherwise
     """
     if not self.compute_units:
         return None
         
-    # Just check for operation override (buy/sell)
+    # Check for operation override (buy/sell/account_data_size)
     return self.compute_units.get(operation)

312-326: Update documentation and consider DRY refactor.

Same documentation issue as the buyer's _get_cu_override method. Additionally, this method is duplicated between PlatformAwareBuyer and PlatformAwareSeller.

Fix the documentation:

 def _get_cu_override(self, operation: str, platform: Platform) -> int | None:
     """Get compute unit override from configuration.
     
     Args:
-        operation: "buy" or "sell"
+        operation: "buy", "sell", or "account_data_size"
         platform: Trading platform (unused - each config is platform-specific)
         
     Returns:
         CU override value if configured, None otherwise
     """
     if not self.compute_units:
         return None
         
-    # Just check for operation override (buy/sell)
+    # Check for operation override (buy/sell/account_data_size)
     return self.compute_units.get(operation)

Optional refactor: Consider extracting _get_cu_override into a shared base class or utility function to eliminate duplication between buyer and seller classes.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec6d586 and 99f3ad9.

📒 Files selected for processing (6)
  • bots/bot-sniper-1-geyser.yaml (1 hunks)
  • bots/bot-sniper-2-logs.yaml (1 hunks)
  • bots/bot-sniper-3-blocks.yaml (1 hunks)
  • bots/bot-sniper-4-pp.yaml (1 hunks)
  • src/core/client.py (4 hunks)
  • src/trading/platform_aware.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
bots/**/*.{yaml,yml}

📄 CodeRabbit inference engine (CLAUDE.md)

bots/**/*.{yaml,yml}: Keep bot configurations in YAML files under bots/
Detect target platform from bot configuration files
Do not include sensitive data in bot configuration files

bots/**/*.{yaml,yml}: Edit bot instance configuration in YAML files under bots/
Start with conservative YAML settings (low buy_amount, high min_sol_balance, strict filters)

Files:

  • bots/bot-sniper-4-pp.yaml
  • bots/bot-sniper-3-blocks.yaml
  • bots/bot-sniper-1-geyser.yaml
  • bots/bot-sniper-2-logs.yaml
bots/**/*.{yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)

bots/**/*.{yml,yaml}: Store bot configurations as YAML files in bots/
Support ${VARIABLE} environment interpolation in bot YAML configs
Validate bot configurations before starting bots

Files:

  • bots/bot-sniper-4-pp.yaml
  • bots/bot-sniper-3-blocks.yaml
  • bots/bot-sniper-1-geyser.yaml
  • bots/bot-sniper-2-logs.yaml
**/*.{yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/trading-bot.mdc)

**/*.{yaml,yml}: Maintain a consistent YAML structure for all bot configuration files, including keys: name, platform, enabled, separate_process, env_file, rpc_endpoint, wss_endpoint, private_key, geyser.{endpoint,api_token,auth_type}, and trade.{buy_amount,buy_slippage,sell_slippage,exit_strategy,extreme_fast_mode}
Use ${VARIABLE_NAME} syntax for environment variable interpolation in YAML configs
Never hardcode sensitive values (e.g., private keys, API tokens) in YAML configuration files
Validate YAML syntax and required configuration fields
Test environment variable interpolation in configuration files

Validate YAML configuration syntax and required fields before running

Files:

  • bots/bot-sniper-4-pp.yaml
  • bots/bot-sniper-3-blocks.yaml
  • bots/bot-sniper-1-geyser.yaml
  • bots/bot-sniper-2-logs.yaml
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Enforce max line length of 88 characters in Python (Ruff config)
Use 4 spaces for indentation in Python files
Target Python version 3.11+ features and syntax
Prefer double quotes for strings in Python code
Enable and honor import sorting in Python modules
Apply Ruff rule sets: Security (S), Annotations (ANN), Exceptions (BLE, TRY), Complexity (C90), Pylint conventions (PL), and no commented-out code (ERA)
Order imports as: standard library, third-party, then local imports
Use Google-style docstrings for functions and classes
Provide type hints for all public functions
Use a module-level logger via get_logger(name)
Wrap risky operations in try/except with proper logging
Implement rate limiting and retry mechanisms where external calls are made
Perform comprehensive input validation for externally sourced data

**/*.py: Limit lines to 88 characters
Use 4 spaces for indentation (never tabs)
Use double quotes for strings consistently
Target Python 3.11+ features and syntax
Enable automatic import sorting and organization
Order imports: standard library first, third-party second, local last
Add type hints to all public functions and methods
Use modern typing syntax (e.g., X | Y unions)
Include explicit return type annotations
Use typing.Any for complex/unknown types (from typing import Any)
Use Google-style docstrings for all functions and classes
Wrap external operations (RPC calls, file I/O) in try/except blocks
Log exceptions with context using logging.exception()
Provide meaningful error messages when handling exceptions
Do not suppress exceptions without good reason
Use get_logger(name) with logger from utils.logger
Use appropriate log levels (DEBUG, INFO, WARNING, ERROR) with contextual messages
Never hardcode secrets (private keys, API tokens)
Use environment variables for sensitive configuration
Do not log sensitive information
Validate all external inputs
Comply with Ruff security rules (S)
Comply with Ruff type annotation rules (ANN)
Comply...

Files:

  • src/core/client.py
  • src/trading/platform_aware.py
src/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)

src/**/*.py: Use snake_case for all Python file names
Avoid circular imports between packages
Use asyncio.create_task() for concurrent operations
Implement proper cleanup on shutdown for async tasks/resources

Files:

  • src/core/client.py
  • src/trading/platform_aware.py
src/core/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)

src/core/**/*.py: Core modules must not import from trading or monitoring
core/ may depend only on utils/ and interfaces/
Limit concurrent operations based on RPC provider limits

Files:

  • src/core/client.py
src/core/client.py

📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)

src/core/client.py: Use connection pooling for HTTP clients and backoff for failed requests
Cache recent blockhash and relevant account information where appropriate

Files:

  • src/core/client.py
src/{client,trading,monitoring,platforms}/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Separate concerns into client, trading, monitoring, and platforms packages under src/

Files:

  • src/trading/platform_aware.py
src/trading/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/architecture.mdc)

trading/ may depend on core/, platforms/, and interfaces/

Files:

  • src/trading/platform_aware.py
🧠 Learnings (1)
📚 Learning: 2025-08-21T12:08:15.475Z
Learnt from: CR
PR: chainstacklabs/pumpfun-bonkfun-bot#0
File: .cursor/rules/trading-bot.mdc:0-0
Timestamp: 2025-08-21T12:08:15.475Z
Learning: Applies to **/*.py : Set compute unit limits and prices (priority fees) on transactions to reduce failures

Applied to files:

  • src/core/client.py
🔇 Additional comments (7)
bots/bot-sniper-3-blocks.yaml (1)

60-65: LGTM: Well-documented compute unit optimization.

The addition of account_data_size: 512_000 is well-documented with clear explanations of the CU reduction benefits. The 512KB limit is reasonable for typical trading operations and aligns with Solana's compute budget best practices. The reference URL is helpful for understanding the optimization.

bots/bot-sniper-2-logs.yaml (1)

60-65: LGTM: Consistent configuration across bot instances.

The configuration matches other sniper bots, maintaining consistency. The optimization is appropriate for this listener type.

bots/bot-sniper-4-pp.yaml (1)

58-63: LGTM: Appropriate for lets_bonk platform.

The account data size optimization is consistently applied across platforms, which is correct since this is a Solana-level optimization independent of trading platform specifics.

bots/bot-sniper-1-geyser.yaml (1)

60-65: LGTM: Completes consistent rollout across all bot instances.

All four sniper bot configurations now have the account data size optimization enabled with identical settings, ensuring consistent compute unit behavior across different listener types.

src/trading/platform_aware.py (2)

270-270: Transaction parameter integration looks correct.

The account_data_size_limit is properly propagated to the transaction builder for sell operations, matching the buy flow implementation.


114-114: Configuration parsing is correct and functioning as expected.

The YAML parser successfully loads account_data_size: 512_000 into the compute_units dictionary across all bot configs. The code correctly extracts it via cfg.get("compute_units", {}) and accesses it through _get_cu_override("account_data_size", ...) using .get(). No configuration structure issues exist.

src/core/client.py (1)

172-227: Transaction builder integration is correct.

The account_data_size_limit parameter is properly integrated into the transaction construction flow:

  1. Parameter added to method signature with appropriate type hint
  2. Instruction ordering is correct (account data size limit → compute unit limit → priority fee)
  3. Proper logging added
  4. Conditional logic ensures instructions are only added when needed

The implementation follows Solana best practices by placing the account data size limit instruction first in the compute budget sequence.

Based on learnings

@smypmsa smypmsa merged commit b6928d1 into main Oct 28, 2025
1 check was pending
@smypmsa smypmsa deleted the feat/add-set-acc-data-size branch October 28, 2025 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants