-
Notifications
You must be signed in to change notification settings - Fork 106
feat: introduce the surfnet_exportSnapshot cheatcode
#364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| /// A cheat code to export all accounts as fixtures for testing. | ||
| /// | ||
| /// ## Parameters | ||
| /// - `meta`: Metadata passed with the request, such as the client's request context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, this param meta being here is a copy-pasta in the first place, could you please get rid of it?
This docstring is meant to be documenting the RPC endpoint, not the rust method.
lgalabru
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it, thank you @Shradhesh71 !
Some small feedback!
|
@lgalabru Pushed updates addressing all feedback |
|
Thanks @Shradhesh71 ! Could you run the command on your machine? that should fix the CI! I just added this button in the studio, looking forward to get this new cheat code in the next release :)
|
lgalabru
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your contribution @Shradhesh71, the code looks good to me!
|
hey @Shradhesh71! I talked with @MicaiahReid and it looks like your approach could be missing something. If a transaction is updating the state of an account, it looks like the current approach would not capture that. |
yep, I’ll look into why transactions that update account state aren’t being captured, reproduce the case, and push a follow up here |
|
@Shradhesh71 we'd love to get this feature wrapped-up for our incoming release, would you have some bandwidth to take it to the finish line or would you like us to takeover? |
|
yeah, everything looks perfect now and is ready for incoming release |
| /// - `config`: An optional `ExportSnapshotConfig` to customize the export behavior. The config fields are: | ||
| /// - `includeParsedAccounts`: If true, includes parsed account data in the snapshot. | ||
| /// - `filter`: An optional filter config to limit which accounts are included in the snapshot. Fields include: | ||
| /// - `includeProgramAccounts`: A list of program IDs to include accounts for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy pasta, this is a bool?
We know that at some point we'll differentiate local vs fetched, should we already introduce this distinction? It could be an enum instead - all (supported with this version), (remoteOnly to be supported)
| #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub struct ExportSnapshotFilter { | ||
| pub include_program_accounts: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include_program_accounts or include_executable_accounts ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include_executable_accounts doesn't cover it - a buffer account or a programdata account (which stores the bulk of program data) isn't executable, but it's a program account (owned by one of the bpf loader programs)
lgalabru
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great, added some no strongly opinionated feedback will leave it up to you!
surfnet_exportSnapshot cheatcode

Changes
Flat Key/Value Dump with Slot Tracking
account_update_slots: HashMap<Pubkey, Slot>field to SurfnetSvm to track when each account was last modified.set_account()method to record the modification slot for each account update.export_accounts_as_fixtures()method that exports all accounts as a flat map with slot information.AccountFixturestruct with the following fields:JsonParsedencoding)RPC Method
surfnet_exportSnapshotRPC method to SurfnetCheatcodes trait.encodingparameter (defaults toBase64).HashMap<String, AccountFixture>with all accounts.Test Coverage
test_export_accounts_as_fixtures— Basic export with Base64 encodingtest_export_accounts_as_fixtures_with_json_parsed— Export with JsonParsed encoding for token accountstest_export_accounts_at_different_slots— Verify slot tracking across multiple slot updates