Skip to content

Commit 913db1a

Browse files
committed
feature(aggregator, signer, common): keep only MithrilStakeDistribution in default allowed discriminants
1 parent 028683b commit 913db1a

File tree

13 files changed

+85
-29
lines changed

13 files changed

+85
-29
lines changed

.github/workflows/backward-compatibility.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
description: "Signed entity types parameters (discriminants names in an ordered comma separated list)"
1818
required: true
1919
type: string
20-
default: "CardanoTransactions,CardanoStakeDistribution,CardanoDatabase"
20+
default: "CardanoTransactions,CardanoStakeDistribution,CardanoDatabase,CardanoImmutableFilesFull"
2121
workflow_call:
2222
inputs:
2323
total-releases:
@@ -28,7 +28,7 @@ on:
2828
default: "10.4.1"
2929
signed-entity-types:
3030
type: string
31-
default: "CardanoTransactions,CardanoStakeDistribution,CardanoDatabase"
31+
default: "CardanoTransactions,CardanoStakeDistribution,CardanoDatabase,CardanoImmutableFilesFull"
3232

3333
jobs:
3434
prepare-env-variables:

docs/website/root/manual/develop/nodes/mithril-aggregator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ Here is a list of the available parameters for the serve command:
527527
| `era_reader_adapter_type` | `--era-reader-adapter-type` | - | `ERA_READER_ADAPTER_TYPE` | Era reader adapter type that can be `cardano-chain`, `file` or `bootstrap`. | `bootstrap` | - | - |
528528
| `era_reader_adapter_params` | `--era-reader-adapter-params` | - | `ERA_READER_ADAPTER_PARAMS` | Era reader adapter params that is an optional JSON encoded parameters structure that is expected depending on the `era_reader_adapter_type` parameter | - | - | - |
529529
| `ancillary_files_signer_config` | - | - | `ANCILLARY_FILES_SIGNER_CONFIG` | Configuration of the ancillary files signer<br/><br/>Can either be a secret key or a key stored in a Google Cloud Platform KMS account.<br/><br/>**IMPORTANT**: The cryptographic scheme used is ED25519 | - | - secret-key:<br/>`{ "type": "secret-key", "secret_key": "136372c3138312c3138382c3130352c3233312c3135" }`<br/>- Gcp kms:<br/>`{ "type": "gcp-kms", "resource_name": "projects/project_name/locations/_location_name/keyRings/key_ring_name/cryptoKeys/key_name/cryptoKeyVersions/key_version" }` | - |
530-
| `signed_entity_types` | `--signed-entity-types` | - | `SIGNED_ENTITY_TYPES` | Signed entity types parameters (discriminants names in an ordered comma separated list) | - | `MithrilStakeDistribution,CardanoImmutableFilesFull,CardanoStakeDistribution` | - |
530+
| `signed_entity_types` | `--signed-entity-types` | - | `SIGNED_ENTITY_TYPES` | Signed entity types parameters (discriminants names in an ordered comma separated list) | - | `MithrilStakeDistribution,CardanoImmutableFilesFull,CardanoStakeDistribution,CardanoDatabase,CardanoTransactions` | - |
531531
| `snapshot_compression_algorithm` | `--snapshot-compression-algorithm` | - | `SNAPSHOT_COMPRESSION_ALGORITHM` | Compression algorithm of the snapshot archive | `zstandard` | `gzip` or `zstandard` | - |
532532
| `zstandard_parameters` | - | - | `ZSTANDARD_PARAMETERS__LEVEL` and `ZSTANDARD_PARAMETERS__NUMBER_OF_WORKERS` | Zstandard specific parameters | - | `{ level: 9, number_of_workers: 4 }` | - |
533533
| `allow_unparsable_block` | `--allow-unparsable-block` | - | `ALLOW_UNPARSABLE_BLOCK` | If set no error is returned in case of unparsable block and an error log is written instead. Will be ignored on (pre)production networks. | `false` | - | - |

