Skip to content

Implement exponential decay model for reputation scores 395#661

Open
Stanley-Owoh wants to merge 13 commits into
DXmakers:mainfrom
Stanley-Owoh:implement-exponential-decay-model-for-reputation-scores-395
Open

Implement exponential decay model for reputation scores 395#661
Stanley-Owoh wants to merge 13 commits into
DXmakers:mainfrom
Stanley-Owoh:implement-exponential-decay-model-for-reputation-scores-395

Conversation

@Stanley-Owoh
Copy link
Copy Markdown
Contributor

[SC-REP-041] Implement Exponential Decay Model for Reputation Scores

Summary

Implemented timestamp-based reputation score decay in the Reputation smart contract. Review aggregates now track the ledger timestamp of the latest review, and public score retrieval applies fixed-point daily decay so older review history gradually carries less weight.

Changes

  • Added last_reviewed_at to reputation review aggregates.
  • Added fixed-point decay calculation for public reputation reads.
  • Updated get_score, query_reputation, and badge reads to reflect decayed current scores.
  • Ensured empty/default profiles initialize all fields safely.
  • Added authorized contract registry support for score adjustment flows:
    • authorize_contract
    • deauthorize_contract
    • is_contract_authorized
  • Restored missing dispute-failure event/helper flow.
  • Removed duplicate badge metadata/getter implementations that caused contract macro conflicts.
  • Added regression coverage proving score decay from the review timestamp.
  • Updated stale tests to match current profile, badge, and job record behavior.

Validation

Passed:

cargo fmt -p reputation
cargo check -p reputation
cargo test -p reputation --lib -- --test-threads=1
cargo build --target wasm32-unknown-unknown --release -p reputation

Test result:

37 passed; 0 failed

Scope

Touched files:

  • contracts/reputation/src/lib.rs
  • contracts/reputation/src/profile.rs

No escrow or unrelated contract logic was changed for this issue.

Closes #395

… snapshots

- Fix badge_level computation in score_from_profile to derive dynamically
  from score via BadgeLevel::from_score, rather than reading stale stored value
- Fix BadgeTier clone in set_badge_metadata to avoid use-after-move
- Fix RoleMetrics::new() initial badge_level to match default score (Bronze)
- Regenerate all Soroban test snapshots for the updated contract logic

All 25 tests passing.
…ity and consistency

- Removed unnecessary whitespace and adjusted formatting in `lib.rs` and `profile.rs`.
- Consolidated function signatures for better clarity.
- Enhanced error handling in arithmetic operations.
- Streamlined badge level assignment logic in the `refresh_badges` method.
- Updated function calls to maintain consistent formatting across the codebase.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@Stanley-Owoh is attempting to deploy a commit to the mAzI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@Stanley-Owoh 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

Copy link
Copy Markdown
Contributor

@soomtochukwu soomtochukwu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If you could fix the merge conflict(s) ASAP
  • see that the CI checks pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SC-REP-041] Implement Exponential Decay Model for Reputation Scores

2 participants