Skip to content

Persist and enforce a single canonical max escrow cap across create_contract and deposit #331

@mikewheeleer

Description

@mikewheeleer

Description

lib.rs defines two conflicting caps: MAX_TOTAL_ESCROW_STROOPS = 10_000_000_000_000 (enforced in create_contract) and MAINNET_MAX_TOTAL_ESCROW_PER_CONTRACT_STROOPS = 1_000_000_000_000_000 (reported by get_mainnet_readiness_info but never enforced). amount_validation.rs adds a third bound MAX_SINGLE_AMOUNT_STROOPS. Consolidate to one enforced, governable cap to avoid silent mismatch between reported and enforced limits.

Requirements and context

  • Scoped to TalentTrust escrow Soroban contract (contracts/escrow).
  • Choose a single canonical per-contract cap, enforce it in create_contract and as the ceiling in deposit_funds, and have get_mainnet_readiness_info report the same value.
  • Document the relationship between per-contract cap and amount_validation::MAX_SINGLE_AMOUNT_STROOPS.
  • Invariant: the cap reported by readiness equals the cap enforced at create/deposit time.
  • Must be secure, tested, and documented.

Suggested execution

  • Fork the repo and create a branch:
    • git checkout -b security/canonical-escrow-cap
  • Implement changes:
    • contracts/escrow/src/lib.rs
    • Tests: contracts/escrow/src/test/mainnet_readiness.rs
    • Docs: docs/escrow/mainnet-readiness.md
    • Include rustdoc/NatSpec-style doc comments on public functions
    • Validate security assumptions (auth, overflow, fail-closed state machine, storage TTL, fee accounting)

Test and commit

  • Run tests: cargo test
  • Cover edge cases (unauthorized callers, double release/refund, expired approvals, fee rounding, paused state)
  • Include test output and security notes in the PR

Example commit message

fix(escrow): unify enforced and reported escrow caps

Guidelines

  • Minimum 95% test coverage on new/changed code
  • Clear documentation
  • Timeframe: 96 hours from assignment

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions