Skip to content

fix: referral loop detection, clawback timelock, outbox relay, ABI snapshots - #1086

Merged
joelpeace48-cell merged 2 commits into
FinesseStudioLab:mainfrom
Gbangbolaoluwagbemiga:fix/issues-729-743-746-784-790-799-803-805
Jul 29, 2026
Merged

fix: referral loop detection, clawback timelock, outbox relay, ABI snapshots#1086
joelpeace48-cell merged 2 commits into
FinesseStudioLab:mainfrom
Gbangbolaoluwagbemiga:fix/issues-729-743-746-784-790-799-803-805

Conversation

@Gbangbolaoluwagbemiga

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • Campaign contract tests: cargo test -p trivela-campaign-contract — four new referral loop/lock tests pass
  • Rewards contract tests: cargo test -p trivela-rewards-contract — six new clawback tests pass
  • Fuzz target compiles: cd contracts/campaign && cargo fuzz build fuzz_merkle_proof
  • ABI snapshot CI: create a PR that changes a contract entry point and confirm the workflow fails; revert and confirm it passes
  • Outbox migration applies cleanly via npm run migrate in backend/
  • chaos/inject.sh --list prints all scenario names without error

Closes #743
Closes #729
Closes #746
Closes #805
Closes #803
Closes #799
Closes #784
Closes #790

Gbangbolaoluwagbemiga and others added 2 commits July 29, 2026 19:52
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment