Skip to content

Add loaded-accounts-data-size field to sim result#6023

Merged
tao-stones merged 4 commits into
anza-xyz:masterfrom
tao-stones:poc-simulate-transaction-rpc-response-extension
Jun 3, 2025
Merged

Add loaded-accounts-data-size field to sim result#6023
tao-stones merged 4 commits into
anza-xyz:masterfrom
tao-stones:poc-simulate-transaction-rpc-response-extension

Conversation

@tao-stones
Copy link
Copy Markdown

@tao-stones tao-stones commented Apr 29, 2025

Problem

For issue #5992

Summary of Changes

  • add loaded_accounts_data_size to simulation response (implementing proposal 2)

Note for reviewers:

By adding an additional field to JSON result, it is likely to be backward compatible - most JSON parsers and clients would ignore additional field, but not guaranteed for users perform strict schema validation. Would like feedback if this is an acceptable practice.

Fixes #5992

@tao-stones tao-stones marked this pull request as draft April 29, 2025 16:28
@mergify
Copy link
Copy Markdown

mergify Bot commented Apr 29, 2025

If this PR represents a change to the public RPC API:

  1. Make sure it includes a complementary update to rpc-client/ (example)
  2. Open a follow-up PR to update the JavaScript client @solana/kit (example)

Thank you for keeping the RPC clients in sync with the server API @tao-stones.

@tao-stones tao-stones force-pushed the poc-simulate-transaction-rpc-response-extension branch 2 times, most recently from bcdf312 to ba0083c Compare April 30, 2025 14:14
@tao-stones
Copy link
Copy Markdown
Author

result of running in testnet that includes both unitsConsumed and loadedAccountsDataSize:

sol@dev-tao-osaka-1:~$ curl http://127.0.0.1:8899 -s -X    POST -H "Content-Type: application/json" -d '
   {
     "jsonrpc": "2.0",
     "id": 1,
     "method": "simulateTransaction",
     "params": [
       "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=",
       {
         "encoding": "base64", "replaceRecentBlockhash": true
       }
     ]
   }
 '

{"jsonrpc":"2.0","result":{"context":{"apiVersion":"2.3.0","slot":331031558},"value":{"accounts":null,"err":{"InstructionError":[0,"IncorrectProgramId"]},"innerInstructions":null,"loadedAccountsDataSize":134105,"logs":["Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]","Program log: Instruction: GetAccountDataSize","Program log: Error: IncorrectProgramId","Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 883 of 200000 compute units","Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA failed: incorrect program id for instruction"],"replacementBlockhash":{"blockhash":"6JBouxHWGiJTam7f21kntii1MiVojfdRU8s61wxpdgUP","lastValidBlockHeight":288079773},"returnData":null,"unitsConsumed":883}},"id":1}

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 98.46154% with 1 line in your changes missing coverage. Please review.

Project coverage is 82.9%. Comparing base (0ccb6d7) to head (2671a99).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #6023     +/-   ##
=========================================
- Coverage    82.9%    82.9%   -0.1%     
=========================================
  Files         842      842             
  Lines      377389   377450     +61     
=========================================
+ Hits       312874   312917     +43     
- Misses      64515    64533     +18     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tao-stones
Copy link
Copy Markdown
Author

spot checked transactions in testnet, PoC RPC returns exact same simulation results except with loaded_account_data_size field.

@tao-stones
Copy link
Copy Markdown
Author

Hi @steveluscher , this poc is to add an additional field loaded_accounts_data_size to RPC's simulation results. Much appreciate if you can take a quick scan if I missed anything by modifying an existing RPC endpoint? 🙏🏼

@tao-stones tao-stones force-pushed the poc-simulate-transaction-rpc-response-extension branch from 0423680 to 2671a99 Compare May 6, 2025 20:41
@tao-stones tao-stones marked this pull request as ready for review May 6, 2025 20:50
@tao-stones tao-stones requested a review from a team as a code owner May 6, 2025 20:50
@tao-stones tao-stones requested review from steveluscher and steviez May 7, 2025 13:39
@tao-stones
Copy link
Copy Markdown
Author

@2501babe, just a heads-up about this PR that adds loaded data size to Simulation RPC result. It relates to the SIMD-0186 changes you are working on. I don't see any direct conflicts between the two, except we probably should communicate users that once your feature is activated, they might see significantly different values in RPC results (if this PR lands).

@2501babe 2501babe self-requested a review May 24, 2025 04:02
@2501babe
Copy link
Copy Markdown
Member

i highly support this pr! letting wallets get the size from simulation and then set the compute budget after was exactly the flow i had in mind. will review next week

one thing worth noting is if you simulate a transaction and then add a compute budget instruction to it you may need to add 22 to the requested size to account for the compute budget pseudoprogram. we should report the correct size for whatever transaction we are given but whoever does the frontend code should probably take that into account

we definitely want to communicate with foundation after this pr and my pr land. if end users implement a flow like "simulate, get the number, add compute budget instruction based on the number" then they should be future-proofed and it shouldnt be a problem if this goes live before simd186 activates

Copy link
Copy Markdown

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Sorry for the huge delay in reviewing this. Looks great!

If you have time, please do submit a PR to Kit to add this field to the RPC response. If you don't, let me know and I'll find someone.

@tao-stones
Copy link
Copy Markdown
Author

If you have time, please do submit a PR to Kit to add this field to the RPC response. If you don't, let me know and I'll find someone.

Thanks for kindly reminding, haven't PR-ed in Kit, but happy to give it a try.

@tao-stones tao-stones merged commit 49c0d5a into anza-xyz:master Jun 3, 2025
47 checks passed
mircea-c added a commit to mircea-c/agave that referenced this pull request Jun 12, 2025
* Add loaded-accounts-data-size field to sim result

* increase loaded_accounts_data_size visibility to public

* update svm examples

* update rpc tests with additional field
tao-stones added a commit that referenced this pull request Jun 13, 2025
* add change to CHANGELOG for #6023

* put under RPC section

* rewording
mergify Bot pushed a commit that referenced this pull request Jun 13, 2025
* add change to CHANGELOG for #6023

* put under RPC section

* rewording

(cherry picked from commit 6fd29a3)
tao-stones added a commit that referenced this pull request Jun 13, 2025
add change to CHANGELOG for #6023 (#6395)

* add change to CHANGELOG for #6023

* put under RPC section

* rewording

(cherry picked from commit 6fd29a3)

Co-authored-by: Tao Zhu <82401714+tao-stones@users.noreply.github.com>
RyanHealey added a commit to LMAX-Exchange/solana4j that referenced this pull request Oct 8, 2025
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.

Include Itemized CU Breakdown in simulateTransaction RPC Response

5 participants