Skip to content

Commit

Permalink
Turn back into noop
Browse files Browse the repository at this point in the history
  • Loading branch information
staffik committed Jun 10, 2024
1 parent 637d384 commit a153c73
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 172 deletions.
6 changes: 1 addition & 5 deletions chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,6 @@ impl Client {
.produce_chunk_add_transactions_time_limit
.update(update_client_config.produce_chunk_add_transactions_time_limit);
}

pub(crate) fn update_validator_signer(&self, signer: Arc<ValidatorSigner>) -> bool {
self.validator_signer.update(Some(signer))
}
}

// Debug information about the upcoming block.
Expand Down Expand Up @@ -403,7 +399,7 @@ impl Client {
shards_manager_adapter,
sharded_tx_pool,
network_adapter,
validator_signer: MutableConfigValue::new(validator_signer, "validator_signer"),
validator_signer,
pending_approvals: lru::LruCache::new(num_block_producer_seats),
catchup_state_syncs: HashMap::new(),
epoch_sync,
Expand Down
15 changes: 5 additions & 10 deletions chain/client/src/client_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,17 +1159,12 @@ impl ClientActorInner {
/// Returns the delay before the next time `check_triggers` should be called, which is
/// min(time until the closest trigger, 1 second).
pub(crate) fn check_triggers(&mut self, ctx: &mut dyn DelayedActionRunner<Self>) -> Duration {
let _span = tracing::debug_span!(target: "client", "check_triggers").entered();
let _span: tracing::span::EnteredSpan =
tracing::debug_span!(target: "client", "check_triggers").entered();
if let Some(config_updater) = &mut self.config_updater {
config_updater.try_update(
&|updateable_client_config| {
self.client.update_client_config(updateable_client_config)
},
&|validator_signer| self.client.update_validator_signer(validator_signer),
);
if config_updater.was_validator_signer_updated() {
self.network_adapter.send(PeerManagerMessageRequest::AdvertiseTier1Proxies);
}
config_updater.try_update(&|updateable_client_config| {
self.client.update_client_config(updateable_client_config)
});
}

// Check block height to trigger expected shutdown
Expand Down
22 changes: 2 additions & 20 deletions chain/client/src/config_updater.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use near_chain_configs::UpdateableClientConfig;
use near_dyn_configs::{UpdateableConfigLoaderError, UpdateableConfigs};
use near_primitives::validator_signer::ValidatorSigner;
use std::sync::Arc;
use tokio::sync::broadcast::Receiver;

Expand All @@ -10,42 +9,25 @@ pub struct ConfigUpdater {
rx_config_update: Receiver<Result<UpdateableConfigs, Arc<UpdateableConfigLoaderError>>>,
/// Represents the latest Error of reading the dynamically reloadable configs.
updateable_configs_error: Option<Arc<UpdateableConfigLoaderError>>,
/// Represents whether validator key was updated during the last reload.
validator_signer_updated: bool,
}

impl ConfigUpdater {
pub fn new(
rx_config_update: Receiver<Result<UpdateableConfigs, Arc<UpdateableConfigLoaderError>>>,
) -> Self {
Self { rx_config_update, updateable_configs_error: None, validator_signer_updated: false }
}

pub fn was_validator_signer_updated(&self) -> bool {
self.validator_signer_updated
Self { rx_config_update, updateable_configs_error: None }
}

/// Check if any of the configs were updated.
/// If they did, the receiver (rx_config_update) will contain a clone of the new configs.
pub fn try_update(
&mut self,
update_client_config_fn: &dyn Fn(UpdateableClientConfig),
update_validator_signer_fn: &dyn Fn(Arc<ValidatorSigner>) -> bool,
) {
self.validator_signer_updated = false;
pub fn try_update(&mut self, update_client_config_fn: &dyn Fn(UpdateableClientConfig)) {
while let Ok(maybe_updateable_configs) = self.rx_config_update.try_recv() {
match maybe_updateable_configs {
Ok(updateable_configs) => {
if let Some(client_config) = updateable_configs.client_config {
update_client_config_fn(client_config);
tracing::info!(target: "config", "Updated ClientConfig");
}
if let Some(validator_signer) = updateable_configs.validator_signer {
if update_validator_signer_fn(validator_signer) {
self.validator_signer_updated = true;
}
tracing::info!(target: "config", "Updated validator key");
}
self.updateable_configs_error = None;
}
Err(err) => {
Expand Down
8 changes: 0 additions & 8 deletions chain/network/src/peer_manager/peer_manager_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,14 +1026,6 @@ impl PeerManagerActor {
self.handle_msg_network_requests(msg, ctx),
)
}
PeerManagerMessageRequest::AdvertiseTier1Proxies => {
let state = self.state.clone();
let clock = self.clock.clone();
ctx.spawn(wrap_future(async move {
state.tier1_advertise_proxies(&clock).await;
}));
PeerManagerMessageResponse::AdvertiseTier1Proxies
}
PeerManagerMessageRequest::OutboundTcpConnect(stream) => {
let peer_addr = stream.peer_addr;
if let Err(err) =
Expand Down
4 changes: 0 additions & 4 deletions chain/network/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ pub struct SetChainInfo(pub ChainInfo);
#[rtype(result = "PeerManagerMessageResponse")]
pub enum PeerManagerMessageRequest {
NetworkRequests(NetworkRequests),
/// Request PeerManager to advertise tier 1 proxies.
/// Used internally.
AdvertiseTier1Proxies,
/// Request PeerManager to connect to the given peer.
/// Used in tests and internally by PeerManager.
/// TODO: replace it with AsyncContext::spawn/run_later for internal use.
Expand Down Expand Up @@ -196,7 +193,6 @@ impl PeerManagerMessageRequest {
#[derive(actix::MessageResponse, Debug)]
pub enum PeerManagerMessageResponse {
NetworkResponses(NetworkResponses),
AdvertiseTier1Proxies,
/// TEST-ONLY
OutboundTcpConnect,
FetchRoutingTable(RoutingTableInfo),
Expand Down
5 changes: 0 additions & 5 deletions core/dyn-configs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use near_async::time::Clock;
use near_chain_configs::UpdateableClientConfig;
use near_o11y::log_config::LogConfig;
use near_primitives::validator_signer::ValidatorSigner;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::sync::Arc;
Expand All @@ -18,8 +17,6 @@ pub struct UpdateableConfigs {
pub log_config: Option<LogConfig>,
/// Contents of the `config.json` corresponding to the mutable fields of `ClientConfig`.
pub client_config: Option<UpdateableClientConfig>,
/// Validator key hot loaded from file.
pub validator_signer: Option<Arc<ValidatorSigner>>,
}

/// Pushes the updates to listeners.
Expand All @@ -38,8 +35,6 @@ pub enum UpdateableConfigLoaderError {
OpenAndRead { file: PathBuf, err: std::io::Error },
#[error("Can't open or read the config file {file:?}: {err:?}")]
ConfigFileError { file: PathBuf, err: anyhow::Error },
#[error("Can't open or read the validator key file {file:?}: {err:?}")]
ValidatorKeyFileError { file: PathBuf, err: anyhow::Error },
#[error("One or multiple dynamic config files reload errors {0:?}")]
Errors(Vec<UpdateableConfigLoaderError>),
#[error("No home dir set")]
Expand Down
41 changes: 2 additions & 39 deletions nearcore/src/dyn_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ use crate::config::Config;
use near_chain_configs::UpdateableClientConfig;
use near_dyn_configs::{UpdateableConfigLoaderError, UpdateableConfigs};
use near_o11y::log_config::LogConfig;
use near_primitives::validator_signer::ValidatorSigner;
use serde::Deserialize;
use std::{
path::{Path, PathBuf},
sync::Arc,
};
use std::path::{Path, PathBuf};

pub const LOG_CONFIG_FILENAME: &str = "log_config.json";

Expand Down Expand Up @@ -35,22 +31,9 @@ pub fn read_updateable_configs(
};
let updateable_client_config = config.as_ref().map(get_updateable_client_config);

let validator_signer = if let Some(config) = config {
read_validator_key(home_dir, &config).unwrap_or_else(|err| {
errs.push(err);
None
})
} else {
None
};

if errs.is_empty() {
crate::metrics::CONFIG_CORRECT.set(1);
Ok(UpdateableConfigs {
log_config,
client_config: updateable_client_config,
validator_signer,
})
Ok(UpdateableConfigs { log_config, client_config: updateable_client_config })
} else {
tracing::warn!(target: "neard", "Dynamically updateable configs are not valid. Please fix this ASAP otherwise the node will be unable to restart: {:?}", &errs);
crate::metrics::CONFIG_CORRECT.set(0);
Expand Down Expand Up @@ -103,23 +86,3 @@ where
},
}
}

fn read_validator_key(
home_dir: &Path,
config: &Config,
) -> Result<Option<Arc<ValidatorSigner>>, UpdateableConfigLoaderError> {
let validator_file: PathBuf = home_dir.join(&config.validator_key_file);
match crate::config::load_validator_key(&validator_file) {
Ok(Some(validator_signer)) => {
tracing::info!(target: "neard", "Hot loading validator key {}.", validator_file.display());
Ok(Some(validator_signer))
}
Ok(None) => {
tracing::info!(target: "neard", "No validator key {}.", validator_file.display());
Ok(None)
}
Err(err) => {
Err(UpdateableConfigLoaderError::ValidatorKeyFileError { file: validator_file, err })
}
}
}
2 changes: 0 additions & 2 deletions nightly/pytest-sanity.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ pytest --timeout=240 sanity/switch_node_key.py
pytest --timeout=240 sanity/switch_node_key.py --features nightly
pytest --timeout=240 sanity/validator_switch_key.py
pytest --timeout=240 sanity/validator_switch_key.py --features nightly
pytest --timeout=120 sanity/validator_switch_key_quick.py
pytest --timeout=120 sanity/validator_switch_key_quick.py --features nightly
pytest sanity/proxy_simple.py
pytest sanity/proxy_simple.py --features nightly
pytest sanity/proxy_restart.py
Expand Down
5 changes: 0 additions & 5 deletions pytest/lib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,6 @@ def kill(self, *, gentle=False):
self._process.wait(5)
self._process = None

def reload_updateable_config(self):
logger.info(f"Reloading updateable config for node {self.ordinal}.")
"""Sends SIGHUP signal to the process in order to trigger updateable config reload."""
self._process.send_signal(signal.SIGHUP)

def reset_data(self):
shutil.rmtree(os.path.join(self.node_dir, "data"))

Expand Down
74 changes: 0 additions & 74 deletions pytest/tests/sanity/validator_switch_key_quick.py

This file was deleted.

0 comments on commit a153c73

Please sign in to comment.