mcpField
M
midnight-consensus

midnight-consensus

github.com/kali-decoder开发18123 次安装1 天前更新
代码仓库

关于 midnight-consensus

介绍 Midnight Network 修改版 Substrate 共识机制的技能,适合研究其验证者与区块最终性设计的读者。内容涵盖 AURA 出块、GRANDPA 最终性,以及 Cardano SPO 委托和可选许可验证者组成的验证者选择机制。

主要功能

  1. 01AURA 轮流出块
  2. 02GRANDPA 异步最终性
  3. 03结合 SPO 委托选择验证者
  4. 04支持可选许可验证者

适用场景

  1. 01了解 Midnight 的出块机制
  2. 02研究 Midnight 如何确认区块
  3. 03查看验证者资格模型

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/kali-decoder/midnight-skills --skill midnight-consensus

安装后在 Claude Code 中输入/midnight-consensus确认已加载。

详细介绍

Midnight 共识

Midnight Network 使用经过修改的 Substrate 共识栈:使用 AURA 生成区块,使用 GRANDPA 确定最终性。两者都针对 Midnight 作为 Cardano Partnerchain 进行了扩展。

架构概览

flowchart TB
  subgraph Selection["Validator selection"]
    SPO["Cardano SPO stake delegation"]
    Perm["Optional permissioned validators"]
    VS["Custom validator set function"]
    SPO --> VS
    Perm --> VS
  end

  subgraph Production["Block production — AURA"]
    VS --> Slots["Round-robin slots + session keys"]
    Slots --> Block["New block proposed"]
  end

  subgraph Finality["Finality — GRANDPA"]
    Block --> Votes["Validator votes on chain"]
    Votes --> Final["Provable finality"]
  end

验证者选择

与标准 Substrate 链不同,Midnight 使用自定义验证者集合选择函数,该函数:

  • 考虑来自 Cardano 质押池运营者(SPO)的质押委托,使现有 Cardano 验证者能够参与 Midnight 共识。
  • 支持可选的许可验证者,用于混合公有/私有网络部署。
模型作用
SPO 委托将 Cardano 质押接入 Partnerchain 验证者资格
许可集合为受监管或联盟网络添加已知运营者
自定义选择将两者合并到活跃会话验证者集合中

AURA:区块生成

AURA(Authority Round) 是一种权益证明(PoA)算法,用于确定由哪位验证者生成每个区块。

  • 验证者按轮询顺序轮流出块。
  • 调度使用预定义时隙和会话密钥。
  • 特点:简单、快速、确定性强,适合验证者集合已知的高吞吐量链。

AURA 并非 Midnight 专属;它起源于 OpenEthereum。请参阅Polkadot 协议术语表 — AURA。

sequenceDiagram
  participant V1 as Validator 1
  participant V2 as Validator 2
  participant V3 as Validator 3
  participant Chain as Chain

  Note over V1,V3: Slot N — Validator 1's turn
  V1->>Chain: Produce block N
  Note over V1,V3: Slot N+1 — Validator 2's turn
  V2->>Chain: Produce block N+1
  Note over V1,V3: Slot N+2 — Validator 3's turn
  V3->>Chain: Produce block N+2

**签名:**AURA 中的区块作者消息使用 sr25519 签名(参见 Cryptography 技能)。


GRANDPA:最终性

GRANDPA(GHOST-based Recursive ANcestor Deriving Prefix Agreement) 提供异步、可证明的最终性。

  • 独立于区块生成运行。
  • 验证者对链进行投票;区块在获得足够支持后即确定最终性。
  • 通用的 Polkadot 组件 — 形式化规范和 Polkadot 术语表。
flowchart LR
  A["Blocks produced (AURA)"] --> B["GRANDPA voters observe chain"]
  B --> C{"≥ threshold support?"}
  C -->|Yes| D["Block finalized — irreversible"]
  C -->|No| E["Remains unfinalized / fork possible"]

**签名:**GRANDPA 最终性消息使用 Ed25519。


AURA 和 GRANDPA 如何协同工作

层职责Midnight 扩展
AURA谁构建下一个区块在 Partnerchain 验证者集合上运行标准 PoA
GRANDPA哪些区块已确定最终性标准异步最终性小工具
验证者集合谁可以参与SPO 委托 + 可选的许可运营者

**要点:**GRANDPA 异步确定较早区块的最终性时,区块生成仍可继续 — 吞吐量与安全性彼此解耦。


相关技能

  • midnight-cryptography/ — AURA 和 GRANDPA 使用的签名方案
  • midnight-onchain-logic/ — 运行时 pallet(pallet-aura、pallet-grandpa、会话管理)
  • midnight-p2p-networking/ — 验证者如何发现彼此并进行通信

评论

支持 Markdown