Skip to content

Commit

Permalink
Merge pull request input-output-hk#1337 from input-output-hk/jpraynau…
Browse files Browse the repository at this point in the history
…d/fix-certificate-chain-recompute-hashes

Fix certificate chain hashes recomputation
  • Loading branch information
jpraynaud authored Nov 10, 2023
2 parents 9bda8c1 + 30461b4 commit 38d4573
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/runbook/recompute-certificates-hash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export CARDANO_NETWORK=**CARDANO_NETWORK**

And copy the SQLite database file `aggregator.sqlite3`:
```bash
cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3 cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3.bak.$(date +%Y-%m-%d)
cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3 /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3.bak.$(date +%Y-%m-%d)
```

And connect to the aggregator container:
Expand All @@ -37,7 +37,7 @@ docker exec -it mithril-aggregator bash

Once connected to the aggregator container, recompute the certificates hashes:
```bash
/app/bin/mithril-aggregator -vvv tools recompute-certificates-hash
/app/bin/mithril-aggregator -vvvv tools recompute-certificates-hash
```

Then disconnect from the aggregator container:
Expand Down Expand Up @@ -73,7 +73,7 @@ docker stop mithril-aggregator

Then, restore the backed up database:
```bash
cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3.sqlite3.bak.$(date +%Y-%m-%d) cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator
cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3.bak.$(date +%Y-%m-%d) /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator/aggregator.sqlite3
```

Then, start the aggregator:
Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.4.5"
version = "0.4.6"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
10 changes: 8 additions & 2 deletions mithril-aggregator/src/tools/certificates_hash_migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,19 @@ impl CertificatesHashMigrator {
}

// 2 - Certificates migrated, we can insert them in the db
// (we do this by chunks in order to avoid reaching the limit of 32766 variables in a single query)
debug!("🔧 Certificate Hash Migrator: inserting migrated certificates in the database");
self.certificate_repository
.create_many_certificates(migrated_certificates)
let migrated_certificates_chunk_size = 250;
for migrated_certificates_chunk in
migrated_certificates.chunks(migrated_certificates_chunk_size)
{
self.certificate_repository
.create_many_certificates(migrated_certificates_chunk.to_owned())
.await
.with_context(|| {
"Certificates Hash Migrator can not insert migrated certificates in the database"
})?;
}

Ok((old_certificates, old_and_new_hashes))
}
Expand Down

0 comments on commit 38d4573

Please sign in to comment.