Skip to content

Commit 7b6e566

Browse files
committed
fix default configuration
1 parent b7c9f3c commit 7b6e566

File tree

11 files changed

+46
-21
lines changed

11 files changed

+46
-21
lines changed

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ warp = "0.3"
3636

3737
[dev-dependencies]
3838
httpmock = "0.6.6"
39-
mithril-common = { path = "../mithril-common", features = ["test_only", "allow_skip_signer_certification"] }
39+
mithril-common = { path = "../mithril-common", features = ["allow_skip_signer_certification"] }
4040
mockall = "0.11.0"
4141
slog-term = "2.9.0"
4242
tempfile = "3.3.0"

mithril-aggregator/config/preview.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"environment": "Production",
23
"cardano_cli_path": "cardano-cli",
34
"cardano_node_socket_path": "/tmp/cardano.sock",
45
"network": "preview",
@@ -16,4 +17,4 @@
1617
"genesis_verification_key": "5b3132372c37332c3132342c3136312c362c3133372c3133312c3231332c3230372c3131372c3139382c38352c3137362c3139392c3136322c3234312c36382c3132332c3131392c3134352c31332c3233322c3234332c34392c3232392c322c3234392c3230352c3230352c33392c3233352c34345d",
1718
"limit_keys_in_stores": 5,
1819
"era_adapter_type": "bootstrap"
19-
}
20+
}

