feat: implement surfnet_writeProgram cheatcode (#319)#396
Merged
lgalabru merged 6 commits intosolana-foundation:mainfrom Nov 5, 2025
Merged
feat: implement surfnet_writeProgram cheatcode (#319)#396lgalabru merged 6 commits intosolana-foundation:mainfrom
lgalabru merged 6 commits intosolana-foundation:mainfrom
Conversation
Contributor
Author
|
@MicaiahReid , kindly review this pr |
Collaborator
|
Thanks @29deepanshutyagi, we'll look into this! |
Collaborator
|
This is awesome, thanks @29deepanshutyagi! I did a minor refactor, but kept nearly all of your logic. I did the following:
|
MicaiahReid
approved these changes
Nov 4, 2025
lgalabru
reviewed
Nov 5, 2025
Collaborator
lgalabru
left a comment
There was a problem hiding this comment.
Thank you @29deepanshutyagi 🙏
Contributor
Author
|
Thank you @MicaiahReid and @lgalabru for the quick review and feedback! 🙏 @MicaiahReid - Thanks for taking the time to refactor and improve the code structure. Moving the logic to locker.rs makes total sense for keeping the RPC files clean, and adding the optional authority field is a great enhancement I hadn't considered. Please Let me know if there's anything else I can help with regarding this issue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ Implemented surfnet_writeProgram cheatcode
Hi @lgalabru ,
I’ve completed the implementation for surfnet_writeProgram as described in this issue - #319
🧩 Summary
Added a new RPC method surfnet_writeProgram to support chunked program uploads with offset-based writes.
This allows writing large programs (up to 5 MB per RPC call) directly to program data accounts — without requiring signatures or buffer accounts.
Automatically creates program and program-data accounts if missing, preserves loader metadata, and maintains rent exemption after expansion.
⚙️ Key Features
Write program data in small or large chunks using an offset.
No signature or buffer creation needed — writes directly to account data.
Replicates Solana’s upgradeable loader semantics (Program + ProgramData).
Automatically recalculates rent-exempt lamports on resize.
Fully validated inputs (pubkey, hex data, offsets).
🧪 Tests
Added 17 comprehensive tests, all passing ✅:
Sequential, non-sequential, and overlapping writes
Auto account creation
Invalid input handling
Rent recalculation
Large 1 MB write
Empty and single-byte write
issue #319