Skip to content

docs(cip): introduce CIP process and CIP-001 (paracross validator set governance) - #1327

Open
vipwzw wants to merge 8 commits into
masterfrom
design/paracross-validator-governance
Open

vipwzw wants to merge 8 commits into
masterfrom
design/paracross-validator-governance

Conversation

@vipwzw

@vipwzw vipwzw commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

背景

Bitcoin 有 BIP、Ethereum 有 EIP,chain33 目前没有任何改进提案机制(仓库内只有零散的 docs/*.md,无 CONTRIBUTING、无 PR 模板)。本 PR 建立 CIP(Chain33 Improvement Proposal) 目录与流程,并提交第一份提案 CIP-001。

本 PR 内容

📄 CIP-001 全文(点击查看)

docs/cip/
├── README.md                                   # CIP 流程:类型、状态机、编号与命名、头部元数据、提交方式、版权
├── cip-template.md                             # 新建 CIP 的模板(必需章节已就位)
└── cip-001-paracross-validator-governance.md   # CIP-001(Standards Track / Consensus·Cross-chain,status: Draft)

CIP-001 摘要:把 paracross 平行链验证人集合的更换,从"节点组内部 2/3 投票达成即生效"改为「平行链提案 → 主链分档治理/时间锁 → 显式 Activate」,并新增治理可控的双向跨链急停:

  • 锁定资产 > 阈值(默认 10 万 BTY):必须经主链治理批准,批准后锁 1 天且窗口内治理可撤销;
  • ≤ 阈值且未获批准:锁 7 天;
  • 生效统一由 Activate 在到点后完成,commit 校验读路径不变,主链与平行链不会对"有效集合"产生分歧;
  • 急停:治理可切断该链跨链资金来往(含入金),挂起提现在停用期间不执行且不让 commit 失败。

明确不解决(写入 CIP 的安全考虑):多数验证人联合作恶仍可伪造状态盗取资产——需 Phase 2(挑战期 + mavl 见证式欺诈证明、抽样罚没、zk);首次建组仍为自由注册,该缺口作为已接受风险记录并给出监控/急停缓解。

附带的支撑文档

同分支还包含 CIP-001 的设计工作稿与实施计划,便于评审时看到完整依据:

  • docs/superpowers/specs/2026-10-14-paracross-validator-governance-design.md(逐节评审通过的设计)
  • docs/superpowers/plans/2026-10-14-paracross-validator-governance.md(12 个 TDD 任务的实施计划)

实施代码不在本 PR:CIP 定稿后再另开实现 PR。

依赖与评审

  • CIP-001 的 requires 指向 fix(paracross): bind node group title to its exact para execer #1326(paracross title 与 execer 精确绑定)——该修复是 CIP 规范中"title 必须规范且与 execer 精确对应"的前置项。
  • CIP-001 初始 status: Draft。状态推进(Review → Last Call → Accepted)与 CIP 序号确认请维护者在 PR 中裁定。
  • POI:discussions-to 暂指仓库 issue 列表,如需专用讨论渠道/邮件列表请指出。

king added 5 commits October 14, 2026 10:23
…ker (phase 1)

Design for replacing the parachain's permissionless, key-based validator
group changes with a main-chain enforced state machine:

- validator set changes are proposed by the parachain governance and only
  take effect via an explicit Activate after a risk-tiered delay: above
  the locked-asset threshold they require autonomy approval plus a 1 day
  lock (cancellable in the window), below it a 7 day lock without
  approval. The commit verification read path is unchanged, so main chain
  and parachain always agree on the active set.
- governance can cut off cross-chain fund flow for a given parachain in
  both directions as an emergency stop.
- phase 2 roadmap (challenge window + mavl witness fraud proofs, sampling
  and slashing, zk validity proofs) and the residual risk of still
  permissionless bootstrap are documented.

Sections 1-6 were reviewed and confirmed section by section before this
spec was written.
12 TDD tasks: constants/params and fork registration, state encoding and
kv helpers, Propose/Approve/Cancel/Activate state machine, entry point
rewiring (NodeGroupConfig/NodeConfig/SupervisionNodeConfig), query, the
governance circuit breaker plus its enforcement on submit and on pending
cross tx execution, fork config rollout, main/para consistency and
rollback integration tests, and CLI/ops docs.

Self-review fixed: error and log constants now declared in task 1,
FromAddr added to the state struct up front, exact wire format spelled
out, and the six review-focus failure modes each pinned to a task test.
Add docs/cip/ with the CIP process (types, status lifecycle, numbering,
header metadata, submission flow), a template, and the first proposal:

CIP-001 (Standards Track, Draft): validator set changes on a parachain
must go through a main chain enforced state machine - parachain proposal,
risk tiered governance approval (above the locked-asset threshold: 1 day,
cancellable) or a 7 day lock, then an explicit Activate. Commit
verification reads are unchanged so main chain and parachain cannot
diverge on the active set. A governance controlled circuit breaker can
cut cross chain fund flow in both directions. Phase 2 (challenge window
with mavl witness fraud proofs, sampling, slashing, zk) is scoped as a
follow-up CIP.
The 100k BTY tier threshold must not be fixed in code or node config, so
CIP-001, the design spec and the implementation plan now define it as an
on-chain paracross parameter decided by main chain governance:

- two-step flow reusing the existing autonomy PropItem pattern
  (ParamPropose=15 writes {id=tx hash, value}, board votes on that hash,
  ParamApply=16 verifies IsAutonomyApprovedItem and writes the value);
  the proposal tx hash binds the value, so an approved item id alone
  cannot be used to inject an arbitrary threshold.
- the value takes effect immediately but only for proposals created
  afterwards: a proposal snapshots its tier at Propose time, so changing
  the threshold cannot retrospectively reclassify an in-flight change.
- chain config now only carries the two delay parameters; the code
  default (100000 x precision) applies only while the state key is
  absent.

Plan gains Task 8 (param state machine) and a seventh review focus item
for threshold injection; tasks 8-12 renumbered to 9-13.
…ic symbol

CIP-001, the design spec and the plan now state every amount in the main
chain native coin (the cfg.GetCoinExec() coin, smallest unit given by
coinPrecision) instead of naming a particular chain's token. The unit is
defined once in the specification, and the plan's global constraints no
longer describe the threshold as a chain config value (it is the
governance voted on-chain parameter from the previous commit).
king and others added 2 commits October 14, 2026 14:29
The unit-test failure on this branch was a pre-existing data race in
plugin/dapp/paracross/testnode (fixed separately in the CI PR); this
empty commit re-runs the checks. Drop it when squashing.
@bysomeone

Copy link
Copy Markdown
Collaborator

对 CIP-001 做了一轮审查(文档内部一致性 / 与现有实现和历史对账 / 关键结论均有实跑验证)。总体:方向与结构没有问题(显式 Activate 换集合、读路径不变,是这版最稳的一处设计),但有几处建议在定稿前补齐。按「需要作者拍板的方案性取舍」和「可直接修订」两档列出。

一、需要拍板(方案性取舍)

1. 急停期间被跳过的挂起提现:丢弃还是延后?

CIP 第 163–164 行写"解除后挂起提现可正常执行,无需重新提交",但按计划的实现(execCrossTxs 循环前判断、直接返回空 receipt)做不到:

  • commitTxDoneStep2 在调用 procCrossTxs 之前已把 titleStatus.Height 推进(plugin/dapp/paracross/executor/action.go:847-853);
  • 此后同高度的 commit 只记 record(action.go:685-687),loopCommitTxDone 从 Height+1 起(action.go:958-961);
  • 全仓没有重放/pending 队列;isAllowMainConsensJump 只在 titleStatus.Height == -1 时放行。

⇒ 该高度的跨链交易一生只执行一次,被跳过即永久不可执行(资金仍留在 paracross 池里,不是蒸发)。建议二选一并写进规范:(i) 承诺改为"需重新提交",并写清平行链侧已扣部分的口径;(ii) 要求实现提供重放队列(需新增状态键与顺序/回滚处理,Phase 1 实现量上升)。

附带:急停的触发与解除都要走完整 autonomy 提案,与"止血"的时效要求不匹配;建议单设低延迟通道 + 自动过期。

2. Propose(op=5)的发起授权

CIP 第 112–119 行的 6 条前置条件都不涉及发起人;op=5 与 op=1/2 共用 NodeGroupConfig action,而主链 allow() 对这两个 action 只要求 ForkCommitTx 生效、对发起人零限制(paracross.go:367-372;design 5.x 还明确"不改 GetTypeMap 与 allow()");规则 3"该 title 已有生效集合"恰好不拦——目标链已有集合正是攻击场景。

⇒ 低价值档链上等于"任何人可提案 + 窗口内无人 Cancel 即生效",与"内部 2/3 投票达成 ≠ 生效"的叙事脱节。建议二选一并写进规范:(a) op=5 不由用户提交,提案只由既有 NodeConfig 2/3 投票路径在链内产出;(b) op=5 保留,但必须携带当前生效集合的 2/3 授权证明。

3. 分档判定是否收敛为"主链单侧"

CIP 第 110 行的锁定资产口径在主链成立,但平行链落的是镜像的另一把键(asset.go:195-238 在 cfg.IsPara() 时对调 execAddr/toAddr),平行链按该口径读到的是另一本账 ⇒ 两侧 Tier 会分歧,而 CIP 118/222 把它当成已成立的不变式(design.md:253 的"两侧一致"只列了 Activate/Disable/Enable,未列 Propose)。建议明确写成"分档在主链计算、平行链只跟随不重算",并说明它与"主链执行失败不下发平行链"(filtertxs.go:104-108)这条既有兜底的关系。

二、可直接修订(文档/规范级)

  1. 低价值档的生效高度:CIP 第 121 行"未获治理批准前 EffectiveMainHeight = 0"是无条件表述,且规则章节从未使用 validatorSetDelayBlocksLow(只在第 50 行参数表出现);而 design.md:175 与 .plans 的用例断言(ProposeMainHeight + 60480)写的是"未批准且低价值档 = 提案高度 + 7 天"。两者矛盾,建议按 design 补进 CIP 正文(含 Activate 规则 2 的表述)。

  2. Activate 的写入路径:CIP 第 133 行"复用 nodeGroupCreate / 监督组写入路径"实测不成立——① 已存在地址走 superaccount.go:466-470 分支,只改 Status/ProposalId/QuitId,不写 BlsPubKey(监督组 supervisionaccount.go:213-217 同款),于是"地址不变、只轮换密钥"的提案新公钥永远不生效;② nodeGroupCreate 传 Status=ParaApplyClosed(3),而已存在地址分支只认 Joining/Quiting,"保留既有成员"这一最常见情形直接报错。建议改为明确要求"对已存在地址显式覆写 BlsPubKey、监督组按地址逐元素写",不要表述成复用。

  3. 急停的 reason:CIP 103/160/194 要求链上记录原因,但同时又规定"不得新增 protobuf"并沿用 ParaNodeGroupConfig,而该消息没有可承载 reason 的字段(Id/AutonomyItemID 已占用)。请明确承载方式。

  4. superManager 的一致性:CIP 123/160 把 isSuperManager(读节点本地配置 config.exec.sub.manage.superManager,superaccount.go:370-379)用作验证人变更批准与急停的备选闸门,但风险登记(207–211)只覆盖了新引入的参数。建议把 superManager / autonomyExec 一并写进"全网必须一致"的升级清单。

  5. 配套计划的配置文件清单:plans:351/353 列的 5 个 build/ci/** 路径是 make reset 生成、不在树内(Makefile:232);真正含 [fork.sub.paracross] 的 tracked 文件是另外 6 个。CIP 正文第 43 行的说法是对的,只需修计划。

  6. 对标引用的时效性:CIP 第 154 行引"现有 NodeGroupApply → autonomy item → NodeGroupApprove 的安全边界",但该闸门在 ForkParaFreeRegister(chain33.fork.toml 已生效)之后已被 checkApproveOpNew 的自审批取代——CIP 的 Approve 其实是首次把 autonomy 引入验证人变更,建议改为"与自由注册之前的旧路径同构"。

  7. 若干 editorial:摘要的"批准后 1 天锁 + 窗口内可撤销"与 Cancel 规则的"Activate 之前任意时刻"表述不一致;"参考实现(12 个 TDD 任务)"而计划是 13 个;kind ∈ {super, sup} 命名易混(super 与"监督组 supervision"字面接近,且本提案尚未上线、改命名无包袱);README 状态图缺 Final/Active → Superseded 箭头;discussions-to 指向 issue 列表页(流程规定评审在 PR 内进行);cip-template.md 的子章节名与 001 不一致。

对得上的部分(一并确认)

CIP 对现状的描述逐条核对基本准确:节点组两侧各存一份、内部 2/3 即生效(3*most > 2*nodes)、ForkParaFreeRegister 自由注册与自审批、#1326 的 title/execer 精确绑定(superaccount / rollup / 跨链筛选三处口径一致)、autonomy 两段式绑定(item 的 ItemTxHash 必须等于传入 hash)、入金账户口径、日志号 684 未占用、延迟参数的配置命名空间。

@bysomeone bysomeone left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按 10-15 那条审查评论:方向与结构没有问题,但有 3 项需要作者拍板的方案性取舍、7 项可直接修订,建议在定稿前补齐。逐条意见与对应代码位置见该评论:#1327 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants