⛏️DePIN

A Decentralised Physical Infrastructure Network (DePIN) of Shared Computing Power

Abstract

This whitepaper introduces a Decentralised Physical Infrastructure Network (DePIN) designed to scale and sustain DeHub, a streaming and gaming application. The system leverages shared computing power from a network of miners who contribute resources for data hosting, transcoding, and delivery. Miners are rewarded directly from application revenue and token transaction fees, ensuring a sustainable, inflation-free model. This paper outlines the technical framework, economic incentives, and implementation strategies for deploying this DePIN, enabling contributions from as little as a mobile device.


System Architecture

----------------------        -----------------
|  DeHub Application |        |   End Users   |   - Start of data flow
----------------------        -----------------
         ⬇ ⬆                       ⬇ ⬆                                     
----------------------------------------------
|              DePIN Coordinator             |    - Tasking, encryption + decryption
----------------------------------------------
     ⬇                ⬇                ⬇                              
----------        -----------       -----------
| Mobile |        | PC/GC   |       | Server  |   - That provide computing power
| Miners |        | Miners  |       | Miners  |   - in exchange for DHB tokens
----------        -----------       -----------
    ⬇        ↙        ⬇       ↙↙ ↘     ⬇
-----------       -------------     ------------
| Hosting |       | Transcode |     | Deliver  |  - Content delivery network
-----------       -------------     ------------

Introduction

Challenges in Streaming and Gaming Platforms

Centralised infrastructure for streaming and gaming platforms faces challenges such as high operational costs, scalability limits, and susceptibility to censorship or outages. These challenges hinder the ability of platforms like DeHub to achieve its purpose of being a decentralised, permissionless and user owned protocol that lives forever on-chain while maintaining cost efficiency.

Solution: Shared Computing DePIN

By decentralising the infrastructure, DeHub can tap into a distributed network of computing power to address these challenges. A DePIN allows users to share their computing resources, ensuring:

  1. Cost Efficiency: Lower hosting and delivery costs by using shared resources.

  2. Scalability: Dynamically grow the network as demand increases.

  3. Sustainability: Reward contributors directly from app revenues without token inflation.


System Architecture

Core Components

  1. Contributors (Miners): Individuals providing computing resources via devices such as mobile phones, PCs, or dedicated servers.

  2. DePIN Coordinator: A data encryption, decryption and smart contract system managing miner rewards, resource allocation, and task distribution.

  3. DeHub Application: The streaming and gaming app interfacing with the DePIN to request and deliver data.

  4. Clients (End Users): Users consuming content via DeHub.

Workflow

  1. Resource Sharing: Contributors register and allocate resources.

  2. Task Assignment: The DePIN Coordinator assigns tasks such as hosting, transcoding, or delivery based on contributor capacity.

  3. Revenue Sharing: Miners are compensated from a revenue pool funded by in-app revenue and token transaction fees.

  4. Verification: Proof-of-computation mechanisms validate miners' contributions.


Incentive Model

Revenue Pool

The reward pool is composed of:

  1. In-App Revenue: A percentage of subscription fees, ad revenue, and in-app purchases.

  2. Token Transaction Fees: A share of transaction fees from the $DHB token.

Distribution Mechanism

  • Rewards are distributed based on the volume and quality of contributions.

  • Miners earn proportionally higher rewards for tasks requiring more resources or bandwidth.


Participation Requirements

Minimum Hardware Requirements

Device Type

Minimum Specs

Supported Tasks

Staking Amount

Mobile Phones

Quad-core CPU, 4GB RAM

Hosting

100,000 $DHB

PCs/Laptops

4-core CPU, 8GB RAM, GPU

Transcoding, Hosting, Delivery

1,000,000 $DHB

Dedicated Servers

8-core CPU, 16GB RAM, SSD

High-volume Hosting, Delivery

10,000,000 $DHB

Software Setup

Miners install a lightweight client application that:

  1. Connects to the DePIN network.

  2. Reports available resources.

  3. Executes assigned tasks.

Full System Code Implementation

Miner Client Code

import requests
import time
import hashlib

API_BASE = "https://depin-coordinator.dehub.net"

class MinerClient:
    def __init__(self, device_id, cpu_cores, ram_gb, bandwidth_mbps):
        self.device_id = device_id
        self.cpu_cores = cpu_cores
        self.ram_gb = ram_gb
        self.bandwidth_mbps = bandwidth_mbps
        self.session_token = None

    def register_device(self):
        payload = {
            "device_id": self.device_id,
            "cpu_cores": self.cpu_cores,
            "ram_gb": self.ram_gb,
            "bandwidth_mbps": self.bandwidth_mbps
        }
        response = requests.post(f"{API_BASE}/register", json=payload)
        if response.status_code == 200:
            self.session_token = response.json().get("session_token")
            print("Registered successfully.")
        else:
            print("Registration failed:", response.text)

    def fetch_task(self):
        headers = {"Authorization": f"Bearer {self.session_token}"}
        response = requests.get(f"{API_BASE}/tasks", headers=headers)
        if response.status_code == 200:
            return response.json()
        return None

    def submit_result(self, task_id, result):
        headers = {"Authorization": f"Bearer {self.session_token}"}
        payload = {"task_id": task_id, "result": result}
        response = requests.post(f"{API_BASE}/submit", json=payload, headers=headers)
        if response.status_code == 200:
            print("Result submitted successfully.")
        else:
            print("Failed to submit result:", response.text)

    def run(self):
        while True:
            task = self.fetch_task()
            if task:
                print(f"Received task: {task['type']}")
                task_result = self.execute_task(task)
                self.submit_result(task['task_id'], task_result)
            time.sleep(10)

    def execute_task(self, task):
        # Simulate task execution
        task_data = task.get("data")
        result_hash = hashlib.sha256(task_data.encode()).hexdigest()
        time.sleep(task.get("duration", 5))  # Simulate processing time
        return result_hash

