# Consensus

> See [Consensus Thread](/subnet-template/server/consensus-thread.md) in the template.

The **Consensus system** governs how nodes in a subnet **agree on the behavior and performance of each other**, particularly by assigning **weights** (or scores) that reflect the quality of their contributions.

The `Consensus` class runs **independently and in parallel** to the main Hypertensor network logic, and is designed to execute during each epoch.

## What It Does

The template provides a baseline `Consensus` implementation with the following responsibilities:

#### **1. Validator**

If the current node is elected as the **validator** for this epoch:

* Collects or computes **scores** for each node (e.g., based on output similarity, task performance, latency, etc.).
* Submits these scores **on-chain** to Hypertenso&#x72;**.**

#### **2. Attestor**

If the current node is assigned as an **attestor**:

* Collects or computes **scores** for each node.
* Retrieves the validator’s submitted scores for the epoch.
* Compares both sets of scores.
* Attest if they match exactly (e.g., **100% accuracy**)

> 📌 Attestation ensures accountability: validators must submit correct, verifiable scores, or face slashing, rejection, or reduced reputation.

***

## Epoch Flow Overview

1. **Epoch begins** (triggered by time or block height)
2. Each node checks its role:
   * If **validator**: generate and publish scores
   * If **attestor**: independently verify the scores
3. **Attestation is submitted** if scores match the validator's submitted consensus data.

***

## Customization

Subnets can extend the `Consensus` class to implement their own:

* Scoring logic (not included in template)
* Attestation criteria
* Coordination with on-chain governance or punishment systems


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertensor.org/build-a-subnet/consensus.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
