Line data Source code
1 : #include "adminctl_client.h" 2 : #include "../../shared/fd_config.h" 3 : #include "../../shared/fd_action.h" 4 : 5 : void 6 : remove_all_authorized_voters_cmd_args( int * pargc, 7 : char *** pargv, 8 0 : args_t * args ) { 9 0 : char const * name = fd_env_strip_cmdline_cstr( pargc, pargv, "--name", NULL, NULL ); 10 0 : if( FD_UNLIKELY( name ) ) fd_cstr_ncpy( args->remove_all_authorized_voters.name, name, sizeof(args->remove_all_authorized_voters.name) ); 11 0 : } 12 : 13 : void 14 : remove_all_authorized_voters_cmd_fn( args_t * args, 15 0 : config_t * config ) { 16 : 17 0 : fd_adminctl_t * adminctl = adminctl_client_attach( config, args->remove_all_authorized_voters.name ); 18 : 19 0 : void * payload = NULL; 20 0 : ulong payload_max = 0UL; 21 0 : ulong slot_idx = fd_adminctl_reserve( adminctl, &payload, &payload_max ); 22 0 : if( FD_UNLIKELY( slot_idx==ULONG_MAX ) ) { 23 0 : FD_LOG_ERR(( "Failed to process `remove-all-authorized-voters` command as there are other pending " 24 0 : "commands that are being processed. Please wait for other commands to complete " 25 0 : "or forcefully terminate the other processes and retry the command." )); 26 0 : } 27 0 : if( FD_UNLIKELY( sizeof(fd_adminctl_remove_all_auth_voters_t)>payload_max ) ) FD_LOG_ERR(( "adminctl remove-all-authorized-voters payload too large" )); 28 : 29 0 : fd_adminctl_remove_all_auth_voters_t * req = (fd_adminctl_remove_all_auth_voters_t *)payload; 30 0 : req->version = FD_ADMINCTL_REMOVE_ALL_AUTH_VOTERS_PAYLOAD_VERSION; 31 : 32 0 : fd_adminctl_publish( adminctl, slot_idx, FD_ADMINCTL_CMD_REMOVE_ALL_AUTH_VOTERS, sizeof(fd_adminctl_remove_all_auth_voters_t) ); 33 : 34 0 : ulong result = fd_adminctl_wait( adminctl, slot_idx ); 35 0 : switch( result ) { 36 0 : case FD_ADMINCTL_RESULT_SUCCESS: 37 0 : FD_LOG_NOTICE(( "All authorized voters removed" )); 38 0 : break; 39 0 : case FD_ADMINCTL_RESULT_UNKNOWN_COMMAND: 40 0 : case FD_REMOVE_ALL_AUTH_VOTERS_RESULT_PAYLOAD_TOO_SMALL: 41 0 : case FD_REMOVE_ALL_AUTH_VOTERS_RESULT_UNSUPPORTED_PAYLOAD_VERSION: 42 0 : case FD_REMOVE_ALL_AUTH_VOTERS_RESULT_UNEXPECTED_PAYLOAD_SIZE: 43 0 : FD_LOG_ERR(( "Failed to remove authorized voter keys: the command was not able to " 44 0 : "successfully communicate with the running Firedancer process. It " 45 0 : "is possible that you are running the command from an older or " 46 0 : "newer version of Firedancer that is no longer compatible." )); 47 0 : default: 48 0 : FD_LOG_ERR(( "Unexpected remove-all-authorized-voters result %lu. This can be a result " 49 0 : "of a version mismatch between the command and the running Firedancer " 50 0 : "process. Please report this to the Firedancer team for investigation.", result )); 51 0 : } 52 0 : } 53 : 54 : static void 55 0 : remove_all_authorized_voters_args_help( fd_action_help_t * help ) { 56 0 : fd_action_help_arg( help, "--name", "<name>", "Name of the validator instance to attach to, if more than one is\n" 57 0 : "running on this host" ); 58 0 : } 59 : 60 : action_t fd_action_remove_all_authorized_voters = { 61 : .name = "remove-all-authorized-voters", 62 : .args = remove_all_authorized_voters_cmd_args, 63 : .fn = remove_all_authorized_voters_cmd_fn, 64 : .require_config = 0, 65 : .perm = NULL, 66 : .description = "Remove all authorized voters from the validator", 67 : .detail = "Removes every authorized voter key from an already running validator,\n" 68 : "including any seeded from [paths.authorized_voter_paths] at startup as\n" 69 : "well as any added at runtime with add-authorized-voter. After this the\n" 70 : "validator can only sign votes for vote accounts whose authorized voter is\n" 71 : "the identity key. On success it prints `All authorized voters removed` and\n" 72 : "exits 0. It is idempotent: removing when there are no authorized voters\n" 73 : "also succeeds.\n" 74 : "\n" 75 : "This command does not start a validator; it attaches to one that is already\n" 76 : "running. With no arguments it discovers the running validator automatically.\n" 77 : "If multiple validators are running, pass --name to select one. If --config is\n" 78 : "given, the validator is instead located from the configuration file; only the\n" 79 : "name and [hugetlbfs.mount_path] values are used, and they must match the\n" 80 : "running validator.\n" 81 : "\n" 82 : "The change is live only: it is not written back to the config file, so any\n" 83 : "voters in [paths.authorized_voter_paths] return on the validator's next\n" 84 : "restart. To drop them across restarts, also remove them from the config.", 85 : .usage = "remove-all-authorized-voters [--name <name>]", 86 : .args_help = remove_all_authorized_voters_args_help, 87 : };