Skip to content

fix(escrow): add bounds validation, issuer verification, and cleanup - #691

Merged
K1NGD4VID merged 4 commits into
TrusTrove:mainfrom
xeladev4:fix/escrow-bounds-validation-and-issuer-checks
Aug 28, 2026
Merged

fix(escrow): add bounds validation, issuer verification, and cleanup#691
K1NGD4VID merged 4 commits into
TrusTrove:mainfrom
xeladev4:fix/escrow-bounds-validation-and-issuer-checks

Conversation

@xeladev4

Copy link
Copy Markdown
Contributor

Summary

  • Add upper-bound validation for u128 to i128 casts to prevent overflow
  • Remove unused DataKey::InvoiceContract and clean up initialize() signature
  • Add issuer verification in release_to_issuer() to prevent unauthorized transfers
  • Replace raw unwrap() in usdc_client() with typed NotInitialized error

Changes

Test plan

  • Added test_lock_fails_amount_exceeds_i128_max to verify rejection of amounts > i128::MAX
  • Added test_lock_succeeds_at_i128_max to verify boundary acceptance
  • Added test_release_to_pool_fails_amount_exceeds_i128_max for release_to_pool validation
  • Added test_release_to_issuer_mismatched_address_panics to verify issuer validation
  • Updated existing tests to accommodate new lock() signature with issuer parameter
  • Updated test setup to remove unused invoice_contract parameter
  • All 50 escrow tests pass

Validation commands

cargo test -p trusttrove-escrow
cargo build --workspace

Closes #541
Closes #542
Closes #543
Closes #545

@xeladev4
xeladev4 requested a review from K1NGD4VID as a code owner August 27, 2026 23:35
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@xeladev4 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@xeladev4
xeladev4 force-pushed the fix/escrow-bounds-validation-and-issuer-checks branch 2 times, most recently from 484be82 to def87b2 Compare August 27, 2026 23:47
xeladev4 and others added 2 commits August 28, 2026 00:57
Closes TrusTrove#541, TrusTrove#542, TrusTrove#543, TrusTrove#545

- Add upper-bound validation for u128 to i128 casts to prevent overflow
- Remove unused DataKey::InvoiceContract and clean up initialize() signature
- Add issuer verification in release_to_issuer() to prevent unauthorized transfers
- Replace raw unwrap() in usdc_client() with typed NotInitialized error
- Update lock() signature to require issuer parameter
- Update release_to_pool() to use pool auth instead of invoice contract auth
- Add tests for i128::MAX boundary validation and issuer mismatch detection

Note: Pool integration tests require corresponding updates to pool contract to work with new escrow API
The escrow contract's lock() function now requires an issuer parameter
as part of the issuer verification fix. This commit updates the pool
contract's fund_invoice() function to pass the issuer address when
calling escrow.lock().

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@xeladev4
xeladev4 force-pushed the fix/escrow-bounds-validation-and-issuer-checks branch from d2e4c62 to d7857c2 Compare August 28, 2026 00:04
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@xeladev4
xeladev4 force-pushed the fix/escrow-bounds-validation-and-issuer-checks branch from 028981a to 4d2da41 Compare August 28, 2026 00:09
@K1NGD4VID
K1NGD4VID merged commit eaebb48 into TrusTrove:main Aug 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment