Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Disable setLogFilter RPC API by default (#8693)
Browse files Browse the repository at this point in the history
automerge
  • Loading branch information
mvines authored Mar 7, 2020
1 parent 4db074a commit cea8067
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
16 changes: 13 additions & 3 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fn new_response<T>(bank: &Bank, value: T) -> RpcResponse<T> {
#[derive(Debug, Default, Clone)]
pub struct JsonRpcConfig {
pub enable_validator_exit: bool,
pub enable_set_log_filter: bool,
pub enable_get_confirmed_block: bool,
pub identity_pubkey: Pubkey,
pub faucet_addr: Option<SocketAddr>,
Expand Down Expand Up @@ -339,6 +340,13 @@ impl JsonRpcRequestProcessor {
Ok(pubkeys)
}

pub fn set_log_filter(&self, filter: String) -> Result<()> {
if self.config.enable_set_log_filter {
solana_logger::setup_with(&filter);
}
Ok(())
}

pub fn validator_exit(&self) -> Result<bool> {
if self.config.enable_validator_exit {
warn!("validator_exit request...");
Expand Down Expand Up @@ -1133,9 +1141,11 @@ impl RpcSol for RpcSolImpl {
})
}

fn set_log_filter(&self, _meta: Self::Metadata, filter: String) -> Result<()> {
solana_logger::setup_with(&filter);
Ok(())
fn set_log_filter(&self, meta: Self::Metadata, filter: String) -> Result<()> {
meta.request_processor
.read()
.unwrap()
.set_log_filter(filter)
}

fn get_confirmed_block(
Expand Down
1 change: 1 addition & 0 deletions multinode-demo/bootstrap-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ ledger_dir="$SOLANA_CONFIG_DIR"/bootstrap-validator

args+=(
--enable-rpc-exit
--enable-rpc-set-log-filter
--ledger "$ledger_dir"
--rpc-port 8899
--snapshot-interval-slots 100
Expand Down
2 changes: 2 additions & 0 deletions multinode-demo/validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ default_arg --voting-keypair "$voting_keypair_path"
default_arg --storage-keypair "$storage_keypair_path"
default_arg --ledger "$ledger_dir"
default_arg --log -
default_arg --enable-rpc-exit
default_arg --enable-rpc-set-log-filter

if [[ -n $SOLANA_CUDA ]]; then
program=$solana_validator_cuda
Expand Down
1 change: 0 additions & 1 deletion net/remote/remote-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ EOF
--enable-rpc-get-confirmed-block
)
else
args+=(--enable-rpc-exit)
if [[ -n $internalNodesLamports ]]; then
args+=(--node-lamports "$internalNodesLamports")
fi
Expand Down
7 changes: 7 additions & 0 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,12 @@ pub fn main() {
.takes_value(false)
.help("Enable the JSON RPC 'validatorExit' API. Only enable in a debug environment"),
)
.arg(
Arg::with_name("enable_rpc_set_log_filter")
.long("enable-rpc-set-log-filter")
.takes_value(false)
.help("Enable the JSON RPC 'setLogFilter' API. Only enable in a debug environment"),
)
.arg(
Arg::with_name("enable_rpc_get_confirmed_block")
.long("enable-rpc-get-confirmed-block")
Expand Down Expand Up @@ -919,6 +925,7 @@ pub fn main() {
new_hard_forks: hardforks_of(&matches, "hard_forks"),
rpc_config: JsonRpcConfig {
enable_validator_exit: matches.is_present("enable_rpc_exit"),
enable_set_log_filter: matches.is_present("enable_rpc_set_log_filter"),
enable_get_confirmed_block: matches.is_present("enable_rpc_get_confirmed_block"),
identity_pubkey: identity_keypair.pubkey(),
faucet_addr: matches.value_of("rpc_faucet_addr").map(|address| {
Expand Down

0 comments on commit cea8067

Please sign in to comment.