Skip to content

Commit 59bf453

Browse files
authored
Merge pull request #2736 from input-output-hk/ctl/2692-decentralization-of-configuration-parameters-phase-1-local-parameters
Decentralization of configuration parameters phase 1 - Aggregator local parameters
2 parents a735684 + fb152f8 commit 59bf453

File tree

54 files changed

+1170
-729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1170
-729
lines changed

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ As a minor extension, we have adopted a slightly different versioning convention
99

1010
## Mithril Distribution [XXXX] - UNRELEASED
1111

12-
- **UNSTABLE**:
12+
- Decentralization of the configuration parameters of Mithril networks:
1313
- Added the `/protocol-configuration/{epoch}` route to fetch aggregator configuration for a given epoch, `{epoch}` must be a number.
14-
15-
- Enhanced `MithrilNetworkConfigurationProvider` to return configuration with a window of three epoch.
16-
- Adapt Signer to read configurations from HttpMithrilNetworkConfigurationProvider
14+
- Refactor Signer and Aggregator (leader, follower) to read network configurations from a `MithrilNetworkConfigurationProvider`
15+
- Support for reading network configurations from its leader aggregator for the follower aggregators.
1716

1817
- Crates versions:
1918

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/website/root/manual/develop/nodes/mithril-aggregator.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ Here is a list of the available parameters for the serve command:
537537
| `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` | - |
538538
| `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` | - |
539539
| `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 }` | - |
540+
| `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: |
540541
| `enable_metrics_server` | `--enable-metrics-server` | - | `ENABLE_METRICS_SERVER` | Enable metrics HTTP server (Prometheus endpoint on /metrics) | `false` | - | - |
541542
| `metrics_server_ip` | `--metrics-server-ip` | - | `METRICS_SERVER_IP` | Metrics HTTP server IP | `0.0.0.0` | - | - |
542543
| `metrics_server_port` | `--metrics-server-port` | - | `METRICS_SERVER_PORT` | Metrics HTTP server listening port | `9090` | - | - |

mithril-aggregator/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.7.93"
3+
version = "0.7.94"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -36,6 +36,7 @@ mithril-doc = { path = "../internal/mithril-doc" }
3636
mithril-era = { path = "../internal/mithril-era" }
3737
mithril-metric = { path = "../internal/mithril-metric" }
3838
mithril-persistence = { path = "../internal/mithril-persistence" }
39+
mithril-protocol-config = { path = "../internal/mithril-protocol-config" }
3940
mithril-resource-pool = { path = "../internal/mithril-resource-pool" }
4041
mithril-signed-entity-lock = { path = "../internal/signed-entity/mithril-signed-entity-lock" }
4142
mithril-signed-entity-preloader = { path = "../internal/signed-entity/mithril-signed-entity-preloader" }

mithril-aggregator/src/configuration.rs

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub trait ConfigurationSource {
109109
}
110110

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

@@ -251,10 +251,15 @@ pub trait ConfigurationSource {
251251
}
252252

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

258+
/// Blocks offset, from the tip of the chain, to exclude during the cardano transactions preload
259+
fn preload_security_parameter(&self) -> BlockNumber {
260+
panic!("preload_security_parameter is not implemented.");
261+
}
262+
258263
/// Maximum number of transactions hashes allowed by request to the prover of the Cardano transactions
259264
fn cardano_transactions_prover_max_hashes_allowed_by_request(&self) -> usize {
260265
panic!("cardano_transactions_prover_max_hashes_allowed_by_request is not implemented.");
@@ -373,12 +378,20 @@ pub trait ConfigurationSource {
373378
}
374379
}
375380

376-
/// Infer the [AggregatorEpochSettings] from the configuration.
377-
fn get_epoch_settings_configuration(&self) -> AggregatorEpochSettings {
378-
AggregatorEpochSettings {
379-
protocol_parameters: self.protocol_parameters(),
380-
cardano_transactions_signing_config: self.cardano_transactions_signing_config(),
381-
}
381+
/// `leader aggregator only` Infer the [AggregatorEpochSettings] from the configuration.
382+
fn get_leader_aggregator_epoch_settings_configuration(
383+
&self,
384+
) -> StdResult<AggregatorEpochSettings> {
385+
Ok(AggregatorEpochSettings {
386+
protocol_parameters: self.protocol_parameters().with_context(
387+
|| "Configuration `protocol_parameters` is mandatory for a Leader Aggregator",
388+
)?,
389+
cardano_transactions_signing_config: self
390+
.cardano_transactions_signing_config()
391+
.with_context(
392+
|| "Configuration `cardano_transactions_signing_config` is mandatory for a Leader Aggregator",
393+
)?,
394+
})
382395
}
383396

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

454467
/// Protocol parameters
455468
#[example = "`{ k: 5, m: 100, phi_f: 0.65 }`"]
456-
pub protocol_parameters: ProtocolParameters,
469+
pub protocol_parameters: Option<ProtocolParameters>,
457470

458471
/// Type of snapshot uploader to use
459472
#[example = "`gcp` or `local`"]
@@ -556,7 +569,12 @@ pub struct ServeCommandConfiguration {
556569

557570
/// Cardano transactions signing configuration
558571
#[example = "`{ security_parameter: 3000, step: 120 }`"]
559-
pub cardano_transactions_signing_config: CardanoTransactionsSigningConfig,
572+
pub cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,
573+
574+
/// Blocks offset, from the tip of the chain, to exclude during the Cardano transactions preload,
575+
/// default to 2160.
576+
#[example = "`2160`"]
577+
pub preload_security_parameter: BlockNumber,
560578

561579
/// Maximum number of transactions hashes allowed by request to the prover of the Cardano transactions
562580
pub cardano_transactions_prover_max_hashes_allowed_by_request: usize,
@@ -672,11 +690,11 @@ impl ServeCommandConfiguration {
672690
network_magic: Some(42),
673691
dmq_network_magic: Some(3141592),
674692
chain_observer_type: ChainObserverType::Fake,
675-
protocol_parameters: ProtocolParameters {
693+
protocol_parameters: Some(ProtocolParameters {
676694
k: 5,
677695
m: 100,
678696
phi_f: 0.95,
679-
},
697+
}),
680698
snapshot_uploader_type: SnapshotUploaderType::Local,
681699
snapshot_bucket_name: None,
682700
snapshot_use_cdn_domain: false,
@@ -710,10 +728,11 @@ impl ServeCommandConfiguration {
710728
allow_unparsable_block: false,
711729
cardano_transactions_prover_cache_pool_size: 3,
712730
cardano_transactions_database_connection_pool_size: 5,
713-
cardano_transactions_signing_config: CardanoTransactionsSigningConfig {
731+
cardano_transactions_signing_config: Some(CardanoTransactionsSigningConfig {
714732
security_parameter: BlockNumber(120),
715733
step: BlockNumber(15),
716-
},
734+
}),
735+
preload_security_parameter: BlockNumber(30),
717736
cardano_transactions_prover_max_hashes_allowed_by_request: 100,
718737
cardano_transactions_block_streamer_max_roll_forwards_per_poll: 1000,
719738
enable_metrics_server: true,
@@ -773,7 +792,7 @@ impl ConfigurationSource for ServeCommandConfiguration {
773792
self.chain_observer_type.clone()
774793
}
775794

776-
fn protocol_parameters(&self) -> ProtocolParameters {
795+
fn protocol_parameters(&self) -> Option<ProtocolParameters> {
777796
self.protocol_parameters.clone()
778797
}
779798

@@ -877,10 +896,14 @@ impl ConfigurationSource for ServeCommandConfiguration {
877896
self.cardano_transactions_database_connection_pool_size
878897
}
879898

880-
fn cardano_transactions_signing_config(&self) -> CardanoTransactionsSigningConfig {
899+
fn cardano_transactions_signing_config(&self) -> Option<CardanoTransactionsSigningConfig> {
881900
self.cardano_transactions_signing_config.clone()
882901
}
883902

903+
fn preload_security_parameter(&self) -> BlockNumber {
904+
self.preload_security_parameter
905+
}
906+
884907
fn cardano_transactions_prover_max_hashes_allowed_by_request(&self) -> usize {
885908
self.cardano_transactions_prover_max_hashes_allowed_by_request
886909
}
@@ -981,6 +1004,9 @@ pub struct DefaultConfiguration {
9811004
/// Cardano transactions signing configuration
9821005
pub cardano_transactions_signing_config: CardanoTransactionsSigningConfig,
9831006

1007+
/// Blocks offset, from the tip of the chain, to exclude during the Cardano transactions preload
1008+
pub preload_security_parameter: u64,
1009+
9841010
/// Maximum number of transactions hashes allowed by request to the prover of the Cardano transactions
9851011
pub cardano_transactions_prover_max_hashes_allowed_by_request: u32,
9861012

@@ -1026,6 +1052,7 @@ impl Default for DefaultConfiguration {
10261052
security_parameter: BlockNumber(3000),
10271053
step: BlockNumber(120),
10281054
},
1055+
preload_security_parameter: 2160,
10291056
cardano_transactions_prover_max_hashes_allowed_by_request: 100,
10301057
cardano_transactions_block_streamer_max_roll_forwards_per_poll: 10000,
10311058
enable_metrics_server: "false".to_string(),
@@ -1104,14 +1131,15 @@ impl Source for DefaultConfiguration {
11041131
&namespace,
11051132
myself.persist_usage_report_interval_in_seconds
11061133
);
1134+
register_config_value!(result, &namespace, myself.preload_security_parameter);
11071135
register_config_value!(
11081136
result,
11091137
&namespace,
11101138
myself.cardano_transactions_signing_config,
11111139
|v: CardanoTransactionsSigningConfig| HashMap::from([
11121140
(
11131141
"security_parameter".to_string(),
1114-
ValueKind::from(*v.security_parameter,),
1142+
ValueKind::from(*v.security_parameter),
11151143
),
11161144
("step".to_string(), ValueKind::from(*v.step),)
11171145
])

0 commit comments

Comments
 (0)