Skip to content

Commit 6364a1f

Browse files
committed
feat: make allow_unparsable_block configurable on Aggregator node
Add 'allow_unparsable_block' clap argument and Configuration parameter.
1 parent 6d1a372 commit 6364a1f

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

mithril-aggregator/src/commands/serve_command.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ pub struct ServeCommand {
3636
/// Will be ignored if set in conjunction with `--disable-digests-cache`.
3737
#[clap(long)]
3838
reset_digests_cache: bool,
39+
40+
/// If set no error is returned in case of unparsable block and an error log is written instead.
41+
///
42+
/// Will be ignored on production networks.
43+
#[clap(long)]
44+
allow_unparsable_block: bool,
3945
}
4046

4147
impl Source for ServeCommand {

mithril-aggregator/src/configuration.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ pub struct Configuration {
147147

148148
/// Time interval at which the signers in [Self::cexplorer_pools_url] will be imported (in minutes).
149149
pub signer_importer_run_interval: u64,
150+
151+
/// If set no error is returned in case of unparsable block and an error log is written instead.
152+
///
153+
/// Will be ignored on production networks.
154+
pub allow_unparsable_block: bool,
150155
}
151156

152157
/// Uploader needed to copy the snapshot once computed.
@@ -218,6 +223,7 @@ impl Configuration {
218223
zstandard_parameters: Some(ZstandardCompressionParameters::default()),
219224
cexplorer_pools_url: None,
220225
signer_importer_run_interval: 1,
226+
allow_unparsable_block: false,
221227
}
222228
}
223229

@@ -348,6 +354,11 @@ pub struct DefaultConfiguration {
348354

349355
/// Signer importer run interval default setting
350356
pub signer_importer_run_interval: u64,
357+
358+
/// If set no error is returned in case of unparsable block and an error log is written instead.
359+
///
360+
/// Will be ignored on production networks.
361+
pub allow_unparsable_block: String,
351362
}
352363

353364
impl Default for DefaultConfiguration {
@@ -367,6 +378,7 @@ impl Default for DefaultConfiguration {
367378
snapshot_compression_algorithm: "zstandard".to_string(),
368379
snapshot_use_cdn_domain: "false".to_string(),
369380
signer_importer_run_interval: 720,
381+
allow_unparsable_block: "false".to_string(),
370382
}
371383
}
372384
}
@@ -465,6 +477,13 @@ impl Source for DefaultConfiguration {
465477
ValueKind::from(myself.signer_importer_run_interval),
466478
),
467479
);
480+
result.insert(
481+
"allow_unparsable_block".to_string(),
482+
Value::new(
483+
Some(&namespace),
484+
ValueKind::from(myself.allow_unparsable_block),
485+
),
486+
);
468487

469488
Ok(result)
470489
}

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,12 @@ impl DependenciesBuilder {
714714
}
715715

716716
async fn build_transaction_parser(&mut self) -> Result<Arc<dyn TransactionParser>> {
717-
// TODO: 'allow_unparsable_block' parameter should be configurable
718-
let allow_unparsable_block = false;
719-
let transaction_parser =
720-
CardanoTransactionParser::new(self.get_logger().await?, allow_unparsable_block);
717+
let transaction_parser = CardanoTransactionParser::new(
718+
self.get_logger().await?,
719+
self.configuration
720+
.get_network()?
721+
.allow_unparsable_block(self.configuration.allow_unparsable_block)?,
722+
);
721723

722724
Ok(Arc::new(transaction_parser))
723725
}

0 commit comments

Comments
 (0)