Skip to content

feat: validate commitment existence in transformation entrypoints#502

Open
Glam26 wants to merge 1 commit into
Commitlabs-Org:masterfrom
Glam26:feature/transformation-commitment-check
Open

feat: validate commitment existence in transformation entrypoints#502
Glam26 wants to merge 1 commit into
Commitlabs-Org:masterfrom
Glam26:feature/transformation-commitment-check

Conversation

@Glam26

@Glam26 Glam26 commented Jun 18, 2026

Copy link
Copy Markdown

I have implemented the cross-contract commitment validation in the
commitment_transformation contract and ensured that the entire test suite is
passing.

Changes Implemented

  1. Cross-Contract Validation: Updated the load_commitment helper in
    contracts/commitment_transformation/src/lib.rs to verify that a commitment
    fetched from commitment_core has a status of "active". If the status is
    different, it now fails with TransformationError::InvalidState.
  2. Environment & Compilation Fixes:
    • Fixed a corrupted Cargo.lock (duplicate version-system entries).
    • Updated contracts/shared_utils/src/lib.rs to re-export emit_error_event
      and Validation, resolving import errors.
    • Fixed duplicate imports and missing module declarations for tests and
      mocks in commitment_transformation.
  3. Mock Core Stabilization:
    • Updated MockCommitmentCore to return a full CoreCommitment equivalent,
      ensuring compatibility with the contract's expected data types.
    • Implemented deterministic ownership in the mock core to satisfy
      existing test assertions.
    • Registered the mock core contract in both tests.rs and
      invalid_state_tests.rs setup helpers.
  4. Verification:
    • Added a new test case test_create_tranches_with_expired_commitment in
      invalid_state_tests.rs to verify that transformations on non-active
      commitments are rejected.
    • Confirmed that all 64 tests in the commitment_transformation crate pass
      successfully.
  5. Documentation:
    • Updated docs/COMMITMENT_TRANSFORMATION_AUTHORIZATION.md to include
      status checks in the cross-contract call notes.
    • Updated docs/RISK_TRANCHES.md to explicitly list the "active" status
      requirement for tranche creation.

Commit Summary
I have committed the changes to the feature/transformation-commitment-check
branch with the message:
feat: validate commitment existence in transformation entrypoints

All tests can be verified by running:
1 cargo test -p commitment_transformation --lib

closes #474

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.

Add cross-contract commitment existence check to commitment_transformation::create_tranches

2 participants