-
Notifications
You must be signed in to change notification settings - Fork 44
List invalid or tampered immutable files in verify command #2637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
List invalid or tampered immutable files in verify command #2637
Conversation
Test Results 4 files ± 0 154 suites ±0 23m 37s ⏱️ +18s Results for commit 9eaf920. ± Comparison against base commit 2ab36d3. This pull request removes 1 and adds 17 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
48bf6a1
to
68915c2
Compare
68915c2
to
169a685
Compare
6a98b96
to
2af282f
Compare
54a2b7c
to
cc140f0
Compare
2eae876
to
65218e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the Cardano database snapshot verification by listing missing or tampered immutable files instead of failing silently. It refactors the digest download and Merkle-proof verification into a unified flow, introduces detailed error types with file listings, and updates the CLI to surface these details in both JSON and human-readable formats.
- Refactored
compute_merkle_proof
intodownload_and_verify_digests
, returningVerifiedDigests
(digest map + Merkle tree). - Extended
MessageBuilder::compute_cardano_database_message
to acceptVerifiedDigests
, handle anallow_missing
flag, and return rich error information (ImmutableFilesLists
). - Updated CLI commands to write JSON error files and print counts of missing/tampered files.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
mithril-client/tests/cardano_db_snapshot_list_get_download_verify.rs | Updated tests to use download_and_verify_digests and VerifiedDigests . |
mithril-client/src/message.rs | Added ImmutableFilesLists , ComputeCardanoDatabaseMessageError , and enhanced compute_cardano_database_message . |
mithril-client/src/cardano_database_client/proving.rs | Replaced compute_merkle_proof with download_and_verify_digests returning VerifiedDigests . |
mithril-client/src/cardano_database_client/api.rs | Updated public API to expose download_and_verify_digests . |
mithril-client-cli/src/commands/cardano_db/verify.rs | Integrated new error handling in the verify command and JSON output. |
65218e9
to
b33c6f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐎
let options = ComputeCardanoDatabaseMessageOptions { | ||
db_dir: restoration_options.db_dir.clone(), | ||
immutable_file_range: restoration_options.immutable_file_range, | ||
allow_missing: false, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be part of the client library directly to reduce the number of arguments of compute_cardano_database_message
.
2776820
to
69aaf2e
Compare
ceed11c
to
75988a6
Compare
} | ||
|
||
#[tokio::test] | ||
async fn download_and_verify_digest_should_return_digest_map_acording_to_beacon() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async fn download_and_verify_digest_should_return_digest_map_acording_to_beacon() { | |
async fn download_and_verify_digest_should_return_digest_map_according_to_beacon() |
pub async fn compute_cardano_database_message( | ||
&self, | ||
certificate: &MithrilCertificate, | ||
merkle_proof: &MKProof, | ||
) -> MithrilResult<ProtocolMessage> { | ||
let mut message = certificate.protocol_message.clone(); | ||
message.set_message_part( | ||
ProtocolMessagePartKey::CardanoDatabaseMerkleRoot, | ||
merkle_proof.root().to_hex(), | ||
); | ||
certificate: &CertificateMessage, | ||
cardano_database_snapshot: &CardanoDatabaseSnapshotMessage, | ||
immutable_file_range: &ImmutableFileRange, | ||
allow_missing: bool, | ||
database_dir: &Path, | ||
verified_digests: &VerifiedDigests, | ||
) -> Result<ProtocolMessage, ComputeCardanoDatabaseMessageError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the proving part (Merkle proof computation) should be kept in the proving
module.
Also this function is too complex (too many inputs and lines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as you see we now have added three new parameters since verified_digests are a dedicated step (that was previously done by compute_merkle_proof) so we need digests, range, and allow_missing flag. They may be reorganize in a struct ?
if we keep compute_merkle_proof in the proving.rs file has a exposed method for API, we will have to decide where to put the listing of missing immutable files and also the verification of the proof (tampered and non verifiable files)
feabf8c
to
6c220c5
Compare
…ests and verified them against certificate
…de the snapshotmessage computation
…d to compute_cardano_database_message
…ano database message with a structured error
… immutables files
…red immutables files in case of ImmutableFilesVerification error
…o handle the new typed error
verify command fail
…rdano_database_message function
…f proof computation error
…verification result
…, fix dummy tool import
6c220c5
to
9eaf920
Compare
Content
improve client library and CLI for verify command to list missing, tampered and/or non verifiable files
Pre-submit checklist
Comments
Issue(s)
Closes #2618