Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@patrick-ogrady
Copy link
Contributor

No description provided.

@patrick-ogrady patrick-ogrady requested a review from Copilot July 14, 2025 00:09
Copy link
Contributor

Copilot AI left a 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 migrates the Binary Merkle Tree (BMT) proof serialization to use the commonware_codec traits instead of custom methods, and updates fuzz targets accordingly.

  • Implement Write, Read, and EncodeSize for Proof<H> and remove old serialize/deserialize methods
  • Introduce a MAX_SIBLINGS bound and switch tests/fuzz targets to encode/decode
  • Add commonware-codec as a dependency in the fuzz workspace

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
storage/src/bmt/mod.rs Added codec trait impls for Proof, removed custom (de)serializers
storage/fuzz/fuzz_targets/bmt_operations.rs Updated fuzz targets to use .encode()/.decode()
storage/fuzz/Cargo.toml Added commonware-codec to dependencies
Comments suppressed due to low confidence (2)

storage/src/bmt/mod.rs:741

  • Add a unit test to cover decoding a proof with more than MAX_SIBLINGS entries to ensure the bound is enforced, e.g.:
#[test]
fn decode_too_many_siblings() {
    let mut serialized = Vec::new();
    // write length prefix > MAX_SIBLINGS
    serialized.extend(((MAX_SIBLINGS + 1) as u64).encode());
    serialized.extend(vec![0u8; (MAX_SIBLINGS + 1) * Sha256::Digest::SIZE]);
    let mut buf = serialized.as_slice();
    assert!(Proof::<Sha256>::decode(&mut buf).is_err());
}
    #[test]

storage/src/bmt/mod.rs:40

  • [nitpick] Update module-level documentation to explain that proofs are now length-prefixed via commonware_codec rather than raw concatenation, so consumers understand the new wire format.
//! assert!(proof.verify(&mut hasher, &digests[1], 1, &root).is_ok());

@patrick-ogrady patrick-ogrady merged commit dcf2a15 into main Jul 14, 2025
26 of 30 checks passed
@patrick-ogrady patrick-ogrady deleted the bmt-codec-proof branch July 14, 2025 00:24
@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.04%. Comparing base (b9858d2) to head (49adafe).
Report is 1 commits behind head on main.

@@           Coverage Diff           @@
##             main    #1270   +/-   ##
=======================================
  Coverage   91.03%   91.04%           
=======================================
  Files         245      245           
  Lines       59775    59760   -15     
=======================================
- Hits        54419    54409   -10     
+ Misses       5356     5351    -5     
Files with missing lines Coverage Δ
storage/src/bmt/mod.rs 97.14% <100.00%> (+0.53%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9858d2...49adafe. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant