Skip to content

Commit c93b35b

Browse files
committed
feat(aggregator): make epoch service allowed discriminants an intersection between local configuration and network configuration
For leader aggregator this does not change anything right now since both value come from the aggregator configuration. For follower this allow them to use a subset of the signed entity types allowed in their leader.
1 parent 36e7a40 commit c93b35b

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

mithril-aggregator/src/services/epoch_service.rs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,15 @@ impl EpochService for MithrilEpochService {
353353
let total_next_stakes_signers = next_signers_with_stake.iter().map(|s| s.stake).sum();
354354

355355
let signed_entity_config = SignedEntityConfig {
356-
allowed_discriminants: self.allowed_signed_entity_discriminants.clone(),
356+
allowed_discriminants: self
357+
.allowed_signed_entity_discriminants
358+
.intersection(
359+
&network_configuration
360+
.configuration_for_aggregation
361+
.enabled_signed_entity_types,
362+
)
363+
.cloned()
364+
.collect(),
357365
cardano_transactions_signing_config: current_epoch_settings
358366
.cardano_transactions_signing_config
359367
.clone(),
@@ -1134,6 +1142,58 @@ mod tests {
11341142
);
11351143
}
11361144

1145+
#[tokio::test]
1146+
async fn inform_epoch_compute_allowed_discriminants_from_intersection_of_aggregation_network_config_and_configured_discriminants()
1147+
{
1148+
let epoch = Epoch(5);
1149+
let allowed_discriminants = BTreeSet::from([
1150+
SignedEntityTypeDiscriminants::CardanoStakeDistribution,
1151+
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
1152+
SignedEntityTypeDiscriminants::CardanoTransactions,
1153+
]);
1154+
let enabled_discriminants = BTreeSet::from([
1155+
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
1156+
SignedEntityTypeDiscriminants::CardanoStakeDistribution,
1157+
SignedEntityTypeDiscriminants::CardanoTransactions,
1158+
]);
1159+
1160+
let mut service = MithrilEpochService {
1161+
mithril_network_configuration_provider: Arc::new(
1162+
FakeMithrilNetworkConfigurationProvider::new(
1163+
MithrilNetworkConfigurationForEpoch {
1164+
enabled_signed_entity_types: enabled_discriminants,
1165+
..Dummy::dummy()
1166+
},
1167+
MithrilNetworkConfigurationForEpoch::dummy(),
1168+
MithrilNetworkConfigurationForEpoch::dummy(),
1169+
),
1170+
),
1171+
..EpochServiceBuilder {
1172+
allowed_discriminants: allowed_discriminants.clone(),
1173+
..EpochServiceBuilder::new(epoch, MithrilFixtureBuilder::default().build())
1174+
}
1175+
.build()
1176+
.await
1177+
};
1178+
1179+
service
1180+
.inform_epoch(epoch)
1181+
.await
1182+
.expect("inform_epoch should not fail");
1183+
1184+
let signed_entity_config = service
1185+
.signed_entity_config()
1186+
.expect("extracting data from service should not fail");
1187+
1188+
assert_eq!(
1189+
BTreeSet::from([
1190+
SignedEntityTypeDiscriminants::CardanoTransactions,
1191+
SignedEntityTypeDiscriminants::CardanoStakeDistribution,
1192+
]),
1193+
signed_entity_config.allowed_discriminants
1194+
);
1195+
}
1196+
11371197
#[tokio::test]
11381198
async fn compute_data_with_data_from_inform_epoch() {
11391199
let current_epoch_fixture = MithrilFixtureBuilder::default().with_signers(3).build();

0 commit comments

Comments
 (0)