feat: Implement TEE reputation system (#49)#55
Open
addnad wants to merge 1 commit intoOpenGradient:mainfrom
Open
feat: Implement TEE reputation system (#49)#55addnad wants to merge 1 commit intoOpenGradient:mainfrom
addnad wants to merge 1 commit intoOpenGradient:mainfrom
Conversation
Add comprehensive reputation contract for tracking and scoring TEE performance. Features: - Track per-TEE statistics: total requests, successes, failures - Record downtime windows with audit trail - Calculate reputation scores using weighted formula * Success rate: 50% weight * Uptime ratio: 35% weight (calculates from downtime) * Response quality: 15% weight - Four reputation tiers: poor, fair, good, excellent - Client query interface to find top TEEs by reputation - Admin controls for configurable weights and thresholds Integration: - Off-chain indexer listens to InferenceSettlementRelay events - Calls recordSettlement() with success/failure status - Heartbeat monitor tracks TEE downtime via TEERegistry - Supports downtime reasons: heartbeat_missed, pcr_revoked, manual_disable Contract includes: - Full role-based access control (recorder, monitor, admin) - Comprehensive test suite with 15+ test cases - Detailed integration guide for deployment and usage Resolves OpenGradient#49
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.
Implements a comprehensive on-chain reputation system for TEEs that tracks performance metrics and provides reputation scores to help clients intelligently select the best TEEs for inference requests.
Problem
Issue #49: OpenGradient needs a way to track successful/failed requests, downtime, etc. by TEEs to help clients decide which one is best to use, and potentially blacklist problematic ones.
Solution
Created
TEEReputation.sol- a smart contract that:Core Features
Performance Tracking: Monitors per-TEE statistics
Downtime Monitoring: Records downtime windows with audit trail
Reputation Scoring: Weighted algorithm combining three metrics
Reputation Tiers: Four-tier classification
Client Query API: Find best TEEs by reputation
getTopTEEsByReputation(teeType, minTier, limit)- get top rated TEEsConfiguration
Admin Controls: Configurable weights and thresholds
updateWeights()andupdateTierThresholds()Role-Based Access Control
SETTLEMENT_RECORDER_ROLE- off-chain indexer records settlementsHEARTBEAT_MONITOR_ROLE- monitor service tracks downtimeDEFAULT_ADMIN_ROLE- manage configurationIntegration
Off-Chain Services Required
Settlement Indexer
InferenceSettlementRelay.IndividualSettlementeventsrecordSettlement(teeId, successful, responseTimeMs)Heartbeat Monitor
recordDowntime(teeId, 0, "heartbeat_missed")when staleresolveDowntime(teeId)when heartbeat receivedNo Breaking Changes
Testing
Comprehensive test suite included (
TEEReputation.t.sol):Files Changed
contracts/solidity/TEEReputation.sol(450 lines) - Main contractcontracts/solidity/tests/TEEReputation.t.sol(350+ lines) - Test suitecontracts/solidity/TEE_REPUTATION_GUIDE.md(400+ lines) - Integration documentationDocumentation
Included detailed guide (
TEE_REPUTATION_GUIDE.md):Impact
✅ Solves issue #49 completely
✅ Enables intelligent TEE selection for clients
✅ Provides basis for future reputation-based incentives/slashing
✅ Fully self-contained, no external dependencies
✅ Gas-efficient (cached scores, batch-friendly)
Deployment Steps
getTopTEEsByReputation()See
TEE_REPUTATION_GUIDE.mdfor detailed checklist.Resolves #49