Skip to content

Commit dac024c

Browse files
committed
Merge branch 'rumenov/r23' into 'master'
fix: make the local store path required in the IC config The local store path is required in theory but not in practice. Enforcing that we require this value reduces bloat and removes a bunch of unwrap statements. See merge request dfinity-lab/public/ic!11867
2 parents 8f5fe86 + ba9ad51 commit dac024c

File tree

12 files changed

+27
-90
lines changed

12 files changed

+27
-90
lines changed

ic-os/guestos/rootfs/opt/ic/share/ic.json5.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// Configuration of registry client
1818
// ============================================
1919
registry_client: {
20-
// The default is not to specify it.
20+
// The directory that should be used to persist registry content.
2121
local_store: "/var/lib/ic/data/ic_registry_local_store/"
2222
},
2323
// ============================================

rs/config/src/config_sample.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ pub const SAMPLE_CONFIG: &str = r#"
8686
// Configuration of registry client
8787
// ============================================
8888
registry_client: {
89-
// The default is not to specify it.
89+
// The directory that should be used to persist registry content.
90+
local_store: "/var/lib/ic/data/ic_registry_local_store/"
9091
},
9192
// ============================================
9293
// Configuration of the node state persistence.

rs/config/src/registry_client.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
use serde::{Deserialize, Serialize};
22
use std::path::PathBuf;
33

4-
/// Eventually, the replica will only read registry data from the local store
5-
/// and the orchestrator will both read from and write to the registry local
6-
/// store.
7-
///
8-
/// I.e. all data provider variants except for the variant `LocalStore` are
9-
/// considered deprecated.
4+
/// The replica only reads registry data from the local store.
5+
/// The orchestrator both reads from and writes to the registry local store.
106
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
117
pub struct Config {
12-
#[serde(flatten)]
13-
pub data_provider: Option<DataProviderConfig>,
14-
}
15-
16-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
17-
#[serde(rename_all = "snake_case")]
18-
pub enum DataProviderConfig {
19-
/// A path to a directory that containing the locally persisted registry.
20-
LocalStore(PathBuf),
8+
pub local_store: PathBuf,
219
}

