Skip to content

Commit bab0560

Browse files
committed
feat: add 'CardanoTransactions' signed entity type
1 parent 17c879d commit bab0560

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

mithril-aggregator/src/services/certifier.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ impl CertifierService for MithrilCertifierService {
397397
}
398398
}
399399
SignedEntityType::CardanoImmutableFilesFull(beacon) => beacon.clone(),
400+
SignedEntityType::CardanoTransactions(beacon) => beacon.clone(),
400401
};
401402
let metadata = CertificateMetadata::new(
402403
protocol_version,

mithril-aggregator/src/services/signed_entity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl MithrilSignedEntityService {
114114
})?,
115115
)),
116116
SignedEntityType::CardanoStakeDistribution(_) => todo!(),
117+
SignedEntityType::CardanoTransactions(_) => todo!(),
117118
}
118119
}
119120
}

mithril-aggregator/src/tools/certificates_hash_migrator.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ mod test {
196196
entities::{
197197
Beacon, Certificate, Epoch, ImmutableFileNumber,
198198
SignedEntityType::{
199-
CardanoImmutableFilesFull, CardanoStakeDistribution, MithrilStakeDistribution,
199+
CardanoImmutableFilesFull, CardanoStakeDistribution, CardanoTransactions,
200+
MithrilStakeDistribution,
200201
},
201202
SignedEntityTypeDiscriminants,
202203
},
@@ -283,6 +284,9 @@ mod test {
283284
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull => {
284285
CardanoImmutableFilesFull(certificate.beacon.clone())
285286
}
287+
SignedEntityTypeDiscriminants::CardanoTransactions => {
288+
CardanoTransactions(certificate.beacon.clone())
289+
}
286290
};
287291
// Note: we don't need to have real artifacts for those tests
288292
let artifact = format!("{signed_entity_type:?}");

mithril-aggregator/tests/test_extensions/aggregator_observer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ impl AggregatorObserver {
8686
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull => {
8787
Ok(SignedEntityType::CardanoImmutableFilesFull(beacon))
8888
}
89+
SignedEntityTypeDiscriminants::CardanoTransactions => {
90+
Ok(SignedEntityType::CardanoTransactions(beacon))
91+
}
8992
}
9093
}
9194
}

mithril-common/src/entities/signed_entity_type.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const ENTITY_TYPE_CARDANO_STAKE_DISTRIBUTION: usize = 1;
1818
/// Database representation of the SignedEntityType::CardanoImmutableFilesFull value
1919
const ENTITY_TYPE_CARDANO_IMMUTABLE_FILES_FULL: usize = 2;
2020

21+
/// Database representation of the SignedEntityType::CardanoTransactions value
22+
const ENTITY_TYPE_CARDANO_TRANSACTIONS: usize = 3;
23+
2124
/// The signed entity type that represents a type of data signed by the Mithril
2225
/// protocol Note: Each variant of this enum must be associated to an entry in
2326
/// the `signed_entity_type` table of the signer/aggregator nodes. The variant
@@ -36,6 +39,9 @@ pub enum SignedEntityType {
3639

3740
/// Full Cardano Immutable Files
3841
CardanoImmutableFilesFull(Beacon),
42+
43+
/// Cardano Transactions
44+
CardanoTransactions(Beacon),
3945
}
4046

