Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a3bf45e
feature(aggregator): WIP: add protocol-config dependency and start a …
turmelclem Oct 7, 2025
6f1d085
feat(aggregator): implement local configuration for mithril network c…
turmelclem Oct 10, 2025
7c0f6b5
chore(aggregator): remove update_epoch_settings from epoch_service, c…
turmelclem Nov 3, 2025
758c48c
refactor(aggregator): do not override existing epoch settings on save
turmelclem Nov 3, 2025
53bfc51
feat(aggregator): add `preload_security_parameter` config parameter
Alenar Nov 5, 2025
dcd103a
doc(website): add `preload_security_parameter` to aggregator doc
Alenar Nov 10, 2025
961e880
feat(aggregator): make protocol_parameters and cardano_transaction_si…
turmelclem Nov 4, 2025
83d9a18
test(aggregator): simplify & rework serve deps container test tooling
Alenar Nov 4, 2025
3a497cd
feat(aggregator): move & rework handle discrepancies
Alenar Nov 5, 2025
bad67ff
chore(aggregator): log when a dependency is built by the dep builder
Alenar Nov 5, 2025
229c9e7
fix(e2e): only update protocol parameters on leader aggregator
Alenar Nov 6, 2025
78ce58b
feat(aggregator): improve logging when single signature authenticatio…
turmelclem Nov 7, 2025
b032862
feat(e2e): output logs in expandable group when running in github act…
Alenar Nov 6, 2025
6319f63
chore(e2e): disable log group in github action
Alenar Nov 10, 2025
df320c5
feat(aggregator): make epoch service allowed discriminants an interse…
Alenar Nov 10, 2025
b5d7048
chore(openapi): prepare removal of `signer_registration_protocol` and…
Alenar Nov 12, 2025
c42e7a8
chore: prepare removal of protocol params & ctx config from `EpochSet…
Alenar Nov 12, 2025
3f771a3
chore(common): deprecate protocol params & ctx config fields in `Epoc…
Alenar Nov 12, 2025
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
1 change: 1 addition & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ Here is a list of the available parameters for the serve command:
| `cardano_transactions_prover_max_hashes_allowed_by_request` | `--cardano-transactions-prover-max-hashes-allowed-by-request` | - | `CARDANO_TRANSACTIONS_PROVER_MAX_HASHES_ALLOWED_BY_REQUEST` | Maximum number of transactions hashes allowed by request to the prover of the Cardano transactions | `100` | `100` | - |
| `cardano_transactions_block_streamer_max_roll_forwards_per_poll` | `--cardano-transactions-block-streamer-max-roll-forwards-per-poll` | - | `CARDANO_TRANSACTIONS_BLOCK_STREAMER_MAX_ROLL_FORWARDS_PER_POLL` | Maximum number of roll forwards during a poll of the block streamer when importing transactions | `1000` | `1000` | - |
| `cardano_transactions_signing_config` | `--cardano-transactions-signing-config` | - | `CARDANO_TRANSACTIONS_SIGNING_CONFIG` | Cardano transactions signing configuration | `{ "security_parameter": 3000, "step": 120 }` | `{ "security_parameter": 3000, "step": 120 }` | - |
| `preload_security_parameter` | - | - | `PRELOAD_SECURITY_PARAMETER` | Blocks offset, from the tip of the chain, to exclude during the cardano transactions preload<br/>`[default: 2160]`. | `2160` | - | :heavy_check_mark: |
| `enable_metrics_server` | `--enable-metrics-server` | - | `ENABLE_METRICS_SERVER` | Enable metrics HTTP server (Prometheus endpoint on /metrics) | `false` | - | - |
| `metrics_server_ip` | `--metrics-server-ip` | - | `METRICS_SERVER_IP` | Metrics HTTP server IP | `0.0.0.0` | - | - |
| `metrics_server_port` | `--metrics-server-port` | - | `METRICS_SERVER_PORT` | Metrics HTTP server listening port | `9090` | - | - |
Expand Down
1 change: 1 addition & 0 deletions mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mithril-doc = { path = "../internal/mithril-doc" }
mithril-era = { path = "../internal/mithril-era" }
mithril-metric = { path = "../internal/mithril-metric" }
mithril-persistence = { path = "../internal/mithril-persistence" }
mithril-protocol-config = { path = "../internal/mithril-protocol-config" }
mithril-resource-pool = { path = "../internal/mithril-resource-pool" }
mithril-signed-entity-lock = { path = "../internal/signed-entity/mithril-signed-entity-lock" }
mithril-signed-entity-preloader = { path = "../internal/signed-entity/mithril-signed-entity-preloader" }
Expand Down
61 changes: 44 additions & 17 deletions mithril-aggregator/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub trait ConfigurationSource {
}

