-
Notifications
You must be signed in to change notification settings - Fork 52
Decentralization of configuration parameters phase 1 - Aggregator local parameters #2736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Alenar
merged 22 commits into
main
from
ctl/2692-decentralization-of-configuration-parameters-phase-1-local-parameters
Nov 13, 2025
Merged
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7d04283
feature(aggregator): WIP: add protocol-config dependency and start a …
turmelclem 51ce8a1
feat(aggregator): implement local configuration for mithril network c…
turmelclem f920b08
chore(aggregator): remove update_epoch_settings from epoch_service, c…
turmelclem b0003a8
refactor(aggregator): do not override existing epoch settings on save
turmelclem 83b2b49
feat(aggregator): add `preload_security_parameter` config parameter
Alenar d2f5a24
doc(website): add `preload_security_parameter` to aggregator doc
Alenar f510adc
feat(aggregator): make protocol_parameters and cardano_transaction_si…
turmelclem 6322f2e
test(aggregator): simplify & rework serve deps container test tooling
Alenar ba06a3c
feat(aggregator): move & rework handle discrepancies
Alenar e07488c
chore(aggregator): log when a dependency is built by the dep builder
Alenar 462a091
fix(e2e): only update protocol parameters on leader aggregator
Alenar dcf4f5a
feat(aggregator): improve logging when single signature authenticatio…
turmelclem befb13c
feat(e2e): output logs in expandable group when running in github act…
Alenar 36e7a40
chore(e2e): disable log group in github action
Alenar c93b35b
feat(aggregator): make epoch service allowed discriminants an interse…
Alenar f57be30
chore(openapi): prepare removal of `signer_registration_protocol` and…
Alenar 904b2fd
chore: prepare removal of protocol params & ctx config from `EpochSet…
Alenar baa84f3
chore(common): deprecate protocol params & ctx config fields in `Epoc…
Alenar b0ce1b1
style: address PR comments
Alenar a5cb7ab
chore(signer): set default `preload_security_parameter` to `2160`
Alenar 5e8f70c
chore: upgrade crate versions and `openapi.yaml` version
Alenar fb152f8
chore: update changelog
Alenar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
mithril-aggregator/src/database/query/epoch_settings/insert_or_ignore_epoch_settings.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
Alenar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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::*; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.