Skip to content

Commit 5d38bce

Browse files
authored
Merge pull request #2055 from input-output-hk/djo/1958/remove_beacon_from_certificate
Remove beacon from certificate
2 parents 650e77d + 22dc14f commit 5d38bce

Some content is hidden

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

52 files changed

+1872
-5623
lines changed

CHANGELOG.md

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

1010
## Mithril Distribution [XXXX] - UNRELEASED
1111

12+
- **BREAKING** changes in Mithril client Lib, CLI, and WASM:
13+
14+
- Remove deprecated `beacon` field from mithril certificates.
15+
- Clients from distribution [`2430`](#mithril-distribution-24300---2024-07-30) and above are compatible with this change.
16+
1217
- Support for Prometheus metrics endpoint in aggregator
1318

1419
- Fix an issue that caused unnecessary re-scan of the Cardano chain when importing transactions.

Cargo.lock

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

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.5.91"
3+
version = "0.5.92"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/database/migration.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,5 +804,13 @@ pragma foreign_key_check;
804804
pragma foreign_keys=true;
805805
"#,
806806
),
807+
// Migration 29
808+
// Drop `immutable_file_number` column `certificate` table`
809+
SqlMigration::new(
810+
29,
811+
r#"
812+
alter table certificate drop column immutable_file_number;
813+
"#,
814+
),
807815
]
808816
}

mithril-aggregator/src/database/query/certificate/insert_certificate.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ impl InsertCertificateRecordQuery {
2525
aggregate_verification_key, \
2626
epoch, \
2727
network, \
28-
immutable_file_number, \
2928
signed_entity_type_id, \
3029
signed_entity_beacon, \
3130
protocol_version, \
@@ -35,7 +34,7 @@ impl InsertCertificateRecordQuery {
3534
initiated_at, \
3635
sealed_at)";
3736
let values_columns: Vec<&str> =
38-
repeat("(?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*)")
37+
repeat("(?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*, ?*)")
3938
.take(certificates_records.len())
4039
.collect();
4140

@@ -53,7 +52,6 @@ impl InsertCertificateRecordQuery {
5352
Value::String(certificate_record.aggregate_verification_key),
5453
Value::Integer(certificate_record.epoch.try_into().unwrap()),
5554
Value::String(certificate_record.network),
56-
Value::Integer(certificate_record.immutable_file_number as i64),
5755
Value::Integer(certificate_record.signed_entity_type.index() as i64),
5856
Value::String(
5957
certificate_record

mithril-aggregator/src/database/record/certificate.rs

Lines changed: 19 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
use chrono::{DateTime, Utc};
22

33
use mithril_common::entities::{
4-
CardanoDbBeacon, Certificate, CertificateMetadata, CertificateSignature, Epoch,
5-
HexEncodedAggregateVerificationKey, HexEncodedKey, ImmutableFileNumber, ProtocolMessage,
6-
ProtocolParameters, ProtocolVersion, SignedEntityType, StakeDistributionParty,
4+
Certificate, CertificateMetadata, CertificateSignature, Epoch,
5+
HexEncodedAggregateVerificationKey, HexEncodedKey, ProtocolMessage, ProtocolParameters,
6+
ProtocolVersion, SignedEntityType, StakeDistributionParty,
77
};
8-
use mithril_common::era_deprecate;
98
use mithril_common::messages::{
109
CertificateListItemMessage, CertificateListItemMessageMetadata, CertificateMessage,
1110
CertificateMetadataMessagePart,
1211
};
1312
#[cfg(test)]
14-
use mithril_common::test_utils::{fake_data, fake_keys};
13+
use mithril_common::{
14+
entities::{CardanoDbBeacon, ImmutableFileNumber},
15+
test_utils::{fake_data, fake_keys},
16+
};
1517
use mithril_persistence::{
1618
database::Hydrator,
1719
sqlite::{HydrationError, Projection, SqLiteEntity},
1820
};
1921

20-
era_deprecate!("Remove immutable_file_number");
2122
/// Certificate record is the representation of a stored certificate.
2223
#[derive(Debug, PartialEq, Clone)]
2324
pub struct CertificateRecord {
@@ -44,9 +45,6 @@ pub struct CertificateRecord {
4445
/// Cardano network of the certificate.
4546
pub network: String,
4647

47-
/// Immutable file number at the time the certificate was created
48-
pub immutable_file_number: ImmutableFileNumber,
49-
5048
/// Signed entity type of the message
5149
pub signed_entity_type: SignedEntityType,
5250

@@ -71,21 +69,11 @@ pub struct CertificateRecord {
7169

7270
#[cfg(test)]
7371
impl CertificateRecord {
74-
pub fn dummy_genesis(
75-
id: &str,
76-
epoch: Epoch,
77-
immutable_file_number: ImmutableFileNumber,
78-
) -> Self {
72+
pub fn dummy_genesis(id: &str, epoch: Epoch) -> Self {
7973
Self {
8074
parent_certificate_id: None,
8175
signature: fake_keys::genesis_signature()[0].to_owned(),
82-
..Self::dummy(
83-
id,
84-
"",
85-
epoch,
86-
immutable_file_number,
87-
SignedEntityType::genesis(epoch),
88-
)
76+
..Self::dummy(id, "", epoch, SignedEntityType::genesis(epoch))
8977
}
9078
}
9179

@@ -99,7 +87,6 @@ impl CertificateRecord {
9987
id,
10088
parent_id,
10189
epoch,
102-
immutable_file_number,
10390
SignedEntityType::CardanoImmutableFilesFull(CardanoDbBeacon::new(
10491
fake_data::network().to_string(),
10592
*epoch,
@@ -108,17 +95,11 @@ impl CertificateRecord {
10895
)
10996
}
11097

111-
pub fn dummy_msd(
112-
id: &str,
113-
parent_id: &str,
114-
epoch: Epoch,
115-
immutable_file_number: ImmutableFileNumber,
116-
) -> Self {
98+
pub fn dummy_msd(id: &str, parent_id: &str, epoch: Epoch) -> Self {
11799
Self::dummy(
118100
id,
119101
parent_id,
120102
epoch,
121-
immutable_file_number,
122103
SignedEntityType::MithrilStakeDistribution(epoch),
123104
)
124105
}
@@ -127,7 +108,6 @@ impl CertificateRecord {
127108
id: &str,
128109
parent_id: &str,
129110
epoch: Epoch,
130-
immutable_file_number: ImmutableFileNumber,
131111
signed_entity_type: SignedEntityType,
132112
) -> Self {
133113
Self {
@@ -138,7 +118,6 @@ impl CertificateRecord {
138118
aggregate_verification_key: fake_keys::aggregate_verification_key()[0].to_owned(),
139119
epoch,
140120
network: fake_data::network().to_string(),
141-
immutable_file_number,
142121
signed_entity_type,
143122
protocol_version: "protocol_version".to_string(),
144123
protocol_parameters: ProtocolParameters {
@@ -158,20 +137,6 @@ impl CertificateRecord {
158137
}
159138
}
160139

161-
impl CertificateRecord {
162-
era_deprecate!(
163-
"remove this method when the immutable_file_number is removed from the metadata"
164-
);
165-
/// Deduce a [CardanoDbBeacon] from this record values.
166-
fn as_cardano_db_beacon(&self) -> CardanoDbBeacon {
167-
CardanoDbBeacon::new(
168-
self.network.clone(),
169-
*self.epoch,
170-
self.immutable_file_number,
171-
)
172-
}
173-
}
174-
175140
impl From<Certificate> for CertificateRecord {
176141
fn from(other: Certificate) -> Self {
177142
let signed_entity_type = other.signed_entity_type();
@@ -182,7 +147,6 @@ impl From<Certificate> for CertificateRecord {
182147
}
183148
};
184149

185-
#[allow(deprecated)]
186150
CertificateRecord {
187151
certificate_id: other.hash,
188152
parent_certificate_id,
@@ -191,7 +155,6 @@ impl From<Certificate> for CertificateRecord {
191155
aggregate_verification_key: other.aggregate_verification_key.to_json_hex().unwrap(),
192156
epoch: other.epoch,
193157
network: other.metadata.network,
194-
immutable_file_number: other.metadata.immutable_file_number,
195158
signed_entity_type,
196159
protocol_version: other.metadata.protocol_version,
197160
protocol_parameters: other.metadata.protocol_parameters,
@@ -207,7 +170,6 @@ impl From<CertificateRecord> for Certificate {
207170
fn from(other: CertificateRecord) -> Self {
208171
let certificate_metadata = CertificateMetadata::new(
209172
other.network,
210-
other.immutable_file_number,
211173
other.protocol_version,
212174
other.protocol_parameters,
213175
other.initiated_at,
@@ -243,7 +205,6 @@ impl From<CertificateRecord> for Certificate {
243205

244206
impl From<CertificateRecord> for CertificateMessage {
245207
fn from(value: CertificateRecord) -> Self {
246-
let beacon = Some(value.as_cardano_db_beacon());
247208
let metadata = CertificateMetadataMessagePart {
248209
network: value.network,
249210
protocol_version: value.protocol_version,
@@ -258,13 +219,11 @@ impl From<CertificateRecord> for CertificateMessage {
258219
(value.signature, String::new())
259220
};
260221

261-
#[allow(deprecated)]
262222
CertificateMessage {
263223
hash: value.certificate_id,
264224
previous_hash: value.parent_certificate_id.unwrap_or_default(),
265225
epoch: value.epoch,
266226
signed_entity_type: value.signed_entity_type,
267-
beacon,
268227
metadata,
269228
protocol_message: value.protocol_message,
270229
signed_message: value.message,
@@ -277,7 +236,6 @@ impl From<CertificateRecord> for CertificateMessage {
277236

278237
impl From<CertificateRecord> for CertificateListItemMessage {
279238
fn from(value: CertificateRecord) -> Self {
280-
let beacon = Some(value.as_cardano_db_beacon());
281239
let metadata = CertificateListItemMessageMetadata {
282240
network: value.network,
283241
protocol_version: value.protocol_version,
@@ -287,13 +245,11 @@ impl From<CertificateRecord> for CertificateListItemMessage {
287245
total_signers: value.signers.len(),
288246
};
289247

290-
#[allow(deprecated)]
291248
CertificateListItemMessage {
292249
hash: value.certificate_id,
293250
previous_hash: value.parent_certificate_id.unwrap_or_default(),
294251
epoch: value.epoch,
295252
signed_entity_type: value.signed_entity_type,
296-
beacon,
297253
metadata,
298254
protocol_message: value.protocol_message,
299255
signed_message: value.message,
@@ -314,15 +270,14 @@ impl SqLiteEntity for CertificateRecord {
314270
let aggregate_verification_key = row.read::<&str, _>(4).to_string();
315271
let epoch_int = row.read::<i64, _>(5);
316272
let network = row.read::<&str, _>(6).to_string();
317-
let immutable_file_number = row.read::<i64, _>(7);
318-
let signed_entity_type_id = row.read::<i64, _>(8);
319-
let signed_entity_beacon_string = Hydrator::read_signed_entity_beacon_column(&row, 9);
320-
let protocol_version = row.read::<&str, _>(10).to_string();
321-
let protocol_parameters_string = row.read::<&str, _>(11);
322-
let protocol_message_string = row.read::<&str, _>(12);
323-
let signers_string = row.read::<&str, _>(13);
324-
let initiated_at = row.read::<&str, _>(14);
325-
let sealed_at = row.read::<&str, _>(15);
273+
let signed_entity_type_id = row.read::<i64, _>(7);
274+
let signed_entity_beacon_string = Hydrator::read_signed_entity_beacon_column(&row, 8);
275+
let protocol_version = row.read::<&str, _>(9).to_string();
276+
let protocol_parameters_string = row.read::<&str, _>(10);
277+
let protocol_message_string = row.read::<&str, _>(11);
278+
let signers_string = row.read::<&str, _>(12);
279+
let initiated_at = row.read::<&str, _>(13);
280+
let sealed_at = row.read::<&str, _>(14);
326281

327282
let certificate_record = Self {
328283
certificate_id,
@@ -336,11 +291,6 @@ impl SqLiteEntity for CertificateRecord {
336291
))
337292
})?),
338293
network,
339-
immutable_file_number: immutable_file_number.try_into().map_err(|e| {
340-
HydrationError::InvalidData(format!(
341-
"Could not cast i64 ({immutable_file_number}) to u64. Error: '{e}'"
342-
))
343-
})?,
344294
signed_entity_type: Hydrator::hydrate_signed_entity_type(
345295
signed_entity_type_id.try_into().map_err(|e| {
346296
HydrationError::InvalidData(format!(
@@ -407,11 +357,6 @@ impl SqLiteEntity for CertificateRecord {
407357
);
408358
projection.add_field("epoch", "{:certificate:}.epoch", "integer");
409359
projection.add_field("network", "{:certificate:}.network", "text");
410-
projection.add_field(
411-
"immutable_file_number",
412-
"{:certificate:}.immutable_file_number",
413-
"integer",
414-
);
415360
projection.add_field(
416361
"signed_entity_type_id",
417362
"{:certificate:}.signed_entity_type_id",
@@ -468,7 +413,7 @@ mod tests {
468413
#[test]
469414
fn converting_certificate_record_to_certificate_should_not_recompute_hash() {
470415
let expected_hash = "my_hash";
471-
let record = CertificateRecord::dummy_genesis(expected_hash, Epoch(1), 1);
416+
let record = CertificateRecord::dummy_genesis(expected_hash, Epoch(1));
472417
let certificate: Certificate = record.into();
473418

474419
assert_eq!(expected_hash, &certificate.hash);

0 commit comments

Comments
 (0)