Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response Rate Scoring Surface #46

Merged
merged 4 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# keys
*.pem

.DS_Store
.ruff_cache
.vscode
Expand Down
3 changes: 3 additions & 0 deletions storb/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
PIECE_LENGTH_SCALING = 0.5
PIECE_LENGTH_OFFSET = 8.39

# Scaling factor for scoring
SCORE_SCALING = 1000

MAX_UPLOAD_SIZE = 1 * 1024 * 1024 * 1024 * 1024 # 1 TiB

# Error correction encoding parameters
Expand Down
21 changes: 18 additions & 3 deletions storb/validator/reward.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import numpy as np

from storb.constants import SCORE_SCALING


def get_response_rate_scores(
self,
Expand Down Expand Up @@ -28,9 +30,22 @@ def get_response_rate_scores(
uids.append(uid)
ret_attempts = max(miner_stats.get("retrieval_attempts", 1), 1)
store_attempts = max(miner_stats.get("store_attempts", 1), 1)
retrieval_rate = abs(miner_stats.get("retrieval_successes", 0) / ret_attempts)
store_rate = abs(miner_stats.get("store_successes", 0) / store_attempts)
weighted_rate_sum = (retrieval_rate / 2) + (store_rate / 2)
retrieval_success_rate = abs(
miner_stats.get("retrieval_successes", 0) / ret_attempts
)
store_success_rate = abs(miner_stats.get("store_successes", 0) / store_attempts)

retrieval_rate_score = (ret_attempts / SCORE_SCALING) * np.log(
retrieval_success_rate
) + 1
store_rate_score = (store_attempts / SCORE_SCALING) * np.log(
store_success_rate
) + 1

retrieval_rate_score = np.clip(retrieval_rate_score, 0, 1)
store_rate_score = np.clip(store_rate_score, 0, 1)

weighted_rate_sum = (retrieval_rate_score / 2) + (store_rate_score / 2)
weighted_rate_sums.append(weighted_rate_sum)

uids = np.array(uids)
Expand Down
Loading