Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/mithril-dmq/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mithril-dmq"
description = "Mechanisms to publish and consume messages of a 'Decentralized Message Queue network' through a DMQ node"
version = "0.1.6"
version = "0.1.7"
authors.workspace = true
documentation.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-dmq/src/consumer/pallas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<M: TryFromBytes + Debug> DmqConsumerPallas<M> {
}

/// Gets the cached `DmqClient`, creating a new one if it does not exist.
async fn get_client(&self) -> StdResult<MutexGuard<Option<DmqClient>>> {
async fn get_client(&self) -> StdResult<MutexGuard<'_, Option<DmqClient>>> {
{
// Run this in a separate block to avoid dead lock on the Mutex
let client_lock = self.client.lock().await;
Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-persistence/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-persistence"
version = "0.2.57"
version = "0.2.58"
description = "Common types, interfaces, and utilities to persist data for Mithril nodes."
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ mod tests {
.read::<i64, _>(0)
}

fn create_db_checker(connection: &ConnectionThreadSafe) -> DatabaseVersionChecker {
fn create_db_checker(connection: &ConnectionThreadSafe) -> DatabaseVersionChecker<'_> {
DatabaseVersionChecker::new(
discard_logger(),
ApplicationNodeType::Aggregator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::sqlite::{EntityCursor, Query, SqliteConnection, Transaction};
/// Extension trait for the [SqliteConnection] type.
pub trait ConnectionExtensions {
/// Begin a transaction on the connection.
fn begin_transaction(&self) -> StdResult<Transaction>;
fn begin_transaction(&self) -> StdResult<Transaction<'_>>;

/// Execute the given sql query and return the value of the first cell read.
fn query_single_cell<Q: AsRef<str>, T: ReadableWithIndex>(
Expand All @@ -18,7 +18,7 @@ pub trait ConnectionExtensions {
) -> StdResult<T>;

/// Fetch entities from the database using the given query.
fn fetch<Q: Query>(&self, query: Q) -> StdResult<EntityCursor<Q::Entity>>;
fn fetch<Q: Query>(&self, query: Q) -> StdResult<EntityCursor<'_, Q::Entity>>;

/// Fetch the first entity from the database returned using the given query.
fn fetch_first<Q: Query>(&self, query: Q) -> StdResult<Option<Q::Entity>> {
Expand All @@ -39,7 +39,7 @@ pub trait ConnectionExtensions {
}

impl ConnectionExtensions for SqliteConnection {
fn begin_transaction(&self) -> StdResult<Transaction> {
fn begin_transaction(&self) -> StdResult<Transaction<'_>> {
Ok(Transaction::begin(self)?)
}

Expand All @@ -54,7 +54,7 @@ impl ConnectionExtensions for SqliteConnection {
statement.read::<T, _>(0).with_context(|| "Read query error")
}

fn fetch<Q: Query>(&self, query: Q) -> StdResult<EntityCursor<Q::Entity>> {
fn fetch<Q: Query>(&self, query: Q) -> StdResult<EntityCursor<'_, Q::Entity>> {
let (condition, params) = query.filters().expand();
let sql = query.get_definition(&condition);
let cursor = prepare_statement(self, &sql)?.into_iter().bind(&params[..])?;
Expand Down
2 changes: 1 addition & 1 deletion internal/mithril-persistence/src/sqlite/connection_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl SqliteConnectionPool {
}

/// Get a connection from the pool
pub fn connection(&self) -> StdResult<ResourcePoolItem<SqlitePooledConnection>> {
pub fn connection(&self) -> StdResult<ResourcePoolItem<'_, SqlitePooledConnection>> {
let timeout = Duration::from_millis(1000);
let connection = self.connection_pool.acquire_resource(timeout)?;

Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.7.78"
version = "0.7.79"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ impl DependenciesBuilder {
let _ = connection.execute("pragma analysis_limit=400; pragma optimize;");
}

if let Some(pool) = &self.sqlite_connection_cardano_transaction_pool {
if let Ok(connection) = pool.connection() {
let _ = connection.execute("pragma analysis_limit=400; pragma optimize;");
}
if let Some(pool) = &self.sqlite_connection_cardano_transaction_pool
&& let Ok(connection) = pool.connection()
{
let _ = connection.execute("pragma analysis_limit=400; pragma optimize;");
}
}

Expand Down
9 changes: 4 additions & 5 deletions mithril-aggregator/src/file_uploaders/cloud_uploader/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ impl CloudUploader {
impl FileUploader for CloudUploader {
async fn upload_without_retry(&self, file_path: &Path) -> StdResult<FileUri> {
let remote_file_path = self.remote_folder.join(get_file_name(file_path)?);
if !self.allow_overwrite {
if let Some(file_uri) = self
if !self.allow_overwrite
&& let Some(file_uri) = self
.cloud_backend_uploader
.file_exists(&remote_file_path)
.await
.with_context(|| "checking if file exists in cloud")?
{
return Ok(file_uri);
}
{
return Ok(file_uri);
}

let file_uri = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mod tests {
for invalid_char in ["g", "x", ";", " ", "à"].iter() {
let hash = format!("{}{}", "a".repeat(63), invalid_char);
let error = ProverTransactionsHashValidator::default()
.validate(&[hash.clone()])
.validate(std::slice::from_ref(&hash))
.expect_err("Should return an error");
assert_eq!(
error,
Expand Down
35 changes: 0 additions & 35 deletions mithril-aggregator/src/services/aggregator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,41 +379,6 @@ impl RemoteCertificateRetriever for AggregatorHTTPClient {
}
}

#[cfg(test)]
pub(crate) mod dumb {
use tokio::sync::RwLock;

use mithril_common::test::double::Dummy;

use super::*;

/// This aggregator client is intended to be used by test services.
/// It actually does not communicate with an aggregator host but mimics this behavior.
/// It is driven by a Tester that controls the data it can return, and it can return its internal state for testing.
pub struct DumbAggregatorClient {
epoch_settings: RwLock<Option<LeaderAggregatorEpochSettings>>,
}

impl Default for DumbAggregatorClient {
fn default() -> Self {
Self {
epoch_settings: RwLock::new(Some(LeaderAggregatorEpochSettings::dummy())),
}
}
}

#[async_trait]
impl LeaderAggregatorClient for DumbAggregatorClient {
async fn retrieve_epoch_settings(
&self,
) -> StdResult<Option<LeaderAggregatorEpochSettings>> {
let epoch_settings = self.epoch_settings.read().await.clone();

Ok(epoch_settings)
}
}
}

#[cfg(test)]
mod tests {
use http::response::Builder as HttpResponseBuilder;
Expand Down
15 changes: 7 additions & 8 deletions mithril-aggregator/src/services/certifier/buffered_certifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,15 @@ impl CertifierService for BufferedCertifierService {
.create_open_message(signed_entity_type, protocol_message)
.await;

if creation_result.is_ok() {
if let Err(error) = self
if creation_result.is_ok()
&& let Err(error) = self
.try_register_buffered_signatures_to_current_open_message(signed_entity_type)
.await
{
warn!(self.logger, "Failed to register buffered signatures to the new open message";
"signed_entity_type" => ?signed_entity_type,
"error" => ?error
);
}
{
warn!(self.logger, "Failed to register buffered signatures to the new open message";
"signed_entity_type" => ?signed_entity_type,
"error" => ?error
);
}

creation_result
Expand Down
14 changes: 7 additions & 7 deletions mithril-aggregator/src/services/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ mod tests {
async fn get_certificate() {
let genesis_certificate = fake_data::genesis_certificate("genesis_hash");
let service = MessageServiceBuilder::new()
.with_certificates(&[genesis_certificate.clone()])
.with_certificates(std::slice::from_ref(&genesis_certificate))
.build()
.await;

Expand Down Expand Up @@ -705,7 +705,7 @@ mod tests {
let message: SnapshotMessage = record.clone().try_into().unwrap();

let service = MessageServiceBuilder::new()
.with_signed_entity_records(&[record.clone()])
.with_signed_entity_records(std::slice::from_ref(&record))
.build()
.await;

Expand Down Expand Up @@ -778,7 +778,7 @@ mod tests {
let message: CardanoDatabaseSnapshotMessage = record.clone().try_into().unwrap();

let service = MessageServiceBuilder::new()
.with_signed_entity_records(&[record.clone()])
.with_signed_entity_records(std::slice::from_ref(&record))
.build()
.await;

Expand Down Expand Up @@ -869,7 +869,7 @@ mod tests {
let message: MithrilStakeDistributionMessage = record.clone().try_into().unwrap();

let service = MessageServiceBuilder::new()
.with_signed_entity_records(&[record.clone()])
.with_signed_entity_records(std::slice::from_ref(&record))
.build()
.await;

Expand Down Expand Up @@ -949,7 +949,7 @@ mod tests {
let message: CardanoTransactionSnapshotMessage = record.clone().try_into().unwrap();

let service = MessageServiceBuilder::new()
.with_signed_entity_records(&[record.clone()])
.with_signed_entity_records(std::slice::from_ref(&record))
.build()
.await;

Expand Down Expand Up @@ -1028,7 +1028,7 @@ mod tests {
let message: CardanoStakeDistributionMessage = record.clone().try_into().unwrap();

let service = MessageServiceBuilder::new()
.with_signed_entity_records(&[record.clone()])
.with_signed_entity_records(std::slice::from_ref(&record))
.build()
.await;

Expand Down Expand Up @@ -1066,7 +1066,7 @@ mod tests {
let message: CardanoStakeDistributionMessage = record.clone().try_into().unwrap();

let service = MessageServiceBuilder::new()
.with_signed_entity_records(&[record.clone()])
.with_signed_entity_records(std::slice::from_ref(&record))
.build()
.await;

Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/src/services/stake_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Default for UpdateToken {
}

impl UpdateToken {
pub fn update(&self, epoch: Epoch) -> StdResult<MutexGuard<()>> {
pub fn update(&self, epoch: Epoch) -> StdResult<MutexGuard<'_, ()>> {
let update_semaphore = self.is_busy.try_lock().map_err(|_| {
let last_updated_epoch = self.busy_on_epoch.read().unwrap();

Expand Down
8 changes: 7 additions & 1 deletion mithril-aggregator/src/store/epoch_settings_storer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[cfg(test)]
use std::collections::HashMap;

use async_trait::async_trait;
use mithril_common::StdResult;
#[cfg(test)]
use tokio::sync::RwLock;

use mithril_common::entities::{Epoch, ProtocolParameters};
Expand Down Expand Up @@ -56,18 +58,20 @@ pub trait EpochSettingsStorer:
}
}

#[cfg(test)]
pub struct FakeEpochSettingsStorer {
pub epoch_settings: RwLock<HashMap<Epoch, AggregatorEpochSettings>>,
}

#[cfg(test)]
impl FakeEpochSettingsStorer {
#[cfg(test)]
pub fn new(data: Vec<(Epoch, AggregatorEpochSettings)>) -> Self {
let epoch_settings = RwLock::new(data.into_iter().collect());
Self { epoch_settings }
}
}

#[cfg(test)]
#[async_trait]
impl ProtocolParametersRetriever for FakeEpochSettingsStorer {
async fn get_protocol_parameters(&self, epoch: Epoch) -> StdResult<Option<ProtocolParameters>> {
Expand All @@ -78,6 +82,7 @@ impl ProtocolParametersRetriever for FakeEpochSettingsStorer {
}
}

#[cfg(test)]
#[async_trait]
impl EpochSettingsStorer for FakeEpochSettingsStorer {
async fn save_epoch_settings(
Expand All @@ -97,6 +102,7 @@ impl EpochSettingsStorer for FakeEpochSettingsStorer {
}
}

#[cfg(test)]
#[async_trait]
impl EpochPruningTask for FakeEpochSettingsStorer {
fn pruned_data(&self) -> &'static str {
Expand Down
Loading