mithril-aggregator/src/configuration.rs

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ pub struct Configuration {
6666
/// Protocol parameters
6767
pub protocol_parameters: ProtocolParameters,
6868

69-
/// Snapshots manifest location
70-
pub url_snapshot_manifest: String,
71-
7269
/// Type of snapshot uploader to use
7370
pub snapshot_uploader_type: SnapshotUploaderType,
7471

@@ -97,7 +94,10 @@ pub struct Configuration {
9794
pub genesis_verification_key: HexEncodedGenesisVerificationKey,
9895

9996
/// Should the immutable cache be reset or not
100-
pub reset_digests_cache: Option<bool>,
97+
pub reset_digests_cache: bool,
98+
99+
/// Use the digest caching strategy
100+
pub disable_digests_cache: bool,
101101

102102
/// Max number of records in stores.
103103
/// When new records are added, oldest records are automatically deleted so
@@ -122,8 +122,9 @@ pub enum SnapshotUploaderType {
122122
Local,
123123
}
124124

125-
impl Default for Configuration {
126-
fn default() -> Self {
125+
impl Configuration {
126+
/// Create a sample configuration mainly for tests
127+
pub fn new_sample() -> Self {
127128
let genesis_verification_key = ProtocolGenesisSigner::create_deterministic_genesis_signer()
128129
.create_genesis_verifier()
129130
.to_verification_key();
@@ -139,8 +140,6 @@ impl Default for Configuration {
139140
m: 100,
140141
phi_f: 0.95,
141142
},
142-
url_snapshot_manifest: "https://storage.googleapis.com/cardano-testnet/snapshots.json"
143-
.to_string(),
144143
snapshot_uploader_type: SnapshotUploaderType::Local,
145144
snapshot_bucket_name: None,
146145
server_ip: "0.0.0.0".to_string(),
@@ -150,15 +149,14 @@ impl Default for Configuration {
150149
snapshot_directory: PathBuf::new(),
151150
data_stores_directory: PathBuf::new(),
152151
genesis_verification_key: key_encode_hex(genesis_verification_key).unwrap(),
153-
reset_digests_cache: Some(false),
152+
reset_digests_cache: false,
153+
disable_digests_cache: false,
154154
store_retention_limit: None,
155155
era_reader_adapter_type: EraReaderAdapterType::Bootstrap,
156156
era_reader_adapter_params: None,
157157
}
158158
}
159-
}
160159

161-
impl Configuration {
162160
/// Build the server URL from configuration.
163161
pub fn get_server_url(&self) -> String {
164162
format!("http://{}:{}/", self.server_ip, self.server_port)
@@ -204,6 +202,9 @@ impl Configuration {
204202
/// Default configuration with all the default values for configurations.
205203
#[derive(Debug, Clone)]
206204
pub struct DefaultConfiguration {
205+
/// Execution environment
206+
pub environment: ExecutionEnvironment,
207+
207208
/// Server listening IP
208209
pub server_ip: String,
209210

@@ -227,11 +228,15 @@ pub struct DefaultConfiguration {
227228

228229
/// ImmutableDigesterCacheProvider default setting
229230
pub reset_digests_cache: String,
231+
232+
/// ImmutableDigesterCacheProvider default setting
233+
pub disable_digests_cache: String,
230234
}
231235

232236
impl Default for DefaultConfiguration {
233237
fn default() -> Self {
234238
Self {
239+
environment: ExecutionEnvironment::Production,
235240
server_ip: "0.0.0.0".to_string(),
236241
server_port: "8080".to_string(),
237242
db_directory: "/db".to_string(),
@@ -240,6 +245,16 @@ impl Default for DefaultConfiguration {
240245
snapshot_uploader_type: "gcp".to_string(),
241246
era_reader_adapter_type: "bootstrap".to_string(),
242247
reset_digests_cache: "false".to_string(),
248+
disable_digests_cache: "false".to_string(),
249+
}
250+
}
251+
}
252+
253+
impl From<ExecutionEnvironment> for ValueKind {
254+
fn from(value: ExecutionEnvironment) -> Self {
255+
match value {
256+
ExecutionEnvironment::Production => ValueKind::String("Production".to_string()),
257+
ExecutionEnvironment::Test => ValueKind::String("Test".to_string()),
243258
}
244259
}
245260
}
@@ -253,6 +268,10 @@ impl Source for DefaultConfiguration {
253268
let mut result = Map::new();
254269
let namespace = "default configuration".to_string();
255270
let myself = self.clone();
271+
result.insert(
272+
"environment".to_string(),
273+
Value::new(Some(&namespace), ValueKind::from(myself.environment)),
274+
);
256275
result.insert(
257276
"server_ip".to_string(),
258277
Value::new(Some(&namespace), ValueKind::from(myself.server_ip)),
@@ -297,6 +316,13 @@ impl Source for DefaultConfiguration {
297316
ValueKind::from(myself.reset_digests_cache),
298317
),
299318
);
319+
result.insert(
320+
"disable_digests_cache".to_string(),
321+
Value::new(
322+
Some(&namespace),
323+
ValueKind::from(myself.disable_digests_cache),
324+
),
325+
);
300326

301327
Ok(result)
302328
}

mithril-aggregator/src/dependency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub mod tests {
289289
use mithril_common::CardanoNetwork;
290290

291291
pub async fn initialize_dependencies() -> (DependencyManager, AggregatorConfig) {
292-
let config = Configuration::default();
292+
let config = Configuration::new_sample();
293293
let mut builder = DependenciesBuilder::new(config);
294294
let dependency_manager = builder.build_dependency_container().await.unwrap();
295295

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ impl DependenciesBuilder {
621621
&self.configuration.data_stores_directory,
622622
&format!("immutables_digests_{}.json", self.configuration.network),
623623
)
624-
.should_reset_digests_cache(self.configuration.reset_digests_cache.unwrap_or(false))
624+
.should_reset_digests_cache(self.configuration.reset_digests_cache)
625625
.build()
626626
.await?;
627627

mithril-aggregator/src/stake_distribution_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ mod tests {
232232
use mithril_common::chain_observer::MockChainObserver;
233233

234234
async fn get_service(chain_observer: MockChainObserver) -> MithrilStakeDistributionService {
235-
let mut builder = DependenciesBuilder::new(crate::Configuration::default());
235+
let mut builder = DependenciesBuilder::new(crate::Configuration::new_sample());
236236
let stake_service = MithrilStakeDistributionService::new(
237237
builder.get_stake_store().await.unwrap(),
238238
Arc::new(chain_observer),

mithril-aggregator/tests/test_extensions/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#[macro_use]
66
pub mod runtime_tester;
7-
//mod dependency;
87
#[macro_use]
98
pub mod utilities;
109

mithril-aggregator/tests/test_extensions/runtime_tester.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl RuntimeTester {
7070
)]));
7171
let configuration = Configuration {
7272
protocol_parameters: default_protocol_parameters,
73-
..Default::default()
73+
..Configuration::new_sample()
7474
};
7575
let mut deps_builder = DependenciesBuilder::new(configuration);
7676
deps_builder.snapshot_uploader = Some(snapshot_uploader.clone());

mithril-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tokio = { version = "1", features = ["full"] }
3434

3535
[dev-dependencies]
3636
httpmock = "0.6.6"
37-
mithril-common = { path = "../mithril-common", features = ["test_only"] }
37+
mithril-common = { path = "../mithril-common" }
3838
mockall = "0.11.0"
3939

4040
[features]

mithril-common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,5 @@ serde_yaml = "0.9.10"
7575
[features]
7676
default = []
7777
portable = ["mithril-stm/portable"] # portable feature avoids SIGILL crashes on CPUs not supporting Intel ADX instruction set when built on CPUs that support it
78-
test_only = []
7978
allow_skip_signer_certification = []
8079

0 commit comments

Comments
 (0)