4147
impl SignedEntityType {
@@ -47,7 +53,7 @@ impl SignedEntityType {
4753
/// Return the epoch from the intern beacon.
4854
pub fn get_epoch(&self) -> Epoch {
4955
match self {
50-
Self::CardanoImmutableFilesFull(b) => b.epoch,
56+
Self::CardanoImmutableFilesFull(b) | Self::CardanoTransactions(b) => b.epoch,
5157
Self::CardanoStakeDistribution(e) | Self::MithrilStakeDistribution(e) => *e,
5258
}
5359
}
@@ -80,6 +86,14 @@ impl SignedEntityType {
8086
})?;
8187
Self::CardanoImmutableFilesFull(beacon)
8288
}
89+
ENTITY_TYPE_CARDANO_TRANSACTIONS => {
90+
let beacon: Beacon = serde_json::from_str(beacon_str).map_err(|e| {
91+
HydrationError::InvalidData(format!(
92+
"Invalid Beacon JSON in open_message.beacon: '{beacon_str}'. Error: {e}"
93+
))
94+
})?;
95+
Self::CardanoTransactions(beacon)
96+
}
8397
index => panic!("Invalid entity_type_id {index}."),
8498
};
8599

@@ -93,13 +107,16 @@ impl SignedEntityType {
93107
Self::MithrilStakeDistribution(_) => ENTITY_TYPE_MITHRIL_STAKE_DISTRIBUTION,
94108
Self::CardanoStakeDistribution(_) => ENTITY_TYPE_CARDANO_STAKE_DISTRIBUTION,
95109
Self::CardanoImmutableFilesFull(_) => ENTITY_TYPE_CARDANO_IMMUTABLE_FILES_FULL,
110+
Self::CardanoTransactions(_) => ENTITY_TYPE_CARDANO_TRANSACTIONS,
96111
}
97112
}
98113

99114
/// Return a JSON serialized value of the internal beacon
100115
pub fn get_json_beacon(&self) -> StdResult<String> {
101116
let value = match self {
102-
Self::CardanoImmutableFilesFull(value) => serde_json::to_string(value)?,
117+
Self::CardanoImmutableFilesFull(value) | Self::CardanoTransactions(value) => {
118+
serde_json::to_string(value)?
119+
}
103120
Self::CardanoStakeDistribution(value) | Self::MithrilStakeDistribution(value) => {
104121
serde_json::to_string(value)?
105122
}
@@ -112,7 +129,9 @@ impl SignedEntityType {
112129
pub fn get_open_message_timeout(&self) -> Option<Duration> {
113130
match self {
114131
Self::MithrilStakeDistribution(_) | Self::CardanoImmutableFilesFull(_) => None,
115-
Self::CardanoStakeDistribution(_) => Some(Duration::from_secs(600)),
132+
Self::CardanoStakeDistribution(_) | Self::CardanoTransactions(_) => {
133+
Some(Duration::from_secs(600))
134+
}
116135
}
117136
}
118137

@@ -128,6 +147,9 @@ impl SignedEntityType {
128147
SignedEntityTypeDiscriminants::CardanoImmutableFilesFull => {
129148
Self::CardanoImmutableFilesFull(beacon.to_owned())
130149
}
150+
SignedEntityTypeDiscriminants::CardanoTransactions => {
151+
Self::CardanoTransactions(beacon.to_owned())
152+
}
131153
}
132154
}
133155
}
@@ -139,6 +161,7 @@ impl SignedEntityTypeDiscriminants {
139161
Self::MithrilStakeDistribution => ENTITY_TYPE_MITHRIL_STAKE_DISTRIBUTION,
140162
Self::CardanoStakeDistribution => ENTITY_TYPE_CARDANO_STAKE_DISTRIBUTION,
141163
Self::CardanoImmutableFilesFull => ENTITY_TYPE_CARDANO_IMMUTABLE_FILES_FULL,
164+
Self::CardanoTransactions => ENTITY_TYPE_CARDANO_TRANSACTIONS,
142165
}
143166
}
144167
}

mithril-common/src/signable_builder/signable_builder_service.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl SignableBuilderService for MithrilSignableBuilderService {
6363
"Signable builder service can not compute protocol message with beacon: '{beacon}'"
6464
))?,
6565
SignedEntityType::CardanoStakeDistribution(_) => todo!(),
66+
SignedEntityType::CardanoTransactions(_) => todo!(),
6667
};
6768

6869
Ok(protocol_message)

0 commit comments

Comments
 (0)