# Proof-of-Authority (PoA) Program Documentation

## Overview

The PoA (Proof-of-Authority) Program is a Solana-based smart contract that allows registered Jito operators to execute specific on-chain instructions known as *proposals*. The execution of these proposals is subject to certain conditions, primarily that:

1. The signer must be a **Jito operator** registered in an **NCN** (Node Coordination Network) linked to the PoA state.
2. The operator must have a sufficient amount of delegated **stake**.
3. The proposal can only be executed once *enough* operators (as defined by the `threshold` in the `PoAState` account) have approved it.

This program is tightly integrated with the **Jito Restaking Program** and the **Vault Program**, ensuring that only valid, staked operators can authorize execution.

## Architecture

{% @mermaid/diagram content="flowchart BT

```
classDef main fill:#AAA,stroke:#333,stroke-width:2px;
classDef ticket fill:#595,stroke:#333,stroke-width:1px,font-size:10;
classDef function fill:#FFD700,stroke:#333,stroke-width:2px, font-weight:bold;
classDef check fill:#FF6347,stroke:#333,stroke-width:1px,font-size:10;
classDef storage fill:#87CEFA,stroke:#333,stroke-width:1px,font-size:10;


subgraph Restaking Program
    NCN[NCN]:::main
    Operator[Operator]:::main
    NcnOperatorState[NcnOperatorState]:::ticket
end

subgraph Vault Program
    Vault[Vault]:::main
    VaultOperatorDelegation[VaultOperatorDelegation]:::ticket
end

subgraph PoA Program
    PoAState[PoAState]:::main
    HandleProposal([handle_proposal]):::function
end
```

%% Vault Program Links
Vault -->|Delegates stake| VaultOperatorDelegation
VaultOperatorDelegation -->|Tracks delegation| Operator

%% Restaking Program Links
NCN -->|Registers| NcnOperatorState
Operator -->|Opts in| NcnOperatorState

%% Cross-Program Links
Vault -.-> |Referenced supported token in| PoAState
NCN -.-> |Referenced in| PoAState

%% Jito Account Verification inside handle\_proposal
HandleProposal -.->|Checks Delegation| VaultOperatorDelegation
HandleProposal -.->|Checks Operator in NCN| NcnOperatorState
HandleProposal -.->|Checks Vault & Operator| Vault
HandleProposal -.->|Checks PoA threshold| PoAState" %}

## PoA State Account

The `PoAState` account holds the configuration parameters that define how the PoA program operates. It includes:

* `threshold` → The minimum number of operators required to approve a proposal before execution.
* `admin` → The administrator of the PoA program.
* `ncn` → The associated **NCN** that determines valid operators.
* `supported_token` → The token that must be **staked** by operators to gain execution rights.
* `stake_threshold` → The **minimum stake** required for an operator to participate in PoA.

## Proposal Execution Workflow

1. **Operator Calls `handle_proposal`**
   * The Jito operator initiates execution by calling `handle_proposal`.
2. **Verification Process:**
   * The program verifies that:
     * The **operator is registered** in the relevant NCN (`NcnOperatorState`).
     * The **operator has enough delegated stake** (`VaultOperatorDelegation`).
     * The **vault and operator match expected values**.
     * The **operator is part of the PoA program**.
3. **Tracking Approvals:**
   * The proposal remains **pending execution** until *enough* operators (determined by `threshold`) approve it.
   * Each operator approval is tracked.
4. **Proposal Execution:**
   * Once the required number of approvals is reached, the proposal is executed.
   * The execution may involve calling various Solana instructions.

This ensures that no single operator has unilateral control, reinforcing decentralization and security.
