The Reputation Ledger is a core component of Session’s architecture, designed to establish a trust-based framework that holds each client accountable for their activity on the network. This ledger is a transparent, decentralized system, maintaining a real-time record of client and node interactions, performance metrics, and reputation scores.
The Reputation Ledger serves two primary functions:
Traffic Quality Monitoring: It evaluates and logs the nature and quality of traffic sent by each client. Clients who trigger firewall blocks due to suspicious or abusive behavior receive penalties, reducing their reputation score (similar to slashing in blockchain networks).
Node Performance Tracking: It maintains an up-to-date record of each lite-node’s reliability, speed, and resource availability. These metrics inform the selection process when assigning nodes to fulfill requests, ensuring optimal allocation based on performance and reputation.
Components of the Reputation Ledger
The Reputation Ledger consists of the following components:
Client Reputation: Each client is assigned a reputation score that reflects their historical behavior and trustworthiness. Higher reputation scores indicate consistent, legitimate activity, while lower scores result from firewall blocks, suspicious traffic, or non-compliance with network policies.
Node Metrics: The ledger tracks critical performance metrics for each lite-node, such as:
Uptime: How often the node is active and responsive.
Reliability: Frequency of successful request processing.
Latency: Response time for processing requests.
Bandwidth Utilization: Amount of bandwidth the node has contributed over time.
These metrics enable a fair and dynamic selection process, giving preference to nodes that demonstrate consistent, high-quality performance.
Pseudocode: Client Reputation Management
Class ReputationLedger:
Initialize:
client_reputations = empty dictionary
Function register_client(client_id):
If client_id not in client_reputations:
client_reputations[client_id] = {
reputation: 100,
requests: 0,
blocks: 0
}
Function track_request(client_id):
If client_id in client_reputations:
client_reputations[client_id].requests += 1
Function penalize_client(client_id, penalty = 10):
If client_id in client_reputations:
client_reputations[client_id].reputation -= penalty
client_reputations[client_id].blocks += 1
Function get_client_reputation(client_id):
If client_id in client_reputations:
Return client_reputations[client_id].reputation
Else:
Return 0
// When client connects to network
ON CLIENT_CONNECT:
IF client not in reputation_system:
Initialize client score to 50
Create empty event history
// During client activity on network
ON CLIENT_REQUEST:
Get client's current reputation
IF suspicious traffic detected:
Decrease reputation by 5
Log suspicious activity
IF firewall block triggered:
Decrease reputation by 10
Log blocking event
IF request successful:
Increase reputation by 1
Log successful request
// Periodic updates
ON REPUTATION_UPDATE_INTERVAL:
FOR each client:
Apply time decay to reputation
Update trust status based on current score:
90+ -> Highly Trusted
40-89 -> Neutral
<40 -> Untrusted
// When checking client status
ON CLIENT_STATUS_CHECK:
Return:
Current reputation score
Trust status
Recent events
This pseudocode initializes a reputation ledger for clients, tracks their requests, applies penalties for suspicious behavior, and retrieves their reputation scores.
Pseudocode: Node Metrics Tracking
Class LiteNode:
Initialize(node_id):
self.node_id = node_id
self.uptime = 0
self.reliability = 0.0
self.latency = 0.0
self.bandwidth_usage = 0
Class ReputationLedger:
Initialize:
client_reputations = empty dictionary
node_metrics = empty dictionary
Function register_node(node_id):
If node_id not in node_metrics:
node_metrics[node_id] = new LiteNode(node_id)
Function update_node_performance(node_id, uptime, reliability, latency, bandwidth):
If node_id in node_metrics:
node = node_metrics[node_id]
node.uptime = uptime
node.reliability = reliability
node.latency = latency
node.bandwidth_usage += bandwidth
Function get_node_metrics(node_id):
If node_id in node_metrics:
Return node_metrics[node_id] as dictionary
Else:
Return empty dictionary
// When node joins network
ON NODE_CONNECT:
Initialize node metrics:
uptime = 0
response_time_avg = 0
successful_requests = 0
network_failures = 0 // failures due to node's network
client_failures = 0 // failures due to client issues
total_requests = 0
bandwidth_used = 0
last_heartbeat = current_time
// Regular health checks
ON HEARTBEAT_INTERVAL:
FOR each node:
Send health probe
IF node responds:
Update last_heartbeat
Record response time
Update uptime percentage
ELSE:
// Cross-check with other nodes to verify network status
IF other_nodes_also_unreachable:
Mark as network partition
ELSE:
Mark node as potentially offline
IF offline_duration > threshold:
network_failures++
Decrease reliability score
// During request processing
ON REQUEST_ASSIGNED:
Record request start time
Track bandwidth allocation
Monitor connection status
IF request completes:
successful_requests++
Calculate response latency
Update response_time_avg
Add bandwidth to total
ELSE:
Analyze failure:
// Check multiple indicators
IF node_connection_dropped:
network_failures++
ELSE IF client_disconnected OR client_timeout OR invalid_request:
client_failures++
ELSE IF multiple_nodes_report_same_client_issue:
client_failures++
ELSE IF neighboring_nodes_operational:
network_failures++
Update reliability score based on failure type
// Node selection for requests
ON NODE_SELECTION:
Filter available nodes where:
- uptime above minimum threshold
- response time within acceptable range
- enough bandwidth available
- network_failures below threshold
Sort nodes by:
- reliability score (excluding client-caused failures)
- current load
- response time
// Performance reporting
ON METRICS_UPDATE:
FOR each node:
Calculate:
true_reliability = successful_requests / (total_requests - client_failures)
health_score = weighted_average(
uptime,
true_reliability,
response_time_avg,
bandwidth_contribution
)
This pseudocode represents how to register lite-nodes and keep track of their performance metrics within the Reputation Ledger.
Pseudocode: Node Selection Committee
Class SelectionCommittee:
Initialize(reputation_ledger):
self.reputation_ledger = reputation_ledger
Function select_best_node(required_bandwidth):
candidates = empty list
For each node_id, metrics in reputation_ledger.node_metrics:
If metrics.reliability > 0.9 AND metrics.bandwidth_usage >= required_bandwidth:
Add node_id to candidates
If candidates not empty:
Sort candidates by:
- Highest uptime (descending)
- Lowest latency (ascending)
selected_node = first node in sorted candidates
Return selected_node
Else:
Return None
// When client needs a node for request
ON CLIENT_REQUEST_NODE(bandwidth_needed):
// Get list of all available nodes
available_nodes = GET_ACTIVE_NODES()
candidates = []
// Filter nodes based on minimum requirements
FOR each node in available_nodes:
IF node.reliability >= 75% AND // Only highly reliable nodes
node.bandwidth >= bandwidth_needed AND // Has enough bandwidth
node.is_online: // Currently active
Add node to candidates
// If we found suitable nodes
IF candidates not empty:
// Sort them by performance metrics
SORT candidates by:
1. Uptime (highest first)
2. Latency (lowest first)
// Select best node
best_node = first node in candidates
RETURN best_node
// No suitable nodes found
ELSE:
RETURN none
// Example usage flow:
ON NEW_MESSAGE_RELAY:
bandwidth = CALCULATE_REQUIRED_BANDWIDTH(message)
selected_node = CLIENT_REQUEST_NODE(bandwidth)
IF selected_node exists:
RELAY_MESSAGE(selected_node, message)
ELSE:
NOTIFY_NO_SUITABLE_NODES()
This pseudocode outlines the logic for selecting the best node based on reliability, bandwidth, uptime, and latency.