rs/monitoring/onchain_observability/adapter/src/main.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use ic_adapter_metrics_server::start_metrics_grpc;
99
use ic_async_utils::{abort_on_panic, incoming_from_nth_systemd_socket};
1010
use ic_base_types::{CanisterId, NodeId};
1111
use ic_canister_client::{Agent, Sender};
12-
use ic_config::registry_client::DataProviderConfig;
1312
use ic_crypto::CryptoComponent;
1413
use ic_interfaces::crypto::{BasicSigner, ErrorReproducibility, KeyManager};
1514
use ic_logger::{error, info, new_replica_logger_from_config, warn, ReplicaLogger};
@@ -340,13 +339,7 @@ async fn create_registry_client_and_crypto_component(
340339
config: Config,
341340
rt_handle: Handle,
342341
) -> (Arc<RegistryClientImpl>, Arc<CryptoComponent>) {
343-
let DataProviderConfig::LocalStore(local_store_from_config) = config
344-
.registry_config
345-
.data_provider
346-
.as_ref()
347-
.expect("No registry provider found");
348-
349-
let data_provider = Arc::new(LocalStoreImpl::new(local_store_from_config));
342+
let data_provider = Arc::new(LocalStoreImpl::new(config.registry_config.local_store));
350343
let registry_client = Arc::new(RegistryClientImpl::new(
351344
data_provider,
352345
Some(&metrics_registry),

rs/orchestrator/registry_replicator/src/args.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clap::Parser;
2-
use ic_config::{logger::LogFormat, registry_client::DataProviderConfig, Config};
2+
use ic_config::{logger::LogFormat, Config};
33
use slog::Level;
44
use std::{
55
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
@@ -67,9 +67,7 @@ impl RegistryReplicatorArgs {
6767
config.logger.dc_id = self.dc_id;
6868
config.registration.nns_pub_key_pem = Some(self.nns_pub_key_pem.clone());
6969
config.registration.nns_url = Some(self.nns_url.clone());
70-
config.registry_client.data_provider = Some(DataProviderConfig::LocalStore(
71-
self.local_store_path.clone(),
72-
));
70+
config.registry_client.local_store = self.local_store_path.clone();
7371
config.nns_registry_replicator.poll_delay_duration_ms = self.poll_delay_duration_ms;
7472

7573
(config, _dir)

rs/orchestrator/registry_replicator/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
3131
use crate::internal_state::InternalState;
3232
use ic_config::metrics::{Config as MetricsConfig, Exporter};
33-
use ic_config::{registry_client::DataProviderConfig, Config};
33+
use ic_config::Config;
3434
use ic_crypto_utils_threshold_sig_der::parse_threshold_sig_key;
3535
use ic_http_endpoints_metrics::MetricsHttpEndpoint;
3636
use ic_interfaces_registry::{RegistryClient, RegistryDataProvider, ZERO_REGISTRY_VERSION};
@@ -92,12 +92,7 @@ impl RegistryReplicator {
9292
config: &Config,
9393
) -> Self {
9494
// We only support the local store data provider
95-
let DataProviderConfig::LocalStore(local_store_path) = config
96-
.registry_client
97-
.data_provider
98-
.clone()
99-
.expect("registry data provider is not configured");
100-
95+
let local_store_path = &config.registry_client.local_store;
10196
let local_store = Arc::new(LocalStoreImpl::new(local_store_path.clone()));
10297
std::fs::create_dir_all(local_store_path)
10398
.expect("Could not create directory for registry local store.");

rs/registry/client/src/client.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//! immediately. The provided data provider is polled periodically in the
33
//! background when start_polling() is called.
44
use crossbeam_channel::{RecvTimeoutError, Sender, TrySendError};
5-
pub use ic_config::registry_client::DataProviderConfig;
65
pub use ic_interfaces_registry::{
76
empty_zero_registry_record, RegistryClient, RegistryClientVersionedResult,
87
RegistryDataProvider, RegistryTransportRecord, POLLING_PERIOD, ZERO_REGISTRY_VERSION,

rs/replay/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use crate::ingress::*;
1919
use crate::player::{Player, ReplayResult};
2020

2121
use ic_canister_client::{Agent, Sender};
22-
use ic_config::registry_client::DataProviderConfig;
2322
use ic_config::{Config, ConfigSource};
2423
use ic_nns_constants::GOVERNANCE_CANISTER_ID;
2524
use ic_protobuf::registry::subnet::v1::InitialNiDkgTranscriptRecord;
@@ -98,9 +97,7 @@ pub fn replay(args: ReplayToolArgs) -> ReplayResult {
9897

9998
// Override config
10099
if let Some(path) = args.data_root {
101-
cfg.registry_client.data_provider = Some(DataProviderConfig::LocalStore(
102-
path.join("ic_registry_local_store"),
103-
));
100+
cfg.registry_client.local_store = path.join("ic_registry_local_store");
104101
cfg.state_manager = ic_config::state_manager::Config::new(path.join("ic_state"));
105102
cfg.artifact_pool.consensus_pool_path = path.join("ic_consensus_pool");
106103
}

rs/replay/src/player.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ use ic_artifact_pool::{
77
certification_pool::CertificationPoolImpl,
88
consensus_pool::{ConsensusPoolImpl, UncachedConsensusPoolImpl},
99
};
10-
use ic_config::{
11-
artifact_pool::ArtifactPoolConfig, registry_client::DataProviderConfig,
12-
subnet_config::SubnetConfigs, Config,
13-
};
10+
use ic_config::{artifact_pool::ArtifactPoolConfig, subnet_config::SubnetConfigs, Config};
1411
use ic_consensus::{
1512
certification::VerifierImpl,
1613
consensus::{
@@ -118,7 +115,7 @@ pub struct Player {
118115
ingress_history_reader: Box<dyn IngressHistoryReader>,
119116
certification_pool: Option<CertificationPoolImpl>,
120117
pub registry: Arc<RegistryClientImpl>,
121-
local_store_path: Option<PathBuf>,
118+
local_store_path: PathBuf,
122119
replica_version: ReplicaVersion,
123120
pub log: ReplicaLogger,
124121
_async_log_guard: AsyncGuard,
@@ -253,14 +250,6 @@ impl Player {
253250
registry.get_latest_version(),
254251
&log,
255252
);
256-
let local_store_path = if let Some(DataProviderConfig::LocalStore(path)) =
257-
cfg.registry_client.data_provider.clone()
258-
{
259-
Some(path)
260-
} else {
261-
None
262-
};
263-
264253
let metrics_registry = MetricsRegistry::new();
265254
let subnet_config = SubnetConfigs::default().own_subnet_config(subnet_type);
266255

@@ -315,7 +304,7 @@ impl Player {
315304
metrics_registry.clone(),
316305
)
317306
});
318-
307+
let local_store_path = cfg.registry_client.local_store.clone();
319308
let validator = consensus_pool.as_ref().map(|pool| {
320309
ReplayValidator::new(
321310
cfg,
@@ -330,7 +319,6 @@ impl Player {
330319
log.clone(),
331320
)
332321
});
333-
334322
Player {
335323
state_manager,
336324
message_routing,
@@ -631,9 +619,7 @@ impl Player {
631619
/// Fetch registry records from the given `nns_url`, and update the local
632620
/// registry store with the new records.
633621
pub fn update_registry_local_store(&self) {
634-
let local_store_path = self.local_store_path.clone().expect(
635-
"update_registry_local_store can only be used with registry configured with local store");
636-
println!("RegistryLocalStore path: {:?}", local_store_path);
622+
println!("RegistryLocalStore path: {:?}", &self.local_store_path);
637623
let latest_version = self.registry.get_latest_version();
638624
println!("RegistryLocalStore latest version: {}", latest_version);
639625
let records = self
@@ -642,7 +628,7 @@ impl Player {
642628
current_time() + Duration::from_secs(60),
643629
)
644630
.unwrap_or_else(|err| panic!("Error in get_certified_changes_since: {}", err));
645-
write_records_to_local_store(&local_store_path, latest_version, records)
631+
write_records_to_local_store(&self.local_store_path, latest_version, records)
646632
}
647633

648634
/// Deliver finalized batches since last expected batch height.
@@ -1232,13 +1218,7 @@ fn setup_registry(
12321218
config: Config,
12331219
metrics_registry: Option<&MetricsRegistry>,
12341220
) -> std::sync::Arc<RegistryClientImpl> {
1235-
let data_provider = match config
1236-
.registry_client
1237-
.data_provider
1238-
.expect("Data provider required")
1239-
{
1240-
DataProviderConfig::LocalStore(path) => Arc::new(LocalStoreImpl::new(path)),
1241-
};
1221+
let data_provider = Arc::new(LocalStoreImpl::new(config.registry_client.local_store));
12421222

12431223
let registry = Arc::new(RegistryClientImpl::new(data_provider, metrics_registry));
12441224
if let Err(e) = registry.fetch_and_start_polling() {

rs/replica/src/main.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
//! Replica -- Internet Computer
22
33
use ic_async_utils::{abort_on_panic, shutdown_signal};
4-
use ic_config::{
5-
registry_client::DataProviderConfig,
6-
{subnet_config::SubnetConfigs, Config},
7-
};
4+
use ic_config::{subnet_config::SubnetConfigs, Config};
85
use ic_crypto_sha::Sha256;
96
use ic_crypto_tls_interfaces::TlsHandshake;
107
use ic_http_endpoints_metrics::MetricsHttpEndpoint;
@@ -261,11 +258,9 @@ fn main() -> io::Result<()> {
261258
&logger.inner_logger.root,
262259
);
263260

264-
let registry_certified_time_reader: Arc<dyn LocalStoreCertifiedTimeReader> = {
265-
let DataProviderConfig::LocalStore(path) =
266-
config.registry_client.data_provider.clone().unwrap();
267-
Arc::new(LocalStoreImpl::new(path))
268-
};
261+
let registry_certified_time_reader: Arc<dyn LocalStoreCertifiedTimeReader> = Arc::new(
262+
LocalStoreImpl::new(config.registry_client.local_store.clone()),
263+
);
269264

270265
info!(logger, "Constructing IC stack");
271266
let (_, _, _p2p_thread_joiner, _, _xnet_endpoint) =

0 commit comments

Comments
 (0)