/// Protocol parameters
fn protocol_parameters(&self) -> ProtocolParameters {
fn protocol_parameters(&self) -> Option<ProtocolParameters> {
panic!("protocol_parameters is not implemented.");
}

Expand Down Expand Up @@ -251,10 +251,15 @@ pub trait ConfigurationSource {
}

/// Cardano transactions signing configuration
fn cardano_transactions_signing_config(&self) -> CardanoTransactionsSigningConfig {
fn cardano_transactions_signing_config(&self) -> Option<CardanoTransactionsSigningConfig> {
panic!("cardano_transactions_signing_config is not implemented.");
}

/// Blocks offset, from the tip of the chain, to exclude during the cardano transactions preload
fn preload_security_parameter(&self) -> BlockNumber {
panic!("preload_security_parameter is not implemented.");
}

/// Maximum number of transactions hashes allowed by request to the prover of the Cardano transactions
fn cardano_transactions_prover_max_hashes_allowed_by_request(&self) -> usize {
panic!("cardano_transactions_prover_max_hashes_allowed_by_request is not implemented.");
Expand Down Expand Up @@ -373,12 +378,20 @@ pub trait ConfigurationSource {
}
}

/// Infer the [AggregatorEpochSettings] from the configuration.
fn get_epoch_settings_configuration(&self) -> AggregatorEpochSettings {
AggregatorEpochSettings {
protocol_parameters: self.protocol_parameters(),
cardano_transactions_signing_config: self.cardano_transactions_signing_config(),
}
/// `leader aggregator only` Infer the [AggregatorEpochSettings] from the configuration.
fn get_leader_aggregator_epoch_settings_configuration(
&self,
) -> StdResult<AggregatorEpochSettings> {
Ok(AggregatorEpochSettings {
protocol_parameters: self.protocol_parameters().with_context(
|| "Configuration `protocol_parameter` is mandatory for a Leader Aggregator",
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the configuration field name: the error message refers to protocol_parameter (singular) but the actual field name is protocol_parameters (plural). This should be corrected to match the actual field name for clarity.

Suggested change
|| "Configuration `protocol_parameter` is mandatory for a Leader Aggregator",
|| "Configuration `protocol_parameters` is mandatory for a Leader Aggregator",

Copilot uses AI. Check for mistakes.
)?,
cardano_transactions_signing_config: self
.cardano_transactions_signing_config()
.with_context(
|| "Configuration `cardano_transactions_signing_config` is mandatory for a Leader Aggregator",
)?,
})
}

/// Check if the aggregator is running in follower mode.
Expand Down Expand Up @@ -453,7 +466,7 @@ pub struct ServeCommandConfiguration {

/// Protocol parameters
#[example = "`{ k: 5, m: 100, phi_f: 0.65 }`"]
pub protocol_parameters: ProtocolParameters,
pub protocol_parameters: Option<ProtocolParameters>,

/// Type of snapshot uploader to use
#[example = "`gcp` or `local`"]
Expand Down Expand Up @@ -556,7 +569,11 @@ pub struct ServeCommandConfiguration {

/// Cardano transactions signing configuration
#[example = "`{ security_parameter: 3000, step: 120 }`"]
pub cardano_transactions_signing_config: CardanoTransactionsSigningConfig,
pub cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,

/// Blocks offset, from the tip of the chain, to exclude during the cardano transactions preload
/// `[default: 2160]`.
pub preload_security_parameter: BlockNumber,

/// Maximum number of transactions hashes allowed by request to the prover of the Cardano transactions
pub cardano_transactions_prover_max_hashes_allowed_by_request: usize,
Expand Down Expand Up @@ -672,11 +689,11 @@ impl ServeCommandConfiguration {
network_magic: Some(42),
dmq_network_magic: Some(3141592),
chain_observer_type: ChainObserverType::Fake,
protocol_parameters: ProtocolParameters {
protocol_parameters: Some(ProtocolParameters {
k: 5,
m: 100,
phi_f: 0.95,
},
}),
snapshot_uploader_type: SnapshotUploaderType::Local,
snapshot_bucket_name: None,
snapshot_use_cdn_domain: false,
Expand Down Expand Up @@ -710,10 +727,11 @@ impl ServeCommandConfiguration {
allow_unparsable_block: false,
cardano_transactions_prover_cache_pool_size: 3,
cardano_transactions_database_connection_pool_size: 5,
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
cardano_transactions_signing_config: Some(CardanoTransactionsSigningConfig {
security_parameter: BlockNumber(120),
step: BlockNumber(15),
},
}),
preload_security_parameter: BlockNumber(30),
cardano_transactions_prover_max_hashes_allowed_by_request: 100,
cardano_transactions_block_streamer_max_roll_forwards_per_poll: 1000,
enable_metrics_server: true,
Expand Down Expand Up @@ -773,7 +791,7 @@ impl ConfigurationSource for ServeCommandConfiguration {
self.chain_observer_type.clone()
}

fn protocol_parameters(&self) -> ProtocolParameters {
fn protocol_parameters(&self) -> Option<ProtocolParameters> {
self.protocol_parameters.clone()
}

Expand Down Expand Up @@ -877,10 +895,14 @@ impl ConfigurationSource for ServeCommandConfiguration {
self.cardano_transactions_database_connection_pool_size
}

fn cardano_transactions_signing_config(&self) -> CardanoTransactionsSigningConfig {
fn cardano_transactions_signing_config(&self) -> Option<CardanoTransactionsSigningConfig> {
self.cardano_transactions_signing_config.clone()
}

fn preload_security_parameter(&self) -> BlockNumber {
self.preload_security_parameter
}

fn cardano_transactions_prover_max_hashes_allowed_by_request(&self) -> usize {
self.cardano_transactions_prover_max_hashes_allowed_by_request
}
Expand Down Expand Up @@ -981,6 +1003,9 @@ pub struct DefaultConfiguration {
/// Cardano transactions signing configuration
pub cardano_transactions_signing_config: CardanoTransactionsSigningConfig,

/// Blocks offset, from the tip of the chain, to exclude during the cardano transactions preload
pub preload_security_parameter: u64,

/// Maximum number of transactions hashes allowed by request to the prover of the Cardano transactions
pub cardano_transactions_prover_max_hashes_allowed_by_request: u32,

Expand Down Expand Up @@ -1026,6 +1051,7 @@ impl Default for DefaultConfiguration {
security_parameter: BlockNumber(3000),
step: BlockNumber(120),
},
preload_security_parameter: 2160,
cardano_transactions_prover_max_hashes_allowed_by_request: 100,
cardano_transactions_block_streamer_max_roll_forwards_per_poll: 10000,
enable_metrics_server: "false".to_string(),
Expand Down Expand Up @@ -1104,14 +1130,15 @@ impl Source for DefaultConfiguration {
&namespace,
myself.persist_usage_report_interval_in_seconds
);
register_config_value!(result, &namespace, myself.preload_security_parameter);
register_config_value!(
result,
&namespace,
myself.cardano_transactions_signing_config,
|v: CardanoTransactionsSigningConfig| HashMap::from([
(
"security_parameter".to_string(),
ValueKind::from(*v.security_parameter,),
ValueKind::from(*v.security_parameter),
),
("step".to_string(), ValueKind::from(*v.step),)
])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
use sqlite::Value;

use mithril_persistence::sqlite::{Query, SourceAlias, SqLiteEntity, WhereCondition};

use crate::database::record::EpochSettingsRecord;

/// Query to update [EpochSettingsRecord] in the sqlite database
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment on line 7 states "Query to update [EpochSettingsRecord]" but this is actually an insert operation (insert or ignore), not an update. The comment should be corrected to "Query to insert [EpochSettingsRecord]" or "Query to insert [EpochSettingsRecord] if it doesn't exist".

Suggested change
/// Query to update [EpochSettingsRecord] in the sqlite database
/// Query to insert [EpochSettingsRecord] into the sqlite database if it doesn't exist

Copilot uses AI. Check for mistakes.
pub struct InsertOrIgnoreEpochSettingsQuery {
condition: WhereCondition,
}

impl InsertOrIgnoreEpochSettingsQuery {
pub fn one(epoch_settings: EpochSettingsRecord) -> Self {
Self {
condition: WhereCondition::new(
"(epoch_setting_id, protocol_parameters, cardano_transactions_signing_config) values (?1, ?2, ?3)",
vec![
Value::Integer(*epoch_settings.epoch_settings_id as i64),
Value::String(
serde_json::to_string(&epoch_settings.protocol_parameters).unwrap(),
),
Value::String(
serde_json::to_string(&epoch_settings.cardano_transactions_signing_config)
.unwrap(),
),
],
),
}
}
}

impl Query for InsertOrIgnoreEpochSettingsQuery {
type Entity = EpochSettingsRecord;

fn filters(&self) -> WhereCondition {
self.condition.clone()
}

fn get_definition(&self, condition: &str) -> String {
// it is important to alias the fields with the same name as the table
// since the table cannot be aliased in a RETURNING statement in SQLite.
let projection = Self::Entity::get_projection()
.expand(SourceAlias::new(&[("{:epoch_setting:}", "epoch_setting")]));

format!("insert or ignore into epoch_setting {condition} returning {projection}")
}
}

#[cfg(test)]
mod tests {
use mithril_common::entities::{BlockNumber, CardanoTransactionsSigningConfig, Epoch};
use mithril_common::test::double::fake_data;
use mithril_persistence::sqlite::ConnectionExtensions;

use crate::database::query::GetEpochSettingsQuery;
use crate::database::test_helper::main_db_connection;

use super::*;

#[test]
fn test_insert_epoch_setting_in_empty_db() {
let connection = main_db_connection().unwrap();

let expected_epoch_settings = EpochSettingsRecord {
epoch_settings_id: Epoch(3),
protocol_parameters: fake_data::protocol_parameters(),
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
security_parameter: BlockNumber(24),
step: BlockNumber(62),
},
};
let record = connection
.fetch_first(InsertOrIgnoreEpochSettingsQuery::one(
expected_epoch_settings.clone(),
))
.unwrap();

assert_eq!(Some(expected_epoch_settings), record);
}

#[test]
fn test_cant_replace_existing_value() {
let connection = main_db_connection().unwrap();

let expected_epoch_settings = EpochSettingsRecord {
epoch_settings_id: Epoch(3),
protocol_parameters: fake_data::protocol_parameters(),
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
security_parameter: BlockNumber(24),
step: BlockNumber(62),
},
};
let record = connection
.fetch_first(InsertOrIgnoreEpochSettingsQuery::one(
expected_epoch_settings.clone(),
))
.unwrap();
assert!(record.is_some());

let record = connection
.fetch_first(InsertOrIgnoreEpochSettingsQuery::one(EpochSettingsRecord {
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
security_parameter: BlockNumber(134),
step: BlockNumber(872),
},
..expected_epoch_settings.clone()
}))
.unwrap();
assert!(record.is_none());

let record_in_db = connection
.fetch_first(GetEpochSettingsQuery::by_epoch(Epoch(3)).unwrap())
.unwrap();
assert_eq!(Some(expected_epoch_settings), record_in_db);
}
}
4 changes: 2 additions & 2 deletions mithril-aggregator/src/database/query/epoch_settings/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod delete_epoch_settings;
mod get_epoch_settings;
mod update_epoch_settings;
mod insert_or_ignore_epoch_settings;

pub use delete_epoch_settings::*;
pub use get_epoch_settings::*;
pub use update_epoch_settings::*;
pub use insert_or_ignore_epoch_settings::*;
Loading
Loading