Skip to content

feat: nullifier re-registration barrier, solvency monitor, proof-of-reserves page, ZK proof SDK - #1087

Merged
joelpeace48-cell merged 1 commit into
FinesseStudioLab:mainfrom
anuoluwaponiorimi:feat/solvency-monitor-proof-reserves-zk-sdk-nullifier-740-847-874-956
Jul 29, 2026
Merged

feat: nullifier re-registration barrier, solvency monitor, proof-of-reserves page, ZK proof SDK#1087
joelpeace48-cell merged 1 commit into
FinesseStudioLab:mainfrom
anuoluwaponiorimi:feat/solvency-monitor-proof-reserves-zk-sdk-nullifier-740-847-874-956

Conversation

@anuoluwaponiorimi

Copy link
Copy Markdown
Contributor

Summary

  • Contracts: Nullifier to prevent re-registration / double-claim after merkle root rotation #740 – Nullifier barrier against re-registration after root rotation: Add a PARTICIPATED persistent storage key in the campaign contract's register() path that is set on first successful registration and is never cleared by deregister(). Any subsequent register() call from the same address returns NullifierAlreadyUsed, even after deregistration or merkle root rotation — eliminating referral-count inflation from de/re-register cycles. Two new admin functions: clear_participation() (explicit opt-in to allow re-registration for a specific address) and has_participated() (view). Five new tests cover marker set, persist-after-deregister, re-register block, admin clear, and root-rotation scenarios.
  • Contract health/solvency monitor with alerting (reserve < liabilities) #874 – Contract solvency monitor with alerting: New SolvencyMonitorService NestJS service that exports four Prometheus Gauges (trivela_contract_reserve_xlm, trivela_contract_liabilities_xlm, trivela_solvency_ratio, trivela_contract_ttl_ledgers) and polls every 60 s. Logs WARN on shortfall or low TTL. Four new Prometheus alert rules in alerting_rules.yml: ContractSolvencyShortfall (critical, ratio < 1.0, 2 m), ContractSolvencyLow (warning, ratio < 1.1, 10 m), ContractTtlLow (warning, < 50 000 ledgers, 5 m), ContractTtlExpired (critical, == 0, immediate).
  • Transparency report + on-chain proof-of-reserves page #956 – Proof-of-reserves page: New ProofOfReserves React page at /proof-of-reserves that polls /api/v1/reserves/snapshot every 60 s and displays reserve, liabilities, solvency ratio, and contract TTL as metric cards with a colour-coded status badge. Includes an independent-verification guide pointing users to Stellar Expert and the Soroban RPC. Lazy-loaded in App.jsx.
  • Off-chain proof-generation SDK (WASM) for browser claim flows #847 – ZK proof SDK scaffolding: sdk/client/src/zk/ — typed ClaimProofInputs / ClaimProof interfaces (types.ts), generateClaimProof() public API that spawns a Web Worker so the main thread stays responsive (index.ts), proof.worker.ts with a stub prover stub and progress reporting (replace the inner loadProver() return with the real circom/snarkjs WASM build), and isZkSupported() environment check.

Test plan

  • cargo test -p trivela-campaign-contract — five new #[test] functions pass; existing tests unaffected (no signature changes)
  • Double-register attempt after deregister() returns NullifierAlreadyUsed
  • clear_participation() followed by register() succeeds; subsequent re-register is blocked again
  • GET /metrics exposes all four solvency Gauges; simulating liabilities > reserve fires ContractSolvencyShortfall alert in Prometheus
  • /proof-of-reserves page loads, displays metric cards, and auto-refreshes every 60 s
  • generateClaimProof(inputs, { onProgress }) resolves with a ClaimProof and emits progress events 0 → 100

Closes #740
Closes #874
Closes #956
Closes #847

… proof SDK

- FinesseStudioLab#740: Add per-participant PARTICIPATED persistent storage key to
  campaign register() that survives deregistration and merkle root
  rotations; returns NullifierAlreadyUsed on re-register attempts.
  Add clear_participation() and has_participated() admin/view functions.
  Five new tests covering marker set/persist/block/clear/rotation flows.
- FinesseStudioLab#874: New SolvencyMonitorService with Prometheus Gauges for reserve,
  liabilities, solvency ratio, and contract TTL; polls every 60s and
  logs WARN on shortfall or low TTL. Four new alert rules added to
  alerting_rules.yml: ContractSolvencyShortfall (critical, <1.0),
  ContractSolvencyLow (warning, <1.1), ContractTtlLow (warning,
  <50k ledgers), ContractTtlExpired (critical, ==0).
- FinesseStudioLab#956: ProofOfReserves React page at /proof-of-reserves; polls
  /api/v1/reserves/snapshot every 60s, shows reserve/liabilities/
  solvency-ratio/TTL metric cards with status badge, auto-refresh,
  and an independent-verification guide. Lazy-loaded in App.jsx.
- FinesseStudioLab#847: ZK proof SDK scaffolding in sdk/client/src/zk/ — typed
  ClaimProofInputs/ClaimProof interfaces, generateClaimProof() public
  API that delegates to a Web Worker, proof.worker.ts stub prover with
  progress reporting, and isZkSupported() environment check.

Closes FinesseStudioLab#740
Closes FinesseStudioLab#874
Closes FinesseStudioLab#956
Closes FinesseStudioLab#847
return proverReady;
}

self.onmessage = async (event: MessageEvent) => {
@joelpeace48-cell
joelpeace48-cell merged commit 40cd609 into FinesseStudioLab:main Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants