feat(rpc): add rpc methods to enable/disable other cheatcodes#557
feat(rpc): add rpc methods to enable/disable other cheatcodes#5570xzrf wants to merge 12 commits intosolana-foundation:mainfrom
Conversation
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!
|
@MicaiahReid what happens in the case when In other words, how will providing |
|
@0xzrf all of this enable disable endpoint and disable enable endpoint language is so confusing 🤣
This disables the {
"jsonrpc": "2.0",
"id": 1,
"method": "surfnet_disableCheatcode",
"params": [
["surfnet_enableCheatcode"],
{
"lockout": true
}
]
}This disables the {
"jsonrpc": "2.0",
"id": 1,
"method": "surfnet_disableCheatcode",
"params": [
"all",
{
"lockout": true
}
]
}Does this answer your question? |
|
Thanks, that was helpful |
MicaiahReid
left a comment
There was a problem hiding this comment.
Can we also remove the unwraps on the locks?
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)