Architecture
Last updated
Last updated
At the core of CoopHive is an SDK that allows anybody to create a token for a distributed computing network.
One layer above are the smart contracts that handle all the financial flows of the economy – payments, staking and slashing, the storing of deals, results, and mediation, etc.
One layer above that are the services that comprise the components of the network. Clients (job creators) and compute nodes (resource provider), mediators (which eventually can comprise any node in the network), and solvers, which act as market-makers.
At the highest layer is the Value Services Layer, for example a user-facing SaaS that allows users to pay for jobs on the network with Stripe. The goal is to have this layer abstract away the complexities of using Web3, providing consumers with a streamlined Web 2 experience.
Job Lifecycle The lifecycle of a job looks like the following:
Job and/or resource offers are posted to the orderbook
The solver finds a potential match of a job and a resource offer
The solver proposes a deal to the client and compute node
The client and compute node agree to the deal by sending transactions to the smart contract
As part of agreeing to the deal, they also post the relevant collateral
The client deposits payment and timeout collateral
The compute node deposits timeout collateral
If the compute node does not post the result within the agreed-upon time frame, it loses its timeout collateral, and the process stops here
The compute node computes the result of the job using an executor like Bacalhau
The compute node posts the CID of the result on-chain
The compute node is refunded its timeout collateral, and deposits its cheating collateral
The client can either accept the result, or request mediation
If the client accepts the result
The compute node is refunded its cheating collateral
The compute node is paid
The client is refunded it timeout collateral
The client is refunded its payment collateral minus the cost of the job
If the client requests mediation, then a mediation protocol is invoked according to the agreed-upon terms of the deal
If the mediation protocol determines that the compute node computed the result correctly
The same steps occur as if the client accepted the result, except the client also pays a mediation fee
If the mediation protocol determines that the compute node did not compute the result correctly
The compute node is not paid, and has its cheating collateral slashed
The client is refunded their timeout and payment collateral
The compute node’s cheating collateral is allocated to the mediators
The result of the mediation is posted on-chain
Clients and compute nodes send job and resource offers, respectively, to an entity known as a solver, which acts as a market-maker by proposing matches to participants in the network. If the client and compute node both agree to the deal, they send transactions to the smart contract. Since blockchains are based on public key infrastructure (PKI), only the corresponding owners could have signed the transactions (unless their keys were stolen). This market-making process also maintains decentralization, since clients and compute nodes have the final say on whether they agree to a deal or not.
In order to assure compute nodes that they will be paid if they compute correctly, and clients that the results they receive will be correct, both clients and compute nodes must place deposits as part of the process of making a deal and submitting a result. Smart contracts mediate financial interactions between nodes, including when the client wants to check whether a compute node has done the computation correctly.
A record of deals, results, and potentially mediation is recorded on-chain. The deals, results, and mediation consist of data that the smart contract needs to be on-chain (e.g. price per instruction), as well as mostly IPFS CID hashes. This way, all necessary data and metadata is stored on-chain, with all data that does not need to be stored on-chain being stored off-chain. Additionally, this makes the protocol much easier to upgrade incrementally, as very few changes will need to be made directly to the smart contract architecture, compared to if all data was being stored on-chain.