File: /src/soroban/tx_state.rs
Category: Soroban / Transactions
Description: The TxStateController implements a two-phase commit pattern but has no actual compensation logic. When a Soroban contract call fails after the database state has been updated, there is no automatic rollback of the database changes. The current implementation merely sets status flags — it does not execute compensating transactions.
Parameters:
- Settlements per batch: up to 500 resource transfers
- DB rollback window: 30 seconds after failure
- Compensating transaction timeout: 60 seconds
- Consistency model: atomic (all-or-nothing)
Codebase Navigation:
src/soroban/tx_state.rs:28 — TwoPhaseCommit — has db_state_backup but never populated
src/soroban/tx_state.rs:45 — commit — no actual commit logic
src/soroban/tx_state.rs:56 — rollback — no compensating transaction
Resolution Blueprint:
- Implement actual prepare phase: before executing a Soroban settlement, snapshot the relevant database rows (resource balances, deduction records) and store the snapshot in the
db_state_backup field
- Implement actual commit phase: after successful Soroban execution, mark the transaction as committed and delete the backup snapshot
- Implement actual rollback phase: on failure, restore the database state from the backup snapshot and submit a compensating Soroban transaction (if the on-chain state was partially modified)
- Add a background
TxReaper task that periodically scans for transactions in Pending state for more than 30 seconds and automatically rolls them back
- Expose
GET /api/v1/soroban/transactions showing all transactions and their current state with timestamps
Acceptance Criteria:
File:
/src/soroban/tx_state.rsCategory: Soroban / Transactions
Description: The
TxStateControllerimplements a two-phase commit pattern but has no actual compensation logic. When a Soroban contract call fails after the database state has been updated, there is no automatic rollback of the database changes. The current implementation merely sets status flags — it does not execute compensating transactions.Parameters:
Codebase Navigation:
src/soroban/tx_state.rs:28—TwoPhaseCommit— hasdb_state_backupbut never populatedsrc/soroban/tx_state.rs:45—commit— no actual commit logicsrc/soroban/tx_state.rs:56—rollback— no compensating transactionResolution Blueprint:
db_state_backupfieldTxReapertask that periodically scans for transactions inPendingstate for more than 30 seconds and automatically rolls them backGET /api/v1/soroban/transactionsshowing all transactions and their current state with timestampsAcceptance Criteria: