feat(svm): add patch_raw in set_account#404
Merged
MicaiahReid merged 20 commits intosolana-foundation:mainfrom Apr 10, 2026
Merged
feat(svm): add patch_raw in set_account#404MicaiahReid merged 20 commits intosolana-foundation:mainfrom
MicaiahReid merged 20 commits intosolana-foundation:mainfrom
Conversation
MicaiahReid
requested changes
Apr 2, 2026
Collaborator
MicaiahReid
left a comment
There was a problem hiding this comment.
This is so awesome!! Love this. This is a really well-written PR.
I've left a few comments, I also have a preference on syntax, for consistency with other actions. Instead of an array:
action "setup_surfnet" "svm::setup_surfnet" {
set_account {
public_key = "3BznENHP5KkRikLZqCLGLTaVGcDBsWDTLjSCbHZD2qTA"
patch_raw = [
{
offset = 8
length = 32
field_value = "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"
field_type = "pubkey"
},
...
]
}
}a map type:
action "setup_surfnet" "svm::setup_surfnet" {
set_account {
public_key = "3BznENHP5KkRikLZqCLGLTaVGcDBsWDTLjSCbHZD2qTA"
patch_raw {
offset = 8
length = 32
field_value = "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"
field_type = "pubkey"
}
patch_raw {
offset = 7960
length = 32
field_value = "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo"
field_type = "pubkey"
}
...
}
}It's the same result, but a slightly cleaner and more "HCL" interface (IMO).
Also! Thoughts on just value / type instead of field_value & field_type?
Co-authored-by: Micaiah Reid <micaiahreid@gmail.com>
MicaiahReid
approved these changes
Apr 8, 2026
Collaborator
MicaiahReid
left a comment
There was a problem hiding this comment.
LFG, awesome stuff, thanks @aspnxdd!
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.
Closes #401
Overview
This PR adds support for raw byte-level patching of account data during the
setup_surfnetset_accountsetup phase. This allows precise, typed mutations to specific offsets within an account's data; useful when you need to update fields like public keys or numeric values at known byte positions.Example Usage
Changes
New type:
SET_ACCOUNT_PATCH_RAW(addons/svm/types/src/lib.rs)offset,length,field_value, andfield_typefieldsfield_typevalues includepubkey,u64, and others (see known limitation below)Extended type:
SET_ACCOUNT_MAPpatch_rawfield accepting an array ofSET_ACCOUNT_PATCH_RAWobjectsUpdated:
SetupSurfpoolcommandpatch_rawis present, providing the required context for mutationsSurfpoolAccountUpdate::parse_value_storeso patches are applied correctlyKnown Limitation
The typing of
field_valueis currently loose: it accepts aString,Int,Bytes,Pubkey, etc., but this is not yet well-reflected in the documentation or type definitions. A follow-up issue should be opened to tighten the type signature and improve the developer experience here.How to test it:
I tested it/played around it outside of rust tests, using surfpool: Please view this branch of my surfpool fork to see how I used it. In this branch I use a Meteora DLMM account and I switch some data, then I later see it on a TS script: