Consensus

Rakis uses an embedding-based consensus mechanism with a commit-reveal system. On-chain contracts or peers in the network initiate inference requests, specifying parameters (prompt, temperature, etc.) and a security frame.

The security frame is designed to adjust the consensus's tightness or looseness, allowing applications with higher security and determinism needs to spend more for redundant compute, while simpler dApps can opt for faster, cheaper methods.

Rakis nodes follow the following steps to attain an agreement on their inference results:

  1. Inference Requests: Nodes on the network (like browser tabs, including yours) pick up and execute inference requests. These requests expire after a certain period, after which the security frame determines if consensus can be achieved. The Security Frame has the following adjustable parameters:

    • Quorum Size: Number of nodes required to validate the inference within the time frame.

    • SecDistance: Degree of similarity needed between results, defined as a distance.

    • SecPercentage: Percentage of participants required to be within the SecDistance, determining the tolerance for outliers or bad actors.

    For instance, a creative project might set a lower quorum size, wider SecDistance, and lower SecPercentage, while a financial project would do the opposite.

  2. Commit Phase: During the allotted time for inference, participants exchange hashes representing their results. This commit phase locks participants into a certain result without allowing them to copy others.

  3. Quorum Formation and Reveal: If enough commits are made within the time frame, nodes form a quorum and request a reveal. Once all outputs are revealed, they are verified against the commits, and consensus begins.

By adjusting the parameters of the security frame, Rakis can cater to different application needs, balancing security and performance.

The implemented consensus mechanism in Rakis is straightforward. Outputs are embedded using binary embeddings, which have shown relative determinism in our tests. These embeddings form clusters, which are used to measure agreement.

Here's how it works:

  1. Embedding and Clustering: The inference outputs are embedded in a high-dimensional space using binary embeddings. The clusters of these embeddings indicate agreement among the nodes.

  2. Finding Agreement: We identify the center of a sphere with a radius of SecDistance that contains the highest number of points (embeddings) in the high-dimensional space. Outputs within this sphere are considered valid, while those outside are deemed failures.

  3. Hashing for Randomness: The valid outputs within the sphere are then deterministically hashed to generate a source of randomness. This randomness is used to select one output, ensuring a consistent and fair consensus.

This method allows Rakis to achieve consensus efficiently by leveraging the clustering of binary embeddings and deterministic hashing for randomness.

Last updated