Skip to content

feat: implement solver reputation score, fix slash ordering, add bond… - #153

Merged
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
solarix-x:feat/solver-reputation-score
Jul 28, 2026
Merged

feat: implement solver reputation score, fix slash ordering, add bond…#153
james2177 merged 2 commits into
stellar-vortex-protocol:mainfrom
solarix-x:feat/solver-reputation-score

Conversation

@solarix-x

Copy link
Copy Markdown
Contributor

Title:

feat: solver reputation score, slash ordering fix, bond-conservation
proptest, solver-registry design

─────────────────────────────────────────────────────────────────────

Description:

Closes #29, Closes #43, Closes #47, Closes #46

Summary

Four issues tackled in one pass — they share the same data model and
touching
lib.rs once is cleaner than four separate PRs with merge conflicts.


#29 — Fix slash_solver transfer-before-persist ordering

Problem: slash_solver was doing the token transfer to
fee_recipient
before writing the updated SolverRecord and IntentRecord to
storage. Since
the function is permissionless, a caller could (in theory) exploit
the gap
between the transfer and the state commit.

Fix: Both .set(...) calls now happen before
client.transfer(...). The
intent state is already Open in storage by the time any token
moves, so a
back-to-back call on the same intent_id hits the
IntentNotAccepted guard
immediately.

Test added: double_slash_second_call_rejected — calls
slash_solver
twice on the same intent and asserts the second returns
Err(IntentNotAccepted).


#47 — Reputation score calculation

New internal helper: compute_reputation_score(&SolverRecord) -> u32

Returns a score in 0–9 999 basis points derived from existing
fill history:

base = fills_completed / (fills_completed + fills_failed) [success
rate]
decay = VOLUME_SCALE / (VOLUME_SCALE + total_volume + 1) [volume
factor]
score = base × (1 − 0.1 × decay) × 10 000

  • Zero attempts → 0. All failures → 0.
  • Perfect solver with no volume → 9 000 bps (90%).
  • Perfect solver with high volume → approaches 10 000 bps.
  • All arithmetic is integer-only; no panics possible.

New view function: get_reputation_score(solver) -> Option<u32>
— returns
None for unregistered solvers.

Tests added: zero fills, all failures, perfect+no volume,
perfect+high
volume, partial failures vs perfect, unregistered solver, post-fill
score.


#43 — Bond-conservation invariant proptest

New dev-dependency: proptest = "1.5.0"

New file: src/proptest_bond.rs — a state-machine harness with 3
solvers
and up to 20 random steps per run (register, deregister, withdraw,
accept+slash).

After every step it asserts:

contract.bond_balance == Σ solver_record.bond_amount

CI: New dedicated proptest job runs PROPTEST_CASES=256 so it
doesn't
slow down the main contract job.


#46solver_registry design document

New file: docs/solver-registry-design.md

Covers:

  • Reputation score formula (carries forward from Implement reputation score calculation from existing SolverRecord fill history #47)
  • 5-tier table (Unranked → Platinum) with min bond, min score, and
    perks
  • Contract boundary analysis — recommends Option A (registry owns
    solver
    state, intent_settlement calls in via cross-contract calls)
  • Full cross-contract interface (eligibility check, record_fill,
    slash, stake,
    unstake, migrate)
  • Fill-window extension and reduced slash % mechanics per tier
  • One-time migration plan from existing intent_settlement storage
  • Open questions (fee rebate %, tier downgrade timing, NFT badges,
    governance)

Testing

All existing tests are unchanged. New tests are additive. Proptest
harness is
gated behind --features testutils and runs in its own CI job.

Files changed

File Change
intent_settlement/src/lib.rs slash ordering fix,
compute_reputation_score, get_reputation_score
intent_settlement/src/test.rs double-slash test, reputation
score tests
intent_settlement/src/proptest_bond.rs new — bond-conservation
harness
intent_settlement/Cargo.toml add proptest dev-dependency
.github/workflows/ci.yml add proptest CI job
docs/solver-registry-design.md new — solver registry design doc

|

…-conservation proptest, add solver-registry design doc

- fix(stellar-vortex-protocol#29): reorder slash_solver to persist SolverRecord and IntentRecord
  before the token transfer; add double-slash regression test
- feat(stellar-vortex-protocol#47): add compute_reputation_score() helper (0-9999 bps, weighted
  success rate with volume bonus) and get_reputation_score() view; add
  edge-case tests (zero fills, all failures, perfect rate, mixed)
- test(stellar-vortex-protocol#43): add proptest dev-dependency; implement bond-conservation
  state-machine harness (proptest_bond.rs); add dedicated CI job
- docs(stellar-vortex-protocol#46): add docs/solver-registry-design.md covering 5 tiers, staking
  math, cross-contract interface (Option A), migration plan, open questions

Closes stellar-vortex-protocol#29, Closes stellar-vortex-protocol#47, Closes stellar-vortex-protocol#43, Closes stellar-vortex-protocol#46
@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@solarix-x Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@james2177
james2177 merged commit b6a3e4d into stellar-vortex-protocol:main Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants