Skip to content

Feat/deterministic batch operation ordering (#553)#694

Open
Chucks1093 wants to merge 2 commits intoJagadeeshftw:masterfrom
Chucks1093:feat/deterministic-batch-operation-ordering
Open

Feat/deterministic batch operation ordering (#553)#694
Chucks1093 wants to merge 2 commits intoJagadeeshftw:masterfrom
Chucks1093:feat/deterministic-batch-operation-ordering

Conversation

@Chucks1093
Copy link
Contributor

Closes #553

Changes

  • contracts/bounty_escrow/contracts/escrow/src/lib.rs

    • Added deterministic ordering helpers for batch items:
      • order_batch_lock_items (sort by bounty_id, ascending)
      • order_batch_release_items (sort by bounty_id, ascending)
    • Updated batch_lock_funds and batch_release_funds to process ordered_items instead of caller-provided order.
    • Added explicit # Ordering Guarantee docs to both batch functions.
    • Preserved existing CEI structure and atomic behavior (all-or-nothing semantics unchanged).
  • soroban/contracts/program-escrow/src/lib.rs

    • Added deterministic ordering helper:
      • order_batch_registration_items (sort by program_id, ascending)
    • Updated batch_register_programs to run validation, duplicate checks, auth collection, and execution over sorted input.
    • Added # Ordering Guarantee docs to batch_register_programs.
  • contracts/bounty_escrow/contracts/escrow/src/test.rs

    • Added test_batch_lock_funds_deterministic_ordering_by_bounty_id
    • Added test_batch_release_funds_deterministic_ordering_by_bounty_id
    • These assert consistent results when caller input is intentionally unsorted.
  • soroban/contracts/program-escrow/src/test.rs

    • Added test_batch_register_order_independent_results
    • Verifies that different input orders produce equivalent final state.
    • Also removed an accidental stray prepended test scaffold that was unrelated and causing duplicate-import/undefined-type compile errors.

Deterministic Ordering Guarantee

Batch operations covered in this PR now execute in deterministic, contract-defined order independent of caller input:

  • batch_lock_funds -> ascending bounty_id
  • batch_release_funds -> ascending bounty_id
  • batch_register_programs -> ascending program_id

This reduces input-order ambiguity and improves reproducibility across clients/indexers.

Testing

Executed locally:

  • contracts/bounty_escrow/contracts/escrow

    • cargo test --lib -- --nocapture -> 517 passed
    • targeted deterministic ordering tests -> passed
  • soroban/contracts/program-escrow

    • cargo test --lib -- --nocapture -> 24 passed
    • targeted order-independence test -> passed

Notes

  • contracts/program-escrow (top-level, non-soroban path) currently has pre-existing syntax errors (unclosed/mismatched delimiters) and fails to compile independently; this PR does not modify that crate.
  • Scope is intentionally limited to batch entrypoints that compile and are active in the touched modules.

@vercel
Copy link

vercel bot commented Feb 26, 2026

@Chucks1093 is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Jagadeeshftw
Copy link
Owner

please resolve the conflicts

@Chucks1093
Copy link
Contributor Author

Okay on it

- Expanded traits.rs: added PauseInterface and FeeInterface with full
  doc comments referencing Grainlify internal spec
- BountyEscrowContract now formally implements all four traits
  (EscrowInterface, UpgradeInterface, PauseInterface, FeeInterface)
- soroban/contracts/escrow: added local EscrowInterface + UpgradeInterface
  trait definitions and implementations; added get_balance and
  get_escrow_info to satisfy standard surface
- grainlify-core: added local UpgradeInterface trait and impl for
  GrainlifyContract (feature-gated to match existing contract gate)
- contracts/view-facade: implemented ViewFacade contract with
  register/deregister/list/get_contract for cross-contract discovery
@Chucks1093 Chucks1093 force-pushed the feat/deterministic-batch-operation-ordering branch from f96a7c9 to fdd7ece Compare February 26, 2026 09:46
@Chucks1093
Copy link
Contributor Author

@Jagadeeshftw can you quickly merge?

@Jagadeeshftw
Copy link
Owner

@Chucks1093 Can you please resolve the conflicts?

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.

Enforce Deterministic Ordering for Batch Operations

2 participants