feat(contract): implement bounded resumable settlement and void refunds (closes #359) - #372
Open
ranjeet150 wants to merge 1 commit into
Open
ranjeet150 wants to merge 1 commit into
ranjeet150 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #359.
Implements a bounded, resumable settlement and void refund protocol on the Soroban contract and updates client/orchestration tooling. Rounds supporting up to 500 bidders can now be settled or voided incrementally across bounded transaction batches without exceeding Soroban execution and memory limits.
Architectural Changes
Explicit Payout Progress & Invariant Conservation:
PayoutProgressstruct: trackingcursor,total_bidders,paid_amount,remaining_obligations, andcompleted.2076271\text{total_escrow} = \text{paid_amount} + \text{remaining_obligations}2076271
SettledorVoidedoccurs if and only if all obligations are 100% completed (remaining_obligations == 0).Frozen Clearing & Idempotency:
settledflag onBidState.Resumable Keeper Orchestration:
settle_batch(round_id, cursor, limit),void_batch(round_id, cursor, limit), andget_payout_progress(round_id).settleandvoiddelegate to batch execution.settleBatch,voidBatch,getPayoutProgress,settleAll,voidAll, and preflight simulations.cursor.Error Handling & Drift Guarding:
InvalidCursor = 40(code 40 in 30-49 data/input range).ERRORS.mdand synchronized with TypeScript bindings and automated drift checks.Verification & Testing Proof
cargo test -p sub-rosa-round).max_500_bidder_bounded_settlement_resource_regression: Verified bounded settlement of 500 bidders across 10 batches with recorded instruction budgets well within Stellar Protocol 20/21/22 single-transaction limits (100M CPU, 40MB memory).bounded_settlement_multi_batch_conservation_and_short_batchbounded_settlement_repeated_and_overlapping_batchesbounded_settlement_invalid_cursors_and_limitsbounded_settlement_zero_surplusbounded_void_multi_batch_and_conservationresumable_settlement_interrupted_keeper_simulationcargo clippy -p sub-rosa-round -- -D warnings: 0 warnings, 0 errors.cargo fmt --check: 100% clean formatting.packages/round-bindings: 17/17 tests pass;tsc --noEmitclean.packages/sdk: 213/213 tests pass;tsc --noEmitclean.services/keeper: 73/73 tests pass.packages/tlock: 67/67 tests pass.scripts/check-round-errors: 5/5 tests pass.