Add multiple verification levels to read_ledger.py#7674
Conversation
…iple verification levels Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
|
@copilot Python's |
…port Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
…sinstance check - Add transaction_count to LedgerValidator to track all processed transactions - Remove unnecessary isinstance check (verification_level is always VerificationLevel) - Fold "Verification level:" into verification result message - Show appropriate information based on level: transactions for OFFSETS/HEADERS, transactions+signatures+txid for MERKLE/FULL - Make last_verified_txid() only appear when it's meaningful (MERKLE/FULL levels) Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
…NONE Individual ledger chunks can be parsed with verification levels up to MERKLE. Only FULL verification requires complete ledger context (for node certificates, service status transitions, etc.). Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
- Fixed MERKLE level to properly deserialize mini-tree from tables["public:ccf.internal.tree"] - Added TREE_TABLE_NAME constant for "public:ccf.internal.tree" - First signature now correctly initializes merkle tree using deserialise() method - Removed merkle tree validation from run_read_ledger_on_testdata (moved to dedicated test) - Added test_merkle_verification_level() to explicitly test MERKLE verification on: - Full ledgers (all testdata directories) - Isolated chunks with multiple signatures (ledger_29-46, ledger_44-64) - Removed MerkleTree import from e2e_operations.py (no longer needed) Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements multiple verification levels for the read_ledger.py utility, allowing users to control the trade-off between verification thoroughness and computation cost. The implementation introduces five verification levels (NONE, OFFSETS, HEADERS, MERKLE, FULL) with FULL being the default, maintaining backward compatibility with existing code.
Changes:
- Added
VerificationLevelIntEnum with five levels of increasing verification rigor - Implemented offset table and transaction header validation methods
- Implemented MERKLE verification level using
merkletree.deserialise()to support isolated chunk verification - Updated CLI to accept
--verification-levelparameter while maintaining backward compatibility with deprecated--insecure-skip-verificationflag
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| python/src/ccf/ledger.py | Added VerificationLevel enum, validation methods, and MERKLE verification logic with proper tree deserialization |
| python/src/ccf/read_ledger.py | Updated CLI to support verification levels with backward compatibility and contextual output messages |
| tests/e2e_operations.py | Removed duplicate merkle tree validation and added dedicated test for MERKLE verification level |
| doc/audit/python_library.rst | Added comprehensive documentation for verification levels with usage examples |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot Add a description of this change to CHANGELOG.md, and rewrite this PR's description to be briefer (summarise, don't list every change). |
Co-authored-by: eddyashton <6000239+eddyashton@users.noreply.github.com>
Done in commit aef3642:
|
Add Multiple Verification Levels to read_ledger.py
This PR implements granular verification levels for the
read_ledger.pytool, allowing users to control the trade-off between verification thoroughness and computation cost.Changes
Added
VerificationLevelenum with five levels (ordered by increasing cost):merkletree.deserialise())Updated
read_ledger.pyCLI:--verification-leveloption (choices: NONE, OFFSETS, HEADERS, MERKLE, FULL)--insecure-skip-verification(maps to NONE for backward compatibility)Updated
LedgerValidator:verification_levelparameter (defaults to FULL)transaction_countfor better reportingDocumentation: Added verification levels section to
doc/audit/python_library.rstwith usage examplesTesting: Added
test_merkle_verification_level()to validate MERKLE verification on full ledgers and isolated chunksBackward Compatibility
✅ Default behavior unchanged (FULL verification)
✅
--insecure-skip-verificationstill works (deprecated)✅ Existing code using
LedgerValidator()continues to workVerification Levels & Isolated Chunks
Original prompt
read_ledger.py#7502💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.