if __name__ == "__main__":
    miner = MinerClient(device_id="unique_device_123", cpu_cores=4, ram_gb=8, bandwidth_mbps=20)
    miner.register_device()
    miner.run()

DePIN Coordinator (Server-Side Logic)

from flask import Flask, request, jsonify
import uuid

app = Flask(__name__)

# Mock databases
devices = {}
tasks = []
completed_tasks = {}

@app.route('/register', methods=['POST'])
def register_device():
    data = request.json
    device_id = data.get('device_id')
    if not device_id or device_id in devices:
        return jsonify({"error": "Invalid or duplicate device ID."}), 400

    devices[device_id] = {
        "cpu_cores": data.get("cpu_cores"),
        "ram_gb": data.get("ram_gb"),
        "bandwidth_mbps": data.get("bandwidth_mbps"),
        "session_token": str(uuid.uuid4())
    }
    return jsonify({"session_token": devices[device_id]["session_token"]}), 200

@app.route('/tasks', methods=['GET'])
def get_task():
    session_token = request.headers.get("Authorization").split(" ")[1]
    device = next((d for d in devices.values() if d["session_token"] == session_token), None)
    if not device:
        return jsonify({"error": "Unauthorized"}), 403

    # Generate a mock task
    task = {
        "task_id": str(uuid.uuid4()),
        "type": "hash_computation",
        "data": "sample_data",
        "duration": 5
    }
    tasks.append(task)
    return jsonify(task), 200

@app.route('/submit', methods=['POST'])
def submit_task():
    data = request.json
    task_id = data.get("task_id")
    result = data.get("result")
    if not task_id or not result:
        return jsonify({"error": "Invalid submission."}), 400

    completed_tasks[task_id] = result
    return jsonify({"message": "Task completed successfully."}), 200

if __name__ == '__main__':
    app.run(debug=True)

Scalability and Security

Dynamic Task Allocation

Tasks are distributed based on:

  • Current demand.

  • Contributor capacity.

  • Proximity to end users.

Proof-of-Computation

A lightweight proof-of-computation mechanism ensures tasks are completed reliably. Rewards are only issued upon verification.

Reward Calculator

The DePIN includes a reward calculator that estimates miners' earnings based on their contributions.

Reward Formula

The rewards are calculated using the following formula:

Reward = (Task Weight x Resource Score x Revenue Pool Share)

Where:

  • Task Weight: A predefined multiplier based on the type of task (e.g., hosting = 1.5, transcoding = 2.0, data delivery = 1.0).

  • Resource Score: A score calculated from the miner's resources, such as CPU cores, bandwidth, and RAM.

  • Revenue Pool Share: The miner's proportional share of the revenue pool.

Example Code for Reward Calculation

class RewardCalculator:
    def __init__(self, task_weight, cpu_cores, bandwidth_mbps, ram_gb, revenue_pool):
        self.task_weight = task_weight
        self.cpu_cores = cpu_cores
        self.bandwidth_mbps = bandwidth_mbps
        self.ram_gb = ram_gb
        self.revenue_pool = revenue_pool

    def calculate_resource_score(self):
        return (self.cpu_cores * 0.4) + (self.bandwidth_mbps * 0.3) + (self.ram_gb * 0.3)

    def calculate_reward(self):
        resource_score = self.calculate_resource_score()
        return self.task_weight * resource_score * self.revenue_pool

# Example usage
if __name__ == "__main__":
    calculator = RewardCalculator(task_weight=1.5, cpu_cores=4, bandwidth_mbps=20, ram_gb=8, revenue_pool=10000)
    reward = calculator.calculate_reward()
    print(f"Estimated Reward: {reward:.2f} DHB Tokens")

This reward calculator can be integrated into the miner client for real-time reward estimation.


Conclusion

The proposed DePIN enables truly decentralised, censorship resistant, limitlessly scalable, and cost-efficient infrastructure for DeHub. By leveraging shared computing power and rewarding miners directly from revenue, the system avoids inflation and ensures long-term sustainability. This model empowers anyone with spare computing resources, from mobile phones to servers, to participate in and benefit from DeHub’s growth. In order to disrupt this behemoth of an industry, one requires billionaire backing or true innovation, just like this DePIN.

*The full code will be open sourced upon completion.

Last updated