Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/mithril-persistence/src/database/hydrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Hydrator {
column_index: U,
) -> String {
// We need to check first that the cell can be read as a string first
// (e.g. when beacon json is '{"network": "dev", "epoch": 1, "immutable_file_number": 2}').
// (e.g. when beacon json is '{"epoch": 1, "immutable_file_number": 2}').
// If it fails, we fallback on reading the cell as an integer (e.g. when beacon json is '5').
// TODO: Maybe there is a better way of doing this.
match row.try_read::<&str, _>(column_index.clone()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ mod tests {
#[tokio::test]
async fn snapshot_archive_name_after_beacon_values() {
let network = fake_data::network();
let beacon = CardanoDbBeacon::new("network".to_string(), 20, 145);
let beacon = CardanoDbBeacon::new(20, 145);
let digest = "test+digest";

let cardano_immutable_files_full_artifact_builder =
Expand Down
1 change: 0 additions & 1 deletion mithril-aggregator/src/database/record/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ impl CertificateRecord {
parent_id,
epoch,
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
fake_data::network(),
*epoch,
immutable_file_number,
)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mod tests {

for signed_entity_type in [
SignedEntityType::MithrilStakeDistribution(epoch),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new("devnet", *epoch, 1)),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(*epoch, 1)),
SignedEntityType::CardanoTransactions(epoch, BlockNumber(100)),
] {
repository
Expand Down
2 changes: 0 additions & 2 deletions mithril-aggregator/src/dependency_injection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,6 @@ impl DependenciesBuilder {
let era_checker = self.get_era_checker().await?;
let stake_distribution_service = self.get_stake_distribution_service().await?;
let epoch_settings = self.get_epoch_settings_configuration()?;
let network = self.configuration.get_network()?;
let allowed_discriminants = self.get_allowed_signed_entity_types_discriminants()?;

let epoch_service = Arc::new(RwLock::new(MithrilEpochService::new(
Expand All @@ -1272,7 +1271,6 @@ impl DependenciesBuilder {
era_checker,
stake_distribution_service,
),
network,
allowed_discriminants,
self.root_logger(),
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ mod tests {
let signed_entity = create_signed_entity(
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::default()),
Snapshot {
beacon: CardanoDbBeacon::new(network, 1, 10),
beacon: CardanoDbBeacon::new(1, 10),
..fake_data::snapshots(1)[0].clone()
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod tests {
#[test]
fn adapt_on_other_than_cardano_immutable_files_full_signed_entity_type_ok() {
let mut certificate_pending = fake_data::certificate_pending();
let beacon = CardanoDbBeacon::new("", 0, 0);
let beacon = CardanoDbBeacon::new(0, 0);
certificate_pending.signed_entity_type =
SignedEntityType::MithrilStakeDistribution(Epoch(15));

Expand Down
24 changes: 12 additions & 12 deletions mithril-aggregator/src/services/certifier/certifier_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ mod tests {

#[tokio::test]
async fn should_clean_epoch_when_inform_epoch() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 1, 1);
let beacon = CardanoDbBeacon::new(1, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epoch = beacon.epoch;
Expand All @@ -491,7 +491,7 @@ mod tests {

#[tokio::test]
async fn should_mark_open_message_expired_when_exists() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
Expand Down Expand Up @@ -523,7 +523,7 @@ mod tests {

#[tokio::test]
async fn should_not_mark_open_message_expired_when_does_not_expire() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
Expand All @@ -550,7 +550,7 @@ mod tests {

#[tokio::test]
async fn should_not_mark_open_message_expired_when_has_not_expired_yet() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
Expand All @@ -577,7 +577,7 @@ mod tests {

#[tokio::test]
async fn should_register_valid_single_signature() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=3).map(Epoch).collect::<Vec<_>>();
Expand Down Expand Up @@ -610,7 +610,7 @@ mod tests {

#[tokio::test]
async fn should_not_register_invalid_single_signature() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let mut protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
Expand Down Expand Up @@ -650,7 +650,7 @@ mod tests {

#[tokio::test]
async fn should_not_register_single_signature_for_certified_open_message() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
Expand Down Expand Up @@ -682,7 +682,7 @@ mod tests {

#[tokio::test]
async fn should_not_register_single_signature_for_expired_open_message() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
Expand Down Expand Up @@ -715,7 +715,7 @@ mod tests {
#[tokio::test]
async fn should_create_certificate_when_multi_signature_produced() {
let network = fake_data::network();
let beacon = CardanoDbBeacon::new(network, 3, 1);
let beacon = CardanoDbBeacon::new(3, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=3).map(Epoch).collect::<Vec<_>>();
Expand Down Expand Up @@ -789,7 +789,7 @@ mod tests {

#[tokio::test]
async fn should_not_create_certificate_for_open_message_not_created() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 1, 1);
let beacon = CardanoDbBeacon::new(1, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
let fixture = MithrilFixtureBuilder::default().with_signers(5).build();
Expand All @@ -802,7 +802,7 @@ mod tests {

#[tokio::test]
async fn should_not_create_certificate_for_open_message_already_certified() {
let beacon = CardanoDbBeacon::new("devnet".to_string(), 1, 1);
let beacon = CardanoDbBeacon::new(1, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epoch = beacon.epoch;
Expand All @@ -826,7 +826,7 @@ mod tests {
mock_multi_signer
.expect_create_multi_signature()
.return_once(move |_| Ok(None));
let beacon = CardanoDbBeacon::new("devnet".to_string(), 1, 1);
let beacon = CardanoDbBeacon::new(1, 1);
let signed_entity_type = SignedEntityType::CardanoImmutableFilesFull(beacon.clone());
let protocol_message = ProtocolMessage::new();
let epochs_with_signers = (1..=5).map(Epoch).collect::<Vec<_>>();
Expand Down
13 changes: 1 addition & 12 deletions mithril-aggregator/src/services/epoch_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use mithril_common::entities::{
};
use mithril_common::logging::LoggerExtensions;
use mithril_common::protocol::{MultiSigner as ProtocolMultiSigner, SignerBuilder};
use mithril_common::{CardanoNetwork, StdResult};
use mithril_common::StdResult;

use crate::{
entities::AggregatorEpochSettings, services::StakeDistributionService, EpochSettingsStorer,
Expand Down Expand Up @@ -188,7 +188,6 @@ pub struct MithrilEpochService {
chain_observer: Arc<dyn ChainObserver>,
era_checker: Arc<EraChecker>,
stake_distribution_service: Arc<dyn StakeDistributionService>,
network: CardanoNetwork,
allowed_signed_entity_discriminants: BTreeSet<SignedEntityTypeDiscriminants>,
logger: Logger,
}
Expand All @@ -198,7 +197,6 @@ impl MithrilEpochService {
pub fn new(
future_epoch_settings: AggregatorEpochSettings,
dependencies: EpochServiceDependencies,
network: CardanoNetwork,
allowed_discriminants: BTreeSet<SignedEntityTypeDiscriminants>,
logger: Logger,
) -> Self {
Expand All @@ -211,7 +209,6 @@ impl MithrilEpochService {
chain_observer: dependencies.chain_observer,
era_checker: dependencies.era_checker,
stake_distribution_service: dependencies.stake_distribution_service,
network,
allowed_signed_entity_discriminants: allowed_discriminants,
logger: logger.new_with_component_name::<Self>(),
}
Expand Down Expand Up @@ -346,7 +343,6 @@ impl EpochService for MithrilEpochService {

let signed_entity_config = SignedEntityConfig {
allowed_discriminants: self.allowed_signed_entity_discriminants.clone(),
network: self.network,
cardano_transactions_signing_config: current_epoch_settings
.cardano_transactions_signing_config
.clone(),
Expand Down Expand Up @@ -932,7 +928,6 @@ mod tests {
struct EpochServiceBuilder {
cardano_transactions_signing_config: CardanoTransactionsSigningConfig,
future_protocol_parameters: ProtocolParameters,
network: CardanoNetwork,
allowed_discriminants: BTreeSet<SignedEntityTypeDiscriminants>,
cardano_era: CardanoEra,
mithril_era: SupportedEra,
Expand All @@ -951,7 +946,6 @@ mod tests {
Self {
cardano_transactions_signing_config: CardanoTransactionsSigningConfig::dummy(),
future_protocol_parameters: epoch_fixture.protocol_parameters(),
network: CardanoNetwork::TestNet(0),
allowed_discriminants: BTreeSet::new(),
cardano_era: String::new(),
mithril_era: SupportedEra::dummy(),
Expand Down Expand Up @@ -1041,7 +1035,6 @@ mod tests {
Arc::new(era_checker),
Arc::new(stake_distribution_service),
),
self.network,
self.allowed_discriminants,
TestLogger::stdout(),
)
Expand All @@ -1068,7 +1061,6 @@ mod tests {
protocol_parameters: signer_registration_protocol_parameters.clone(),
..AggregatorEpochSettings::dummy()
},
network: SignedEntityConfig::dummy().network,
allowed_discriminants: SignedEntityConfig::dummy().allowed_discriminants,
cardano_era: "CardanoEra".to_string(),
mithril_era: SupportedEra::eras()[1],
Expand Down Expand Up @@ -1122,14 +1114,12 @@ mod tests {

let cardano_transactions_signing_config =
CardanoTransactionsSigningConfig::new(BlockNumber(29), BlockNumber(986));
let network = CardanoNetwork::TestNet(27);
let allowed_discriminants = BTreeSet::from([
SignedEntityTypeDiscriminants::CardanoTransactions,
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
]);

let mut service = EpochServiceBuilder {
network,
allowed_discriminants: allowed_discriminants.clone(),
stored_current_epoch_settings: AggregatorEpochSettings {
cardano_transactions_signing_config: cardano_transactions_signing_config.clone(),
Expand All @@ -1153,7 +1143,6 @@ mod tests {
signed_entity_config.clone(),
SignedEntityConfig {
allowed_discriminants,
network,
cardano_transactions_signing_config,
}
);
Expand Down
18 changes: 3 additions & 15 deletions mithril-aggregator/tests/certificate_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ async fn certificate_chain() {
Epoch(1),
StakeDistributionParty::from_signers(initial_fixture.signers_with_stake()).as_slice(),
initial_fixture.compute_and_encode_avk(),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
"devnet".to_string(),
1,
3
)),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(1, 3)),
ExpectedCertificate::genesis_identifier(Epoch(1)),
)
);
Expand All @@ -135,11 +131,7 @@ async fn certificate_chain() {
Epoch(1),
StakeDistributionParty::from_signers(initial_fixture.signers_with_stake()).as_slice(),
initial_fixture.compute_and_encode_avk(),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
"devnet".to_string(),
1,
4
)),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(1, 4)),
ExpectedCertificate::genesis_identifier(Epoch(1)),
)
);
Expand Down Expand Up @@ -296,11 +288,7 @@ async fn certificate_chain() {
Epoch(4),
StakeDistributionParty::from_signers(next_fixture.signers_with_stake()).as_slice(),
next_fixture.compute_and_encode_avk(),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
"devnet".to_string(),
4,
7
)),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(4, 7)),
ExpectedCertificate::identifier(&SignedEntityType::MithrilStakeDistribution(Epoch(4))),
)
);
Expand Down
6 changes: 1 addition & 5 deletions mithril-aggregator/tests/create_certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ async fn create_certificate() {
.map(|s| s.signer_with_stake.clone().into())
.collect::<Vec<_>>(),
fixture.compute_and_encode_avk(),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
"devnet".to_string(),
1,
3
)),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(1, 3)),
ExpectedCertificate::genesis_identifier(Epoch(1)),
)
);
Expand Down
6 changes: 1 addition & 5 deletions mithril-aggregator/tests/open_message_expiration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ async fn open_message_expiration() {
.map(|s| s.signer_with_stake.clone().into())
.collect::<Vec<_>>(),
fixture.compute_and_encode_avk(),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
"devnet".to_string(),
1,
3
)),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(1, 3)),
ExpectedCertificate::genesis_identifier(Epoch(1)),
)
);
Expand Down
6 changes: 1 addition & 5 deletions mithril-aggregator/tests/open_message_newer_exists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ async fn open_message_newer_exists() {
.map(|s| s.signer_with_stake.clone().into())
.collect::<Vec<_>>(),
fixture.compute_and_encode_avk(),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
"devnet".to_string(),
1,
4
)),
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(1, 4)),
ExpectedCertificate::genesis_identifier(Epoch(1)),
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ use mithril_aggregator::{
use mithril_common::entities::{CardanoTransactionsSnapshot, Certificate, SignedEntity};
use mithril_common::{
entities::{Epoch, SignedEntityType, SignedEntityTypeDiscriminants, TimePoint},
CardanoNetwork, StdResult, TickerService,
StdResult, TickerService,
};
use std::sync::Arc;

// An observer that allow to inspect currently available open messages.
pub struct AggregatorObserver {
network: CardanoNetwork,
certifier_service: Arc<dyn CertifierService>,
signed_entity_service: Arc<dyn SignedEntityService>,
ticker_service: Arc<dyn TickerService>,
Expand All @@ -24,7 +23,6 @@ impl AggregatorObserver {
// [AggregatorObserver] factory
pub async fn new(deps_builder: &mut DependenciesBuilder) -> Self {
Self {
network: deps_builder.configuration.get_network().unwrap(),
certifier_service: deps_builder.get_certifier_service().await.unwrap(),
signed_entity_service: deps_builder.get_signed_entity_service().await.unwrap(),
ticker_service: deps_builder.get_ticker_service().await.unwrap(),
Expand Down
2 changes: 1 addition & 1 deletion mithril-client-cli/src/commands/cardano_db/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ mod tests {
ProtocolMessagePartKey::NextAggregateVerificationKey,
"whatever".to_string(),
);
let beacon = CardanoDbBeacon::new("testnet".to_string(), 10, 100);
let beacon = CardanoDbBeacon::new(10, 100);

MithrilCertificate {
hash: "hash".to_string(),
Expand Down
5 changes: 1 addition & 4 deletions mithril-common/benches/digester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ async fn compute_digest(
let digester =
CardanoImmutableDigester::new("devnet".to_string(), cache_provider, create_logger());
digester
.compute_digest(
&db_dir(),
&CardanoDbBeacon::new("devnet".to_string(), 1, number_of_immutables),
)
.compute_digest(&db_dir(), &CardanoDbBeacon::new(1, number_of_immutables))
.await
.expect("digest computation should not fail");
}
Expand Down
Loading
Loading