diff --git a/mithril-aggregator/src/database/provider/open_message.rs b/mithril-aggregator/src/database/provider/open_message.rs index 07f567c851f..64d335095c2 100644 --- a/mithril-aggregator/src/database/provider/open_message.rs +++ b/mithril-aggregator/src/database/provider/open_message.rs @@ -439,7 +439,7 @@ impl SqLiteEntity for OpenMessageWithSingleSignatures { ("protocol_message", "{:open_message:}.protocol_message", "text"), ("is_certified", "{:open_message:}.is_certified", "bool"), ("created_at", "{:open_message:}.created_at", "text"), - ("single_signatures", "json_group_array(json_object('signer_id', {:single_signature:}.signer_id, 'signature', {:single_signature:}.signature, 'won_indexes', {:single_signature:}.lottery_indexes))", "text") + ("single_signatures", "case when {:single_signature:}.signer_id is null then '[]' else json_group_array(json_object('signer_id', {:single_signature:}.signer_id, 'signature', {:single_signature:}.signature, 'won_indexes', {:single_signature:}.lottery_indexes)) end", "text") ]) } } @@ -509,7 +509,7 @@ mod tests { ]); assert_eq!( - "open_message.open_message_id as open_message_id, open_message.epoch_setting_id as epoch_setting_id, open_message.beacon as beacon, open_message.signed_entity_type_id as signed_entity_type_id, open_message.protocol_message as protocol_message, open_message.is_certified as is_certified, open_message.created_at as created_at, json_group_array(json_object('signer_id', single_signature.signer_id, 'signature', single_signature.signature, 'won_indexes', single_signature.lottery_indexes)) as single_signatures".to_string(), + "open_message.open_message_id as open_message_id, open_message.epoch_setting_id as epoch_setting_id, open_message.beacon as beacon, open_message.signed_entity_type_id as signed_entity_type_id, open_message.protocol_message as protocol_message, open_message.is_certified as is_certified, open_message.created_at as created_at, case when single_signature.signer_id is null then '[]' else json_group_array(json_object('signer_id', single_signature.signer_id, 'signature', single_signature.signature, 'won_indexes', single_signature.lottery_indexes)) end as single_signatures".to_string(), projection.expand(aliases) ) } diff --git a/mithril-aggregator/src/dependency.rs b/mithril-aggregator/src/dependency.rs index 0d35e43e4d3..dca4bbf42fa 100644 --- a/mithril-aggregator/src/dependency.rs +++ b/mithril-aggregator/src/dependency.rs @@ -194,12 +194,12 @@ impl DependencyManager { } for (epoch, params) in parameters_per_epoch { - self.fill_verification_key_store(epoch, ¶ms.0).await; - self.fill_stakes_store(epoch, params.0.to_vec()).await; self.protocol_parameters_store .save_protocol_parameters(epoch, params.1) .await .expect("save_protocol_parameters should not fail"); + self.fill_verification_key_store(epoch, ¶ms.0).await; + self.fill_stakes_store(epoch, params.0.to_vec()).await; } for certificate in certificate_chain { @@ -237,6 +237,9 @@ impl DependencyManager { second_epoch_signers: Vec, genesis_protocol_parameters: &ProtocolParameters, ) { + self.init_protocol_parameter_store(genesis_protocol_parameters) + .await; + let (work_epoch, epoch_to_sign) = self.get_genesis_epochs().await; for (epoch, signers) in [ (work_epoch, genesis_signers), @@ -245,9 +248,6 @@ impl DependencyManager { self.fill_verification_key_store(epoch, &signers).await; self.fill_stakes_store(epoch, signers).await; } - - self.init_protocol_parameter_store(genesis_protocol_parameters) - .await; } /// `TEST METHOD ONLY` @@ -269,6 +269,10 @@ impl DependencyManager { async fn fill_verification_key_store(&self, target_epoch: Epoch, signers: &[SignerWithStake]) { for signer in signers { + self.signer_recorder + .record_signer_id(signer.party_id.clone()) + .await + .expect("record_signer_id should not fail"); self.verification_key_store .save_verification_key(target_epoch, signer.clone()) .await diff --git a/mithril-aggregator/src/runtime/runner.rs b/mithril-aggregator/src/runtime/runner.rs index 9b6bcf5c50a..94ea4049338 100644 --- a/mithril-aggregator/src/runtime/runner.rs +++ b/mithril-aggregator/src/runtime/runner.rs @@ -713,12 +713,10 @@ pub mod tests { }; use crate::{MithrilSignerRegisterer, ProtocolParametersStorer, SignerRegistrationRound}; use mithril_common::chain_observer::FakeObserver; - use mithril_common::crypto_helper::{ - tests_setup::setup_certificate_chain, }; + use mithril_common::crypto_helper::tests_setup::setup_certificate_chain; use mithril_common::digesters::DumbImmutableFileObserver; use mithril_common::entities::{ - Beacon, CertificatePending, ProtocolMessage, SignedEntityType, - StakeDistribution, + Beacon, CertificatePending, ProtocolMessage, SignedEntityType, StakeDistribution, }; use mithril_common::store::StakeStorer; use mithril_common::test_utils::MithrilFixtureBuilder; @@ -757,7 +755,7 @@ pub mod tests { let runner = AggregatorRunner::new(config, Arc::new(dependencies)); let beacon = fake_data::beacon(); - let mut certificate = fake_data::certificate("certificate_hash".to_string()); + let mut certificate = fake_data::genesis_certificate("certificate_hash".to_string()); certificate.beacon = beacon.clone(); assert!(!runner diff --git a/mithril-aggregator/tests/test_extensions/runtime_tester.rs b/mithril-aggregator/tests/test_extensions/runtime_tester.rs index be63a9b4d27..c0ba499edb0 100644 --- a/mithril-aggregator/tests/test_extensions/runtime_tester.rs +++ b/mithril-aggregator/tests/test_extensions/runtime_tester.rs @@ -148,6 +148,13 @@ impl RuntimeTester { .get_current_beacon() .await .map_err(|e| format!("Querying the current beacon should not fail: {e:?}"))?; + self.deps_builder + .get_certifier_service() + .await + .unwrap() + .inform_epoch(beacon.epoch) + .await + .expect("inform_epoch should not fail"); let protocol_parameters = self .deps_builder .get_protocol_parameters_store() @@ -221,6 +228,13 @@ impl RuntimeTester { .await .ok_or("a new epoch should have been issued")?; self.update_digester_digest().await?; + self.deps_builder + .get_certifier_service() + .await + .unwrap() + .inform_epoch(new_epoch) + .await + .expect("inform_epoch should not fail"); Ok(new_epoch) }