Skip to content

Commit 678f1fa

Browse files
committed
feat(aggregator): add aggregate signature type in root route
1 parent 6e57783 commit 678f1fa

File tree

6 files changed

+179
-110
lines changed

6 files changed

+179
-110
lines changed

mithril-aggregator/src/dependency_injection/builder/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ impl DependenciesBuilder {
453453
cardano_node_version: self.configuration.cardano_node_version(),
454454
allow_http_serve_directory: self.configuration.allow_http_serve_directory(),
455455
origin_tag_white_list: self.configuration.compute_origin_tag_white_list(),
456+
aggregate_signature_type: self.configuration.aggregate_signature_type(),
456457
},
457458
);
458459

mithril-aggregator/src/http_server/routes/root_routes.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ fn root(
1818
.and(middlewares::extract_config(router_state, |config| {
1919
config.allowed_discriminants.clone()
2020
}))
21+
.and(middlewares::extract_config(router_state, |config| {
22+
config.aggregate_signature_type
23+
}))
2124
.and(middlewares::extract_config(router_state, |config| {
2225
config.cardano_transactions_prover_max_hashes_allowed_by_request
2326
}))
@@ -28,6 +31,7 @@ mod handlers {
2831
use std::collections::BTreeSet;
2932
use std::{convert::Infallible, sync::Arc};
3033

34+
use mithril_common::AggregateSignatureType;
3135
use slog::Logger;
3236
use warp::http::StatusCode;
3337

@@ -45,6 +49,7 @@ mod handlers {
4549
logger: Logger,
4650
api_version_provider: Arc<APIVersionProvider>,
4751
allowed_signed_entity_type_discriminants: BTreeSet<SignedEntityTypeDiscriminants>,
52+
aggregate_signature_type: AggregateSignatureType,
4853
max_hashes_allowed_by_request: usize,
4954
) -> Result<impl warp::Reply, Infallible> {
5055
let open_api_version = unwrap_to_internal_server_error!(
@@ -54,6 +59,7 @@ mod handlers {
5459

5560
let mut capabilities = AggregatorCapabilities {
5661
signed_entity_types: allowed_signed_entity_type_discriminants,
62+
aggregate_signature_type,
5763
cardano_transactions_prover: None,
5864
};
5965

@@ -87,6 +93,7 @@ mod tests {
8793
use warp::test::request;
8894

8995
use mithril_api_spec::APISpec;
96+
use mithril_common::AggregateSignatureType;
9097
use mithril_common::entities::SignedEntityTypeDiscriminants;
9198
use mithril_common::messages::{
9299
AggregatorCapabilities, AggregatorFeaturesMessage, CardanoTransactionsProverCapabilities,
@@ -155,6 +162,7 @@ mod tests {
155162
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull,
156163
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
157164
]),
165+
aggregate_signature_type: AggregateSignatureType::Concatenation,
158166
cardano_transactions_prover: None,
159167
},
160168
}

mithril-aggregator/src/http_server/routes/router.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use mithril_common::entities::SignedEntityTypeDiscriminants;
1111
#[cfg(test)]
1212
use mithril_common::test::double::Dummy;
1313
use mithril_common::{
14-
CardanoNetwork, MITHRIL_API_VERSION_HEADER, MITHRIL_CLIENT_TYPE_HEADER,
14+
AggregateSignatureType, CardanoNetwork, MITHRIL_API_VERSION_HEADER, MITHRIL_CLIENT_TYPE_HEADER,
1515
MITHRIL_ORIGIN_TAG_HEADER,
1616
};
1717

@@ -35,6 +35,7 @@ pub struct RouterConfig {
3535
pub cardano_node_version: String,
3636
pub allow_http_serve_directory: bool,
3737
pub origin_tag_white_list: HashSet<String>,
38+
pub aggregate_signature_type: AggregateSignatureType,
3839
}
3940

4041
#[cfg(test)]
@@ -53,6 +54,7 @@ impl Dummy for RouterConfig {
5354
cardano_node_version: "1.2.3".to_string(),
5455
allow_http_serve_directory: false,
5556
origin_tag_white_list: HashSet::from(["DUMMY_TAG".to_string()]),
57+
aggregate_signature_type: AggregateSignatureType::Concatenation,
5658
}
5759
}
5860
}

mithril-common/src/messages/aggregator_features.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::collections::BTreeSet;
22

33
use serde::{Deserialize, Serialize};
44

5+
use mithril_stm::AggregateSignatureType;
6+
57
use crate::entities::SignedEntityTypeDiscriminants;
68

79
/// Message advertised by an Aggregator to inform about its features
@@ -23,6 +25,9 @@ pub struct AggregatorCapabilities {
2325
/// Signed entity types that are signed by the aggregator
2426
pub signed_entity_types: BTreeSet<SignedEntityTypeDiscriminants>,
2527

28+
/// Aggregate signature type used by the aggregator
29+
pub aggregate_signature_type: AggregateSignatureType,
30+
2631
/// Cardano transactions prover capabilities
2732
#[serde(skip_serializing_if = "Option::is_none")]
2833
pub cardano_transactions_prover: Option<CardanoTransactionsProverCapabilities>,
@@ -73,6 +78,38 @@ mod tests {
7378
}
7479
}
7580

81+
#[derive(Debug, Serialize, Deserialize, PartialEq)]
82+
struct AggregatorFeaturesMessageUntilV0_6_17 {
83+
pub open_api_version: String,
84+
pub documentation_url: String,
85+
pub capabilities: AggregatorCapabilitiesUntilV0_6_17,
86+
}
87+
88+
#[derive(Debug, Serialize, Deserialize, PartialEq)]
89+
struct AggregatorCapabilitiesUntilV0_6_17 {
90+
pub signed_entity_types: BTreeSet<SignedEntityTypeDiscriminants>,
91+
#[serde(skip_serializing_if = "Option::is_none")]
92+
pub cardano_transactions_prover: Option<CardanoTransactionsProverCapabilities>,
93+
#[serde(skip_serializing_if = "Option::is_none")]
94+
pub cardano_transactions_signing_config: Option<CardanoTransactionsSigningConfig>,
95+
}
96+
97+
fn golden_message_until_open_api_0_6_17() -> AggregatorFeaturesMessageUntilV0_6_17 {
98+
AggregatorFeaturesMessageUntilV0_6_17 {
99+
open_api_version: "0.0.1".to_string(),
100+
documentation_url: "https://example.com".to_string(),
101+
capabilities: AggregatorCapabilitiesUntilV0_6_17 {
102+
signed_entity_types: BTreeSet::from([
103+
SignedEntityTypeDiscriminants::CardanoTransactions,
104+
]),
105+
cardano_transactions_prover: Some(CardanoTransactionsProverCapabilities {
106+
max_hashes_allowed_by_request: 100,
107+
}),
108+
cardano_transactions_signing_config: None,
109+
},
110+
}
111+
}
112+
76113
fn golden_message_current() -> AggregatorFeaturesMessage {
77114
AggregatorFeaturesMessage {
78115
open_api_version: "0.0.1".to_string(),
@@ -81,6 +118,7 @@ mod tests {
81118
signed_entity_types: BTreeSet::from([
82119
SignedEntityTypeDiscriminants::CardanoTransactions,
83120
]),
121+
aggregate_signature_type: AggregateSignatureType::Concatenation,
84122
cardano_transactions_prover: Some(CardanoTransactionsProverCapabilities {
85123
max_hashes_allowed_by_request: 100,
86124
}),
@@ -93,6 +131,7 @@ mod tests {
93131
"documentation_url": "https://example.com",
94132
"capabilities": {
95133
"signed_entity_types": ["CardanoTransactions"],
134+
"aggregate_signature_type": "Concatenation",
96135
"cardano_transactions_prover": {
97136
"max_hashes_allowed_by_request": 100
98137
}
@@ -107,6 +146,14 @@ mod tests {
107146
assert_eq!(golden_message_until_open_api_0_1_45(), message);
108147
}
109148

149+
#[test]
150+
fn test_current_json_deserialized_into_message_supported_until_open_api_0_6_17() {
151+
let json = CURRENT_JSON;
152+
let message: AggregatorFeaturesMessageUntilV0_6_17 = serde_json::from_str(json).unwrap();
153+
154+
assert_eq!(golden_message_until_open_api_0_6_17(), message);
155+
}
156+
110157
#[test]
111158
fn test_current_json_deserialized_into_current_message() {
112159
let json = CURRENT_JSON;

mithril-common/src/test/double/dummies.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ mod entities {
7979
}
8080

8181
mod messages {
82-
use chrono::Duration;
8382
use std::collections::BTreeSet;
8483

84+
use chrono::Duration;
85+
86+
use mithril_stm::AggregateSignatureType;
87+
8588
use crate::entities::{
8689
AncillaryLocation, BlockNumber, CardanoDbBeacon, CardanoTransactionsSetProof,
8790
CardanoTransactionsSigningConfig, CompressionAlgorithm, DigestLocation, Epoch,
@@ -168,6 +171,7 @@ mod messages {
168171
signed_entity_types: BTreeSet::from([
169172
SignedEntityTypeDiscriminants::MithrilStakeDistribution,
170173
]),
174+
aggregate_signature_type: AggregateSignatureType::Concatenation,
171175
cardano_transactions_prover: None,
172176
},
173177
}

0 commit comments

Comments
 (0)