refactor(quest-engine): unify batch and single review payout logic - #110
Merged
Merged
Conversation
Extract approve_submission_inner as a shared internal helper that applies the 15% platform fee, queries the StakeVault multiplier, handles both boost (>= 100) and penalty (< 100) paths, and marks the submission Approved. review_submission and batch_review_submissions now both delegate the approval path to this helper, eliminating the duplicated flat-payout logic that previously existed in batch_review_submissions and ensuring the two paths can never drift apart. New tests added to test.rs: - test_batch_review_with_120_multiplier (boost path in batch) - test_batch_review_with_200_multiplier (large boost in batch) - test_batch_review_with_80_multiplier (penalty path in batch) - test_batch_review_mixed_multiplier_tiers (multiple learners, different tiers) - test_batch_review_fails_when_pool_cannot_cover_boost (failure case) - test_batch_review_paused_panics - test_batch_review_already_reviewed_panics All 61 tests pass; cargo fmt and clippy -D warnings clean. closes learnault#88
3 tasks
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
Resolves the parity gap between
review_submissionandbatch_review_submissionsin the QuestEngine contract.Previously,
batch_review_submissionsused a flat payout (fee + base amount) with no staking-multiplier logic. This meant bulk approvals behaved differently from individual approvals, violating the contract's intended invariants.Changes
contracts/quest-engine/src/lib.rsapprove_submission_inner— an internal helper that encapsulates the full approval flow:distribute_rewardsubmission.status = Approvedreview_submissiondelegates the approval branch to the helper (no behaviour change)batch_review_submissionsreplaces the old inline flat-payout loop with a call to the helper per learnercontracts/quest-engine/src/test.rsMockStakeVaultPerLearner: stores per-learner multipliers so mixed-tier batch tests worktest_batch_review_with_120_multiplier— boost path verified in batchtest_batch_review_with_200_multiplier— larger boost verified in batchtest_batch_review_with_80_multiplier— penalty path verified in batchtest_batch_review_mixed_multiplier_tiers— three learners each with a different tier (120×, 80×, 100×) in the same batch runtest_batch_review_fails_when_pool_cannot_cover_boost— panics when pool has insufficient balancetest_batch_review_paused_panics— pause check propagated to batchtest_batch_review_already_reviewed_panics— double-approval guard in batchAcceptance criteria
Verification
closes #88