mithril-aggregator/src/configuration.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,8 @@ pub struct ServeCommandConfiguration {
495495
/// Signed entity types parameters (discriminants names in an ordered, case-sensitive, comma
496496
/// separated list).
497497
///
498-
/// The values `MithrilStakeDistribution` and `CardanoImmutableFilesFull` are prepended
499-
/// automatically to the list.
500-
#[example = "`MithrilStakeDistribution,CardanoImmutableFilesFull,CardanoStakeDistribution`"]
498+
/// The value `MithrilStakeDistribution` is prepended is automatically to the list.
499+
#[example = "`MithrilStakeDistribution,CardanoImmutableFilesFull,CardanoStakeDistribution,CardanoDatabase,CardanoTransactions`"]
501500
pub signed_entity_types: Option<String>,
502501

503502
/// Compression algorithm used for the snapshot archive artifacts.

mithril-aggregator/src/runtime/runner.rs

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@ pub mod tests {
597597
async fn build_runner(
598598
temp_dir: PathBuf,
599599
mock_certifier_service: MockCertifierService,
600+
) -> AggregatorRunner {
601+
build_runner_with_discriminants(temp_dir, mock_certifier_service, vec![]).await
602+
}
603+
604+
async fn build_runner_with_discriminants(
605+
temp_dir: PathBuf,
606+
mock_certifier_service: MockCertifierService,
607+
allowed_discriminants: Vec<SignedEntityTypeDiscriminants>,
600608
) -> AggregatorRunner {
601609
let mut deps = initialize_dependencies(temp_dir).await;
602610
deps.certifier_service = Arc::new(mock_certifier_service);
@@ -607,6 +615,20 @@ pub mod tests {
607615
.return_once(|_| Ok(ProtocolMessage::default()));
608616
deps.signable_builder_service = Arc::new(mock_signable_builder_service);
609617

618+
// Configure EpochService with allowed_discriminants
619+
if !allowed_discriminants.is_empty() {
620+
let current_epoch = deps.ticker_service.get_current_epoch().await.unwrap();
621+
let epoch_service = FakeEpochServiceBuilder {
622+
signed_entity_config: SignedEntityConfig {
623+
allowed_discriminants: allowed_discriminants.into_iter().collect(),
624+
..SignedEntityConfig::dummy()
625+
},
626+
..FakeEpochServiceBuilder::dummy(current_epoch)
627+
}
628+
.build();
629+
deps.epoch_service = Arc::new(RwLock::new(epoch_service));
630+
}
631+
610632
let runner = build_runner_with_fixture_data(deps).await;
611633

612634
let current_epoch = runner
@@ -1014,7 +1036,15 @@ pub mod tests {
10141036
);
10151037

10161038
mock_certifier_service.expect_create_open_message().never();
1017-
build_runner(temp_dir!(), mock_certifier_service).await
1039+
build_runner_with_discriminants(
1040+
temp_dir!(),
1041+
mock_certifier_service,
1042+
vec![
1043+
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
1044+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
1045+
],
1046+
)
1047+
.await
10181048
};
10191049

10201050
let open_message_returned = runner
@@ -1044,7 +1074,15 @@ pub mod tests {
10441074
.expect_create_open_message()
10451075
.return_once(|_, _| Ok(open_message_created))
10461076
.times(1);
1047-
build_runner(temp_dir!(), mock_certifier_service).await
1077+
build_runner_with_discriminants(
1078+
temp_dir!(),
1079+
mock_certifier_service,
1080+
vec![
1081+
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
1082+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
1083+
],
1084+
)
1085+
.await
10481086
};
10491087

10501088
let open_message_returned = runner
@@ -1069,7 +1107,15 @@ pub mod tests {
10691107
);
10701108

10711109
mock_certifier_service.expect_create_open_message().never();
1072-
build_runner(temp_dir!(), mock_certifier_service).await
1110+
build_runner_with_discriminants(
1111+
temp_dir!(),
1112+
mock_certifier_service,
1113+
vec![
1114+
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
1115+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
1116+
],
1117+
)
1118+
.await
10731119
};
10741120

10751121
let open_message_returned = runner
@@ -1096,7 +1142,15 @@ pub mod tests {
10961142
);
10971143

10981144
mock_certifier_service.expect_create_open_message().never();
1099-
build_runner(temp_dir!(), mock_certifier_service).await
1145+
build_runner_with_discriminants(
1146+
temp_dir!(),
1147+
mock_certifier_service,
1148+
vec![
1149+
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
1150+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
1151+
],
1152+
)
1153+
.await
11001154
};
11011155

11021156
let open_message_returned = runner
@@ -1108,8 +1162,7 @@ pub mod tests {
11081162
}
11091163

11101164
#[tokio::test]
1111-
async fn test_get_current_non_certified_open_message_called_for_mithril_stake_distribution_and_then_for_immutable_file(
1112-
) {
1165+
async fn test_get_current_non_certified_open_message_called_for_mithril_stake_distribution() {
11131166
let mut mock_certifier_service = MockCertifierService::new();
11141167

11151168
let mut seq = Sequence::new();
@@ -1122,15 +1175,6 @@ pub mod tests {
11221175
.in_sequence(&mut seq)
11231176
.return_once(|_| Ok(Some(create_open_message(IsCertified::Yes, IsExpired::No))));
11241177

1125-
mock_certifier_service
1126-
.expect_get_open_message()
1127-
.with(eq(SignedEntityType::CardanoImmutableFilesFull(
1128-
fake_data::beacon(),
1129-
)))
1130-
.times(1)
1131-
.in_sequence(&mut seq)
1132-
.return_once(|_| Ok(Some(create_open_message(IsCertified::Yes, IsExpired::No))));
1133-
11341178
mock_certifier_service.expect_create_open_message().never();
11351179

11361180
mock_certifier_service

mithril-aggregator/tests/certificate_chain.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ async fn certificate_chain() {
2424
let configuration = ServeCommandConfiguration {
2525
protocol_parameters: protocol_parameters.clone(),
2626
data_stores_directory: get_test_dir("certificate_chain"),
27+
signed_entity_types: Some(
28+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull.to_string(),
29+
),
2730
..ServeCommandConfiguration::new_sample(temp_dir!())
2831
};
2932
let mut tester = RuntimeTester::build(

mithril-aggregator/tests/create_certificate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ async fn create_certificate() {
2525
protocol_parameters: protocol_parameters.clone(),
2626
signed_entity_types: Some(
2727
[
28+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull.to_string(),
2829
SignedEntityTypeDiscriminants::CardanoTransactions.to_string(),
2930
SignedEntityTypeDiscriminants::CardanoDatabase.to_string(),
3031
]

mithril-aggregator/tests/create_certificate_follower.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ async fn create_certificate_follower() {
104104
security_parameter: BlockNumber(0),
105105
step: BlockNumber(30),
106106
},
107+
signed_entity_types: Some(
108+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull.to_string(),
109+
),
107110
..ServeCommandConfiguration::new_sample(temp_dir!())
108111
};
109112
let mut leader_tester =

mithril-aggregator/tests/open_message_expiration.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ async fn open_message_expiration() {
2525
let configuration = ServeCommandConfiguration {
2626
protocol_parameters: protocol_parameters.clone(),
2727
data_stores_directory: get_test_dir("open_message_expiration"),
28+
signed_entity_types: Some(
29+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull.to_string(),
30+
),
2831
..ServeCommandConfiguration::new_sample(temp_dir!())
2932
};
3033
let mut tester = RuntimeTester::build(

mithril-aggregator/tests/open_message_newer_exists.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ async fn open_message_newer_exists() {
2323
let configuration = ServeCommandConfiguration {
2424
protocol_parameters: protocol_parameters.clone(),
2525
data_stores_directory: get_test_dir("open_message_newer_exists"),
26+
signed_entity_types: Some(
27+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull.to_string(),
28+
),
2629
..ServeCommandConfiguration::new_sample(temp_dir!())
2730
};
2831
let mut tester = RuntimeTester::build(

mithril-common/src/entities/signed_entity_config.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ impl SignedEntityConfig {
3232
/// Default allowed discriminants
3333
///
3434
/// Appended to the allowed discriminants in the configuration.
35-
pub const DEFAULT_ALLOWED_DISCRIMINANTS: [SignedEntityTypeDiscriminants; 2] = [
36-
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
37-
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
38-
];
35+
pub const DEFAULT_ALLOWED_DISCRIMINANTS: [SignedEntityTypeDiscriminants; 1] =
36+
[SignedEntityTypeDiscriminants::MithrilStakeDistribution];
3937

4038
/// Append to the given list of allowed signed entity types discriminants the [Self::DEFAULT_ALLOWED_DISCRIMINANTS]
4139
/// if not already present.
@@ -466,7 +464,6 @@ mod tests {
466464
vec![
467465
SignedEntityType::MithrilStakeDistribution(beacon.epoch),
468466
SignedEntityType::CardanoStakeDistribution(beacon.epoch - 1),
469-
SignedEntityType::CardanoImmutableFilesFull(beacon.clone()),
470467
SignedEntityType::CardanoTransactions(beacon.epoch, chain_point.block_number - 1),
471468
],
472469
signed_entity_types

0 commit comments

Comments
 (0)