Repository navigation
feat(contract): implement anti-frontrunning commit-reveal mechanism for competitive payroll bounties (#212) - #214
Open
markankamaransheogarat-sys wants to merge 2 commits into
Conversation
…or competitive payroll bounties (Orbit-xyz#212) - Add BountyData and BountyCommitment contract types for competitive task escrows - Add DataKey variants: NextBountyId, Bounty(u64), BountyCommitment(u64, Address) - Implement create_bounty to escrow reward tokens against a target solution hash - Implement commit_bounty_claim storing commitment hash binding claimant address, proof, and secret salt - Enforce BOUNTY_CHALLENGE_DELAY_LEDGERS (5 ledgers) delay window to eliminate mempool copy-paste frontrunning - Implement reveal_bounty_claim to verify preimage, validate solution hash, and dispatch payout to claimant - Implement reclaim_bounty for creator recovery of expired unclaimed bounties - Add public getters get_bounty, get_bounty_commitment, and pure helper compute_bounty_commitment_hash - Implement comprehensive unit test suite in test.rs covering happy path, early reveal rejection, frontrunning resistance, tampered preimages, invalid solutions, double-claim protection, and expired reclaim - Fix baseline test delimiters and lending pool client address call so all 134 soroban tests pass cleanly
|
@markankamaransheogarat-sys is attempting to deploy a commit to the Abdqoharr Olayiwola's projects Team on Vercel. A member of the Team first needs to authorize it. |
5 tasks
This branch has not been deployed
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 #212.
Implements a cryptographic two-phase commit-reveal claim scheme with an enforced challenge delay window for competitive payroll bounties on Stellar/Soroban. This mechanism prevents mempool frontrunning bots from observing valid bounty solutions/proofs, extracting preimages, and frontrunning legitimate contributors with higher gas fees.
Architectural Design & Threat Model
Commit Phase (
commit_bounty_claim):commitment_hash = SHA256(claimant || proof || secret_salt).BountyCommitment { claimant, commitment_hash, commit_ledger }with state extension TTL.claimant. Even if a bot attempts to copy the commitment hash under the bot's address, the preimage check will fail upon reveal.Challenge Delay Window (
BOUNTY_CHALLENGE_DELAY_LEDGERS = 5):current_ledger >= commitment.commit_ledger + 5(~25 seconds).Reveal Phase (
reveal_bounty_claim):proofandsecret_salt.claimantandcommitment.claimant == claimant.SHA256(claimant || proof || secret_salt) == commitment.commitment_hash.SHA256(proof) == bounty.solution_hash.claimant, marks bounty claimed, and emitsbounty_claimedevent.Lifecycle & Reclamation (
reclaim_bounty,get_bounty,get_bounty_commitment):expiration_timestamp.compute_bounty_commitment_hashfor off-chain and frontend dApp integration.Acceptance Criteria Checklist
test_frontrunning_bot_mempool_copy_fails).test_reveal_bounty_claim_before_challenge_delay_fails,test_bounty_reveal_challenge_delay_panics_with_message).test_tampered_proof_or_salt_panics,test_invalid_solution_hash_fails,test_bounty_reveal_invalid_preimage_panics_with_message,test_bounty_reveal_without_commitment_panics).test_bounty_cannot_be_claimed_twice,test_bounty_reclaim_after_expiration).contracts/soroban/src/test.rs: 8 dedicated tests covering full commit-reveal lifecycle, challenge delay, attack vectors, and edge cases.cargo testpasses cleanly: All 134 tests pass 100% green (134 passed; 0 failed; 0 ignored).