Skip to content

feat: implement milestone proof hash verification (closes #78)#148

Open
harleyakoh wants to merge 1 commit into
StellarGrant:mainfrom
harleyakoh:feat/milestone-proof-hash-verification
Open

feat: implement milestone proof hash verification (closes #78)#148
harleyakoh wants to merge 1 commit into
StellarGrant:mainfrom
harleyakoh:feat/milestone-proof-hash-verification

Conversation

@harleyakoh
Copy link
Copy Markdown

Summary

Resolves #78

Implements on-chain structured proof hash storage and format validation for milestone submissions, as described in the issue.

Changes

\ ypes.rs\

  • Added \proof_hash: Option<BytesN<32>>\ field to \Milestone\ struct for mandatory CID/commit hash storage
  • Added \proof_hash: Option<BytesN<32>>\ field to \MilestoneSubmission\ for batch submissions
  • Added \InvalidProofHash = 37\ to \ContractError\ enum

\lib.rs\

  • Updated \milestone_submit\ signature to accept \proof_hash: Option<BytesN<32>>\
  • Updated \�pply_milestone_submission\ to validate and store the hash rejects all-zero hashes ([0u8; 32]) as malformed/unset
  • Updated \milestone_submit_batch\ to forward \proof_hash\ from each \MilestoneSubmission\

\events.rs\

  • Added \MilestoneProofHashSubmitted\ event struct
  • Added \emit_milestone_proof_hash_submitted\ emitted alongside \MilestoneSubmitted\ when a valid hash is provided

\ est.rs\ + integration tests + fuzz targets

  • Updated all \Milestone\ struct constructions with \proof_hash: None\
  • Updated all \milestone_submit\ / \ ry_milestone_submit\ call sites with the new parameter
  • Added 3 new unit tests:
    • \ est_milestone_submit_with_valid_proof_hash\ valid 32-byte hash is stored correctly
    • \ est_milestone_submit_all_zero_proof_hash_rejected\ all-zero hash returns \InvalidProofHash\
    • \ est_milestone_submit_without_proof_hash_succeeds\ \None\ is accepted (hash is optional)

Notes

  • The \proof_hash\ field is optional existing flows that don't provide a hash continue to work unchanged
  • Oracle integration (future issue) can build on top of the stored \proof_hash\ field

…t#78)

- Add proof_hash: Option<BytesN<32>> field to Milestone struct in types.rs
- Add proof_hash: Option<BytesN<32>> field to MilestoneSubmission struct
- Add InvalidProofHash (error StellarGrant#37) to ContractError enum
- Update milestone_submit and apply_milestone_submission to accept and
  validate proof_hash: rejects all-zero hashes as malformed
- Add MilestoneProofHashSubmitted event in events.rs, emitted when a
  valid hash is provided on submission
- Update milestone_submit_batch to forward proof_hash from MilestoneSubmission
- Add 3 unit tests: valid hash stored, zero hash rejected, None succeeds
- Update all existing call sites and test fixtures to include proof_hash param
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.

Implement Milestone Proof Verification (e.g., IPFS/GitHub Hash check)

1 participant