Skip to content

fix: loaded account datasize - #25

Open
sonicfromnewyoke wants to merge 5 commits into
blueshift-gg:masterfrom
sonicfromnewyoke:sonic/fix-loaded-accounts-data-size
Open

fix: loaded account datasize#25
sonicfromnewyoke wants to merge 5 commits into
blueshift-gg:masterfrom
sonicfromnewyoke:sonic/fix-loaded-accounts-data-size

Conversation

@sonicfromnewyoke

@sonicfromnewyoke sonicfromnewyoke commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Problem

The SDK's transaction Builder requested a loaded-accounts-data-size limit of only ~111 bytes, which undercounts what SIMD-0186 actually meters because it ignored the per-account 64-byte metadata and the program's ~1.2 KB programdata account. Transactions built this way would be under-budgeted and fail on-chain.

Summary of Changes

Verifications

tested locally on 2 envs:

  1. surfpool:
./surfpool.sh

cargo run --bin single-price-feed

result

Screenshot 2026-06-27 at 01 22 09
  1. solana-test-validator:
solana-test-validator --reset \
    --upgradeable-program fastRQJt3nLdY3QA7n8eZ8ETEVefy56ryfUGVkfZokm target/deploy/doppler_program.so admnz5UvRa93HM5nTrxXmsJ1rw2tvXMBFGauvCgzQhE \
    --account admnz5UvRa93HM5nTrxXmsJ1rw2tvXMBFGauvCgzQhE examples/accounts/admin-account.json \
    --account QUVF91dzXWYvE5FmFEc41JZxRDmNgx8S8P6sNDWYZiW examples/accounts/sol-usdc-price-feed-oracle.json \
    --account 9bA7GPqPpZ5aLbwb8E6cKvUPM8pcHXXTqLpf5zLAqHP5 examples/accounts/sol-usdt-price-feed-oracle.json \
    --account 6uQ848roY5vumz43QeQguE7xCyBSmgZbwNdJMTrs2Xhy examples/accounts/bonk-sol-price-feed-oracle.json

cargo run --bin single-price-feed

result
Screenshot 2026-06-27 at 01 29 41

@ChiefWoods could you double check the fix on your end?

Summary by CodeRabbit

  • New Features

    • Added a helper script to start a local Solana validator with the required program and accounts preloaded.
    • Updated sizing logic for transaction account data limits to reflect current account layouts.
  • Bug Fixes

    • Improved compute-budget calculations so priority and loaded-data limits are more accurate.
    • Ensured updates with multiple accounts are handled consistently.
  • Documentation

    • Refreshed README examples, commands, and priority score tables to match the latest behavior and values.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Workspace Solana dependency pins are bumped (including major-version changes). SDK sizing constants are replaced with ACCOUNT_METADATA and doppler-specific layout constants. Oracle<T>::loaded_accounts_data_size_limit() is renamed oracle_data_len() and the transaction builder's loaded-size formula is updated. A new run-validator.sh replaces the txtx runbook. README examples, E2E traces, and priority-score table are updated for the 1583-byte limit.

Changes

Loaded-account sizing and startup setup

Layer / File(s) Summary
Workspace pins, .gitignore, and dev-dep cleanup
Cargo.toml, sdk/Cargo.toml, .gitignore
Workspace dependency versions bumped (major-version Solana crate upgrades), doppler-program removed from sdk dev-dependencies, Cargo.lock added to .gitignore.
Sizing constants rework
sdk/src/constants.rs
Replaces old compute-budget/oracle constants with ACCOUNT_METADATA (64), DOPPLER_PROGRAM_SIZE (36), DOPPLER_BINARY_SIZE (1136), and DOPPLER_PROGRAM_DATA_SIZE.
Oracle data length helper and test decoupling
sdk/src/accounts.rs
Oracle<T> renames loaded_accounts_data_size_limit() to oracle_data_len(). Tests replace external doppler_program::PriceFeed with an inline local struct.
Transaction builder loaded-size calculation
sdk/src/transaction.rs
Builder initializes loaded-account size from new constants, increments per oracle via oracle_data_len() + ACCOUNT_METADATA, removes unit-price size adjustment, and adds three validating tests.
run-validator.sh and surfpool.sh updates
run-validator.sh, surfpool.sh
New run-validator.sh builds the SO with pinned platform-tools, loads accounts from JSON, and launches solana-test-validator. surfpool.sh adds --tools-version v1.54 and switches to surfpool start --runbook setup.
Program test minor cleanups
program/tests/tests.rs
#[must_use] reformatted onto its own line; accounts argument switched from &vec![...] to a slice literal.
README sizing docs and examples
README.md
Replaces old sizing snippet with data_len + 64 formula, updates validator commands to run-validator.sh, refreshes E2E traces and priority-score table for the 1583-byte limit.

Panic handler attribute update

Layer / File(s) Summary
Remove #[no_mangle] from panic handler macro
doppler/src/panic_handler.rs
The nostd_panic_handler! macro drops #[no_mangle] from the generated panic_handler definition.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hop hop, the sizes grow precise,
oracle_data_len rolls the dice,
1583 bytes, a tighter bound,
the validator script is finally found.
No more runbooks, just a shell so neat —
this rabbit's build stack is complete! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing the loaded account data size calculation.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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)
sdk/src/accounts.rs (1)

58-61: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Note: oracle_data_len() returns size_of, not the serialized length.

The on-chain account data is oracle.to_bytes(), whose length can be smaller than size_of::<Oracle<T>>() due to struct padding (e.g. a repr(C) payload ending in a u32). Here this is safe because it only over-estimates the loaded size, but the name implies the serialized byte length. Worth a one-line doc note that this is the (conservative) in-memory size.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdk/src/accounts.rs` around lines 58 - 61, Update the documentation on
oracle_data_len() in Oracle<T> to clarify that it returns the conservative
in-memory size via core::mem::size_of::<Oracle<T>>() rather than the serialized
on-chain length from oracle.to_bytes(); keep the method behavior unchanged and
add a short note near the oracle_data_len symbol so callers do not mistake it
for the exact encoded byte length.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@surfpool.sh`:
- Around line 20-23: The startup runbook invocation in surfpool.sh is missing an
explicit manifest environment, which can leave setup without rpc_api_url and
network_id at boot. Update the surfpool start command in the startup script to
pass the localnet environment alongside the existing setup runbook flags,
keeping the change localized to the surfpool start invocation.

---

Nitpick comments:
In `@sdk/src/accounts.rs`:
- Around line 58-61: Update the documentation on oracle_data_len() in Oracle<T>
to clarify that it returns the conservative in-memory size via
core::mem::size_of::<Oracle<T>>() rather than the serialized on-chain length
from oracle.to_bytes(); keep the method behavior unchanged and add a short note
near the oracle_data_len symbol so callers do not mistake it for the exact
encoded byte length.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e048c20c-dc04-4871-8308-2eff64d6f8d2

📥 Commits

Reviewing files that changed from the base of the PR and between 8d42c87 and 1ad9f36.

📒 Files selected for processing (9)
  • Cargo.toml
  • README.md
  • program/tests/tests.rs
  • sdk/Cargo.toml
  • sdk/src/accounts.rs
  • sdk/src/constants.rs
  • sdk/src/transaction.rs
  • surfpool.sh
  • txtx.yml
💤 Files with no reviewable changes (1)
  • sdk/Cargo.toml

Comment thread surfpool.sh Outdated
Comment thread README.md
Comment thread sdk/src/transaction.rs
Comment thread sdk/src/constants.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@run-validator.sh`:
- Around line 5-6: The hard-coded PROGRAM_ID and UPGRADE_AUTHORITY values in
run-validator.sh are inconsistent with the addresses used elsewhere in the PR.
Update the validator setup to use the same program and authority identifiers
referenced by the inspection traces/examples so the validator loads under the
expected keys and stays aligned with the SDK/docs.
- Around line 19-21: The SBF build in run-validator.sh is incorrectly skipped
when SO_PATH already exists, which can leave surfpool/solana-test-validator
using a stale program binary after branch or code changes. Update the validator
startup flow to always run the cargo build-sbf step before launching the
validator, using the existing build command and identifiers like SO_PATH and
cargo build-sbf, instead of gating it on file existence.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 958e45d8-e109-49f1-9dff-4c6cf60c4a55

📥 Commits

Reviewing files that changed from the base of the PR and between d364a81 and 34dedfc.

📒 Files selected for processing (7)
  • .gitignore
  • README.md
  • run-validator.sh
  • runbooks/setup.tx
  • sdk/build.rs
  • sdk/src/constants.rs
  • surfpool.sh
💤 Files with no reviewable changes (2)
  • runbooks/setup.tx
  • surfpool.sh
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

Comment thread run-validator.sh
Comment on lines +5 to +6
PROGRAM_ID="fastRQJt3nLdY3QA7n8eZ8ETEVefy56ryfUGVkfZokm"
UPGRADE_AUTHORITY="admnz5UvRa93HM5nTrxXmsJ1rw2tvXMBFGauvCgzQhE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

These hard-coded keys do not match the rest of the PR.

The script uses fastRQ…EVefy… / admnz5…CgzQhE, while the inspection traces and examples in the PR use fastRQ…EVfey… / admnsz5…CqzQhE. Starting the validator with different addresses will load the program under keys the SDK/docs are not using.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@run-validator.sh` around lines 5 - 6, The hard-coded PROGRAM_ID and
UPGRADE_AUTHORITY values in run-validator.sh are inconsistent with the addresses
used elsewhere in the PR. Update the validator setup to use the same program and
authority identifiers referenced by the inspection traces/examples so the
validator loads under the expected keys and stays aligned with the SDK/docs.

Comment thread run-validator.sh
Comment on lines +19 to +21
if [ ! -f "$SO_PATH" ]; then
cargo build-sbf --tools-version "$TOOLS_VERSION" --manifest-path program/Cargo.toml
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not gate the SBF build on file existence.

After the first run, this reuses whatever target/deploy/doppler_program.so is already on disk. Branch switches or program changes can then boot the validator with a stale binary, which undermines the local surfpool/solana-test-validator coverage this PR depends on.

Suggested change
-if [ ! -f "$SO_PATH" ]; then
-    cargo build-sbf --tools-version "$TOOLS_VERSION" --manifest-path program/Cargo.toml
-fi
+cargo build-sbf --tools-version "$TOOLS_VERSION" --manifest-path program/Cargo.toml
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ ! -f "$SO_PATH" ]; then
cargo build-sbf --tools-version "$TOOLS_VERSION" --manifest-path program/Cargo.toml
fi
cargo build-sbf --tools-version "$TOOLS_VERSION" --manifest-path program/Cargo.toml
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@run-validator.sh` around lines 19 - 21, The SBF build in run-validator.sh is
incorrectly skipped when SO_PATH already exists, which can leave
surfpool/solana-test-validator using a stale program binary after branch or code
changes. Update the validator startup flow to always run the cargo build-sbf
step before launching the validator, using the existing build command and
identifiers like SO_PATH and cargo build-sbf, instead of gating it on file
existence.

@sonicfromnewyoke
sonicfromnewyoke requested a review from dhl June 27, 2026 16:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sdk/src/constants.rs`:
- Around line 24-28: Add a guard around DOPPLER_BINARY_SIZE so the pinned value
is verified against the actual built doppler_program artifact size instead of
only being a comment-backed constant. Update the existing constants/tests path
to compare the value used in loaded_accounts_data_size with the size of
target/deploy/doppler_program.so, and fail fast or assert when they differ. Use
DOPPLER_BINARY_SIZE as the primary symbol to locate the check and ensure the
validation is tied to the runtime-critical loaded_accounts_data_size behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 220c5cd1-0645-4bac-91f9-f462c0cb68eb

📥 Commits

Reviewing files that changed from the base of the PR and between 34dedfc and 1f9bb23.

📒 Files selected for processing (2)
  • run-validator.sh
  • sdk/src/constants.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • run-validator.sh

Comment thread sdk/src/constants.rs
Comment on lines +24 to +28
// doppler program binary size (bytes): the size of the stripped deploy artifact
// (`target/deploy/doppler_program.so`). Pinned statically to the validator-confirmed
// value; if the program is rebuilt with a different toolchain, re-measure the artifact
// and update this constant (and the `loaded_accounts_data_size` tests).
pub(crate) const DOPPLER_BINARY_SIZE: u32 = 1136;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== constant definition =="
sed -n '20,40p' sdk/src/constants.rs

echo
echo "== downstream consumers/tests =="
sed -n '1,220p' sdk/src/transaction.rs

echo
echo "== search for any existing sync/guard logic =="
rg -n --hidden \
  'DOPPLER_BINARY_SIZE|doppler_program\.so|loaded_accounts_data_size|run-validator|build\.rs' \
  sdk run-validator.sh README.md Cargo.toml .gitignore

Repository: blueshift-gg/doppler

Length of output: 7462


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== run-validator.sh =="
sed -n '1,220p' run-validator.sh

echo
echo "== README references around run-validator =="
sed -n '240,280p' README.md

echo
echo "== repo-wide search for artifact size checks =="
rg -n --hidden \
  'stat -c|wc -c|target/deploy/doppler_program\.so|DOPPLER_BINARY_SIZE|loaded_accounts_data_size' \
  . \
  -g '!target'

Repository: blueshift-gg/doppler

Length of output: 3433


Add a size check for DOPPLER_BINARY_SIZE. sdk/src/constants.rs:24-28 pins a runtime-critical assumption, but there’s no guard that compares it with the actual target/deploy/doppler_program.so size. If the artifact changes, the loaded-accounts-data-size limit can drift silently while the current tests still pass against the stale constant.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sdk/src/constants.rs` around lines 24 - 28, Add a guard around
DOPPLER_BINARY_SIZE so the pinned value is verified against the actual built
doppler_program artifact size instead of only being a comment-backed constant.
Update the existing constants/tests path to compare the value used in
loaded_accounts_data_size with the size of target/deploy/doppler_program.so, and
fail fast or assert when they differ. Use DOPPLER_BINARY_SIZE as the primary
symbol to locate the check and ensure the validation is tied to the
runtime-critical loaded_accounts_data_size behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants