fix: referral loop detection, clawback timelock, outbox relay, ABI snapshots - #1086
Merged
joelpeace48-cell merged 2 commits intoJul 29, 2026
Conversation
…apshots (FinesseStudioLab#729 FinesseStudioLab#743 FinesseStudioLab#746 FinesseStudioLab#784 FinesseStudioLab#790 FinesseStudioLab#799 FinesseStudioLab#803 FinesseStudioLab#805) Resolves FinesseStudioLab#743 — campaign contract: add ReferralLoop (123) and ReferralLocked (124) error variants; walk referral chain up to 10 hops in do_register to reject cycles; stamp (REFERRAL_LOCKED, participant) on first referral so re-registration cannot adopt a different referrer (sybil guard). Tests cover direct cycle, indirect 3-hop cycle, locked-referrer switch rejection, and same-referrer re-registration. Resolves FinesseStudioLab#729 — rewards contract: add ClawbackProposal contracttype and four new error variants (32–35); add propose_clawback (admin-only, returns proposal id), cancel_clawback (guardian-cancellable within timelock), and execute_clawback (anyone after CLAWBACK_TIMELOCK_LEDGERS ≈ 7 days). Replay blocked by executed flag. Tests cover propose, overbudget rejection, pre-timelock rejection, successful execution with balance/supply update, cancel-then-execute rejection, and replay. Resolves FinesseStudioLab#746 — add transactional outbox: migration 037_outbox.js creates the outbox table with optimistic locking; outboxService.js provides writeOutbox() helper and OutboxRelay class with exponential back-off; webhookService.js gains enqueueEvent(db, event) to write intents atomically alongside DB state changes. Resolves FinesseStudioLab#805 — add contract-abi-snapshot.yml CI workflow that builds WASM, exports specs via stellar contract inspect, and diffs against committed snapshots in contracts/snapshots/; fails loudly on unreviewed ABI changes. Closes FinesseStudioLab#803 — add fuzz_merkle_proof cargo-fuzz target exercising valid proofs, mutated leaves, and empty-proof rejection; register sha2 dependency in fuzz Cargo.toml. Closes FinesseStudioLab#799 — add docs/STORAGE_RENT_MODEL.md with per-entry size table, 10k-participant cost projection, TTL strategy, and operational recommendations. Closes FinesseStudioLab#784 — add chaos/inject.sh fault-injection harness (network-partition, db-latency, webhook-endpoint-down, stellar-rpc-timeout, outbox-relay-kill, high-cpu) with restore command and chaos/README.md. Closes FinesseStudioLab#790 — add frontend/src/lib/offlineQueue.ts: IndexedDB-backed offline action queue with enqueue, flush loop, exponential back-off, and online event listener.
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
ReferralLoop = 123andReferralLocked = 124. Four tests added.propose_clawback(admin-only),cancel_clawback(guardian-cancellable), andexecute_clawback(anyone after ~7-day timelock). Bounded to unclaimed balance; replay blocked byexecutedflag. Six tests added.037_outbox.js,OutboxRelayworker with exponential back-off,writeOutbox()helper, andWebhookService.enqueueEvent()to atomically write side-effects alongside state changes.contract-abi-snapshot.ymlworkflow exports contract specs viastellar contract inspectand diffs againstcontracts/snapshots/— fails on unreviewed interface changes.fuzz_merkle_proofcargo-fuzz target: valid proofs, mutated leaves, and empty-proof rejection. Registered infuzz/Cargo.tomlwithsha2dependency.docs/STORAGE_RENT_MODEL.md: per-entry size table, 10k-participant cost projection (~7.78 XLM/cycle), TTL strategy, and operational keeper recommendations.chaos/inject.shfault-injection harness: network-partition, db-latency, webhook-endpoint-down, stellar-rpc-timeout, outbox-relay-kill, high-cpu, and restore.frontend/src/lib/offlineQueue.ts: IndexedDB-backed offline action queue with flush loop, exponential back-off, andonlineevent listener.Test plan
cargo test -p trivela-campaign-contract— four new referral loop/lock tests passcargo test -p trivela-rewards-contract— six new clawback tests passcd contracts/campaign && cargo fuzz build fuzz_merkle_proofnpm run migrateinbackend/chaos/inject.sh --listprints all scenario names without errorCloses #743
Closes #729
Closes #746
Closes #805
Closes #803
Closes #799
Closes #784
Closes #790