feat: implement solver reputation score, fix slash ordering, add bond… - #153
Merged
james2177 merged 2 commits intoJul 28, 2026
Merged
Conversation
…-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
|
@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! 🚀 |
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.
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_solvertransfer-before-persist orderingProblem:
slash_solverwas doing the token transfer tofee_recipientbefore writing the updated
SolverRecordandIntentRecordtostorage. 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 beforeclient.transfer(...). Theintent state is already
Openin storage by the time any tokenmoves, so a
back-to-back call on the same
intent_idhits theIntentNotAcceptedguardimmediately.
Test added:
double_slash_second_call_rejected— callsslash_solvertwice on the same intent and asserts the second returns
Err(IntentNotAccepted).#47 — Reputation score calculation
New internal helper:
compute_reputation_score(&SolverRecord) -> u32Returns 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
New view function:
get_reputation_score(solver) -> Option<u32>— returns
Nonefor 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 3solvers
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
proptestjob runsPROPTEST_CASES=256so itdoesn't
slow down the main
contractjob.#46 —
solver_registrydesign documentNew file:
docs/solver-registry-design.mdCovers:
perks
solver
state,
intent_settlementcalls in via cross-contract calls)slash, stake,
unstake, migrate)
intent_settlementstoragegovernance)
Testing
All existing tests are unchanged. New tests are additive. Proptest
harness is
gated behind
--features testutilsand runs in its own CI job.Files changed
intent_settlement/src/lib.rscompute_reputation_score,get_reputation_scoreintent_settlement/src/test.rsintent_settlement/src/proptest_bond.rsintent_settlement/Cargo.tomlproptestdev-dependency.github/workflows/ci.ymlproptestCI jobdocs/solver-registry-design.md|