feature(rpc): Adds rpc methods to enable/disable other cheatcodes#557
Open
0xzrf wants to merge 2 commits intosolana-foundation:mainfrom
Open
feature(rpc): Adds rpc methods to enable/disable other cheatcodes#5570xzrf wants to merge 2 commits intosolana-foundation:mainfrom
0xzrf wants to merge 2 commits intosolana-foundation:mainfrom
Conversation
MicaiahReid
requested changes
Mar 9, 2026
Collaborator
MicaiahReid
left a comment
There was a problem hiding this comment.
This is awesome. The core internal logic is there, but I'd like to simplify the RPC interface a bit.
I'd like to keep all of the same functionality you've implemented, but only have a total of two new RPC methods:
surfnet_enableCheatcodesurfnet_disableCheatcode
When disabling a cheatcode, you can optionally provide { lockout: true } to allow disabling surfnet_enableCheatcode. For the enable/disable method, a list of methods can be provided, or just the string "all".
Here are some example requests.
Enable all cheatcodes (if `surfnet_enableCheatcode` is enabled)
**Note**: if previously `surfnet_enableCheatcode` was disabled, this would return an error ```JSON { "jsonrpc": "2.0", "id": 1, "method": "surfnet_enableCheatcode", "params": [ "all" ] } ```Disable all cheatcodes (except `surfnet_enableCheatcode`/`surfnet_disableCheatcode`, since no lockout option provided)
{
"jsonrpc": "2.0",
"id": 1,
"method": "surfnet_disableCheatcode",
"params": [
"all"
]
}Disable the set account + set token account cheatcodes
{
"jsonrpc": "2.0",
"id": 1,
"method": "surfnet_disableCheatcode",
"params": [
["surfnet_setAccount", "surfnet_setTokenAccount"]
]
}Disable the set account + set token account cheatcodes
{
"jsonrpc": "2.0",
"id": 1,
"method": "surfnet_disableCheatcode",
"params": [
["surfnet_setAccount", "surfnet_setTokenAccount"]
]
}Disable `surfnet_enableCheatcode`
If we didn't provide `{"lockout": true}` the method would return an error, saying to disable this cheatcode you need to provide the flag ```JSON { "jsonrpc": "2.0", "id": 1, "method": "surfnet_disbleCheatcode", "params": [ ["surfnet_enableCheatcode"], { "lockout": true } ] } ```Hopefully those examples help clarify!
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 #543
Summary
This PR adds new rpc methods to the
SurfnetCheatcodestrait to disable and enable different cheat codesWhat Changed
disable_cheatcodes,enable_cheatcodes,lockout,disable_all_cheatcodesrpc methodsCheatcodeConfigstruct,CheatcodeFilterenum andRpcCheatcodesinsurfpool-typescrate. Here's the description for each:cheatcodes_config: Arc<Mutex<CheatcodeConfig>>toRunloopContextstruct to allow cheatcode method filtering betweenRunloopContextandSurfpoolMiddlewaresurfnet_disableCheatcodeandsurfnet_enableCheatcodemajorly just push to theCheatcodeFilter::ListCheatcodeFilter::Listvariant(And rejects all the cheatcode rpc calls whenCheatcodeFilter::All)lockoutanddisable_all_cheatcodesbasically manipulate the state inside theCheatcodeConfigstruct, while theCheatcodeConfig::is_cheatcode_disabled()handles whether to reject the request or notcrates/core/src/tests/ingration.rs:test_enable_and_disable_cheatcodesContext
This PR is motivated by the issue #543 and (hopefully) adheres to mostly all the code expectation provided by @MicaiahReid , except the admin control(More then happy to add that too once I get some clarity on that part)