CKB Contract Flow

COMP 共享 Lock(Shared Cell)约束COMP Shared Lock (Shared Cell) Constraints

来源:gpBlockchain/comp-shared-lock @fd2370a contracts/comp-shared-lock/src/main.rs、json.rs,docs/contract-design.md · testnet 0xbc47…73c1 (type,Type ID) · 部署见 deployment.json · “谁都能用这个 cell,但谁都拿不走它”Source: gpBlockchain/comp-shared-lock @fd2370a contracts/comp-shared-lock/src/main.rs, json.rs, docs/contract-design.md · testnet 0xbc47…73c1 (type, Type ID) · deployment in deployment.json · "Anyone may use the Cell, but nobody may take the Cell"
Lock 脚本Lock script代理 / 工具Proxy / utility测试网Testnet开源Open source社区Community
贡献者:Contributed by @gpBlockchain @gpBlockchain

给 AI agent:For AI agents: comp_shared_lock.md · llms.txt

0 → 1创建 COMP 共享 cell(lock 不执行)Create a COMP shared cell (lock not executed)

Inputs 输入Inputs
任意资金 cellany funding cells由各自的 lock 解锁unlocked by their own locks
Outputs 输出Outputs
新 COMP cell(可一次建多个)new COMP cell(s) (several per tx allowed)Cell{ capacity: 任意(≥ 占用), lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: 应为 none, data: 任意 }Cell{ capacity: any (≥ occupied), lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: should be none, data: any }
lock.args 字节布局(40B,输入与后继必须逐字节相同)lock.args byte layout (40B, byte-identical in input and successor)
channel_hashoff 0 · 32B · Byte32
max_feeoff 32 · 8B · u64 LE
  • channel_hashoff 0 · 32B · Byte32应用状态 / 频道标识,合约不解释其内容application state / channel id; opaque to the lockargs 总长 = 40;后继 lock 不可改args length = 40; immutable in successor6 / 11
  • max_feeoff 32 · 8B · u64 LE单次转换 COMP cell 最多可损失的 capacity(shannon)max capacity the COMP cell may lose per transition (shannon)后继 capacity + max_fee ≥ 输入 capacitysuccessor capacity + max_fee ≥ input capacity12
channel_hash0x3bf471b16283375362945f60972e6dd4a998db34b53623457dcaa800b6a42726
max_fee0x40420f0000000000 = 1,000,000 shannon (0.01 CKB)
示例:deployment.json 的 sharedCell.lockArgs(共享 cell #0)Example: sharedCell.lockArgs in deployment.json (shared cell #0)

限制Constraints

  • —本合约不检查:输出上的 lock 在被花费前不会执行not checked by this contract: an output lock does not run until it is spent非合约规则:若创建时 args ≠ 40 字节或带了 type,该 cell 以后每次花费都会失败(6 / 10),等于永久锁死。测试网上有一次建 10 个、40 个 COMP cell 的创建交易,例如 0x6a2af0eb…7a15。Not a contract rule: if a cell is created with args ≠ 40 bytes or with a type, every later spend fails (6 / 10), locking it forever. Testnet has creation txs making 10 or 40 COMP cells at once, e.g. 0x6a2af0eb…7a15.

1 → 1匿名消息 / 更新(任何人可发)Anonymous message / update (anyone)

Inputs 输入Inputs
COMP 共享 cell(group 输入,唯一)COMP shared cell (group input, the only one)Cell{ capacity: C, lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: none, data: 任意 } since: 0x8000000000000001Cell{ capacity: C, lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: none, data: any } since: 0x8000000000000001
witness[group 0](可选)witness[group 0] (optional)缺省,或 WitnessArgs{ lock: None / 空 / {"public_key":null,"signature":null, "extensions":{…}} }absent, or WitnessArgs{ lock: None / empty / {"public_key":null,"signature":null, "extensions":{…}} }
cell_depsCOMP 代码 cell(Type ID 单例) 0x54d0bc54…db64:0 dep_type codeCOMP code cell (Type ID singleton) 0x54d0bc54…db64:0 dep_type code
Outputs 输出Outputs
后继 COMP cell(唯一)successor COMP cell (the only one)Cell{ capacity: ≥ C − max_fee, lock: 与输入相同(不可改), type: none, data: 新数据(不检查) }Cell{ capacity: ≥ C − max_fee, lock: same as input (immutable), type: none, data: new data (unchecked) }
其他输出other outputs不能再有任何 COMP lock 输出no other COMP-locked output
input.since(8B u64,必须恰好 = 0x8000000000000001)input.since (8B u64, must equal exactly 0x8000000000000001)
relative flagbit 63
metricbit 61–62
valuebit 0–55
  • relative flagbit 631 = 相对1 = relative必须为 1must be 116
  • metricbit 61–6200 = 区块号00 = block number必须为区块号must be block number16
  • valuebit 0–55相对区块数relative block count必须 = 1(0、2、绝对 1 都拒绝)must be 1 (0, 2, absolute 1 rejected)16
since0x8000000000000001
效果:在区块 H 创建的 COMP cell 最早在 H+1 才能被花费,每条 cell 谱系每个区块最多一次转换(不是全局配额)。Effect: a COMP cell created in block H is first spendable in H+1, so each cell lineage advances at most once per block (not a global quota).
witness[group 0]:WitnessArgs.lock = UTF-8 JSON 消息witness[group 0]: WitnessArgs.lock = UTF-8 JSON message
public_key"0x"+66 hex · 33B
signature"0x"+130 hex · 65B
extensionsraw JSON
  • public_key"0x"+66 hex · 33B压缩 SEC1 secp256k1 公钥(0x02/0x03 ‖ x),与 CKB 地址无关;可省略 0x,大小写 hex 都接受compressed SEC1 secp256k1 key (0x02/0x03 ‖ x), independent of CKB addresses; 0x optional, either hex case accepted字符串或 null;与 signature 同时存在 / 同时缺省;长度恰好 33 字节string or null; present together with signature; exactly 33 bytes13 / 14
  • signature"0x"+130 hex · 65Br[32] ‖ s[32] ‖ recid[1],recid ∈ {0..3, 27, 28}r[32] ‖ s[32] ‖ recid[1], recid ∈ {0..3, 27, 28}恢复出的压缩公钥必须等于 public_keyrecovered compressed key must equal public_key14 / 15
  • extensionsraw JSON应用载荷,必须是 object 或 array;签名时按原样字节参与哈希application payload, object or array; hashed as raw bytes when signed签名消息必须存在;三个已知键都不可重复required for signed messages; none of the three known keys may repeat14
anonymous{"public_key":null,"signature":null,"extensions":{"protocol":"comp","version":2,"type":"text","payload":"hello"}}
signed{"public_key":"0x03e07dfd…ba61","signature":"0xb544e24f…25cb01","extensions":{"protocol":"comp","version":2,"type":"text","payload":"test"}}
示例来自测试网 tx 0xac085cab…8d01(匿名)与 0x07a093a2…d50b(签名)。未知顶层键会被语法校验后忽略。Examples from testnet tx 0xac085cab…8d01 (anonymous) and 0x07a093a2…d50b (signed). Unknown top-level keys are syntax-checked then ignored.

限制Constraints

  • scriptload_script 成功load_script succeedsError::Encoding;所有 syscall 失败(since / type / capacity / tx_hash 读取)也映射为 4Error::Encoding; every syscall failure (since / type / capacity / tx_hash load) also maps to 44
  • script.args长度 = 40(channel_hash 32B ‖ max_fee u64 LE)length = 40 (channel_hash 32B ‖ max_fee u64 LE)6
  • GroupInput恰好 1 个(不可合并)exactly 1 (no merge)8
  • group input since= 0x8000000000000001(相对 1 个区块)= 0x8000000000000001 (relative 1 block)16
  • inputs同 code_hash + hash_type 的 COMP 输入在整笔交易里只能有 1 个(不同 args 的其他 COMP cell 也不行)only 1 input in the whole tx may use the COMP code_hash + hash_type (other COMP cells with different args included)7
  • outputs同 code_hash + hash_type 的输出恰好 1 个(后继;0 = 销毁,≥2 = 分叉)exactly 1 output with the COMP code_hash + hash_type (successor; 0 = destroy, ≥2 = fork)9
  • input.type / successor.type都必须为空both must be absent10
  • successor.lock与输入 lock 逐字节相同(code_hash、hash_type、args)byte-identical to the input lock (code_hash, hash_type, args)后继按 code_hash + hash_type 查找,所以改了 args 的后继报 11 而不是 9the successor is found by code_hash + hash_type, so a successor with changed args fails with 11, not 911
  • successor.capacity+ max_fee ≥ 输入 capacity(checked_add,溢出视为通过;可增加)+ max_fee ≥ input capacity (checked_add; overflow passes; may increase)12
  • outputs_data[successor]不检查(应用自定义)not checked (application-owned)
  • witness[group 0]不存在 → 匿名通过;存在但不是合法 WitnessArgs(包括空 0x)→ 失败missing → anonymous pass; present but not valid WitnessArgs (including empty 0x) → fail14
  • WitnessArgs.lockNone 或空 → 匿名通过;否则必须是 UTF-8 且是完整 JSON objectNone or empty → anonymous pass; otherwise must be UTF-8 and a complete JSON object14
  • JSONpublic_key / signature 必须是字符串或 null,extensions 必须是 object / array / null;三者都不可重复;不允许尾随字节;嵌套 < 64public_key / signature must be string or null, extensions object / array / null; none may repeat; no trailing bytes; nesting < 64即使是匿名消息也会先做这一步语法校验applies to anonymous messages too14
  • public_key, signature都为 null / 缺省 → 匿名通过;只有一个 → 失败both null / absent → anonymous pass; exactly one → fail13

1 → 1签名消息(compressed 公钥 + 可恢复签名)Signed message (compressed public key + recoverable signature)

Inputs 输入Inputs
COMP 共享 cell(group 输入,唯一)COMP shared cell (group input, the only one)Cell{ capacity: C, lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: none, data: 任意 } since: 0x8000000000000001Cell{ capacity: C, lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: none, data: any } since: 0x8000000000000001
witness[group 0]WitnessArgs{ lock: { "public_key": 0x02|03…(33B), "signature": 0x…(65B), "extensions": {…} } }WitnessArgs{ lock: { "public_key": 0x02|03… (33B), "signature": 0x… (65B), "extensions": {…} } }
cell_depsCOMP 代码 cell(Type ID 单例) 0x54d0bc54…db64:0 dep_type codeCOMP code cell (Type ID singleton) 0x54d0bc54…db64:0 dep_type code
Outputs 输出Outputs
后继 COMP cell(唯一)successor COMP cell (the only one)Cell{ capacity: ≥ C − max_fee, lock: 与输入相同(不可改), type: none, data: 新数据(不检查) }Cell{ capacity: ≥ C − max_fee, lock: same as input (immutable), type: none, data: new data (unchecked) }
witness[group 0]:WitnessArgs.lock = UTF-8 JSON 消息witness[group 0]: WitnessArgs.lock = UTF-8 JSON message
public_key"0x"+66 hex · 33B
signature"0x"+130 hex · 65B
extensionsraw JSON
  • public_key"0x"+66 hex · 33B压缩 SEC1 secp256k1 公钥(0x02/0x03 ‖ x),与 CKB 地址无关;可省略 0x,大小写 hex 都接受compressed SEC1 secp256k1 key (0x02/0x03 ‖ x), independent of CKB addresses; 0x optional, either hex case accepted字符串或 null;与 signature 同时存在 / 同时缺省;长度恰好 33 字节string or null; present together with signature; exactly 33 bytes13 / 14
  • signature"0x"+130 hex · 65Br[32] ‖ s[32] ‖ recid[1],recid ∈ {0..3, 27, 28}r[32] ‖ s[32] ‖ recid[1], recid ∈ {0..3, 27, 28}恢复出的压缩公钥必须等于 public_keyrecovered compressed key must equal public_key14 / 15
  • extensionsraw JSON应用载荷,必须是 object 或 array;签名时按原样字节参与哈希application payload, object or array; hashed as raw bytes when signed签名消息必须存在;三个已知键都不可重复required for signed messages; none of the three known keys may repeat14
anonymous{"public_key":null,"signature":null,"extensions":{"protocol":"comp","version":2,"type":"text","payload":"hello"}}
signed{"public_key":"0x03e07dfd…ba61","signature":"0xb544e24f…25cb01","extensions":{"protocol":"comp","version":2,"type":"text","payload":"test"}}
示例来自测试网 tx 0xac085cab…8d01(匿名)与 0x07a093a2…d50b(签名)。未知顶层键会被语法校验后忽略。Examples from testnet tx 0xac085cab…8d01 (anonymous) and 0x07a093a2…d50b (signed). Unknown top-level keys are syntax-checked then ignored.
签名摘要(签名消息才计算)signing digest (signed messages only)
message_hash32B
signing_digest32B
  • message_hash32BCKB_BLAKE2B(65 个 0x00 ‖ extensions 原始字节)CKB_BLAKE2B(65 zero bytes ‖ raw extensions bytes)15
  • signing_digest32BCKB_BLAKE2B(tx_hash ‖ message_hash);tx_hash 覆盖 inputs、outputs、outputs_data、deps、since,不含 witnessCKB_BLAKE2B(tx_hash ‖ message_hash); tx_hash commits to inputs, outputs, outputs_data, deps, since, not witnessessecp256k1 recover_from_prehash(digest, sig, recid) == public_keysecp256k1 recover_from_prehash(digest, sig, recid) == public_key15
CKB_BLAKE2B = blake2b-256,personal "ckb-default-hash"。public_key 不参与摘要,靠恢复结果相等来绑定。CKB_BLAKE2B = blake2b-256 with personal "ckb-default-hash". public_key is not hashed; it is bound by equality with the recovered key.

限制Constraints

  • scriptload_script 成功load_script succeedsError::Encoding;所有 syscall 失败(since / type / capacity / tx_hash 读取)也映射为 4Error::Encoding; every syscall failure (since / type / capacity / tx_hash load) also maps to 44
  • script.args长度 = 40(channel_hash 32B ‖ max_fee u64 LE)length = 40 (channel_hash 32B ‖ max_fee u64 LE)6
  • GroupInput恰好 1 个(不可合并)exactly 1 (no merge)8
  • group input since= 0x8000000000000001(相对 1 个区块)= 0x8000000000000001 (relative 1 block)16
  • inputs同 code_hash + hash_type 的 COMP 输入在整笔交易里只能有 1 个(不同 args 的其他 COMP cell 也不行)only 1 input in the whole tx may use the COMP code_hash + hash_type (other COMP cells with different args included)7
  • outputs同 code_hash + hash_type 的输出恰好 1 个(后继;0 = 销毁,≥2 = 分叉)exactly 1 output with the COMP code_hash + hash_type (successor; 0 = destroy, ≥2 = fork)9
  • input.type / successor.type都必须为空both must be absent10
  • successor.lock与输入 lock 逐字节相同(code_hash、hash_type、args)byte-identical to the input lock (code_hash, hash_type, args)后继按 code_hash + hash_type 查找,所以改了 args 的后继报 11 而不是 9the successor is found by code_hash + hash_type, so a successor with changed args fails with 11, not 911
  • successor.capacity+ max_fee ≥ 输入 capacity(checked_add,溢出视为通过;可增加)+ max_fee ≥ input capacity (checked_add; overflow passes; may increase)12
  • outputs_data[successor]不检查(应用自定义)not checked (application-owned)
  • witness[group 0]不存在 → 匿名通过;存在但不是合法 WitnessArgs(包括空 0x)→ 失败missing → anonymous pass; present but not valid WitnessArgs (including empty 0x) → fail14
  • WitnessArgs.lockNone 或空 → 匿名通过;否则必须是 UTF-8 且是完整 JSON objectNone or empty → anonymous pass; otherwise must be UTF-8 and a complete JSON object14
  • JSONpublic_key / signature 必须是字符串或 null,extensions 必须是 object / array / null;三者都不可重复;不允许尾随字节;嵌套 < 64public_key / signature must be string or null, extensions object / array / null; none may repeat; no trailing bytes; nesting < 64即使是匿名消息也会先做这一步语法校验applies to anonymous messages too14
  • public_key, signature都为 null / 缺省 → 匿名通过;只有一个 → 失败both null / absent → anonymous pass; exactly one → fail13
  • extensions签名消息必须存在且非 nullmust be present and non-null for signed messages14
  • public_keyhex(0x 可选)解码后恰好 33 字节hex (0x optional) decodes to exactly 33 bytes14
  • signaturehex(0x 可选)解码后恰好 65 字节hex (0x optional) decodes to exactly 65 bytes14
  • signature[0..64]是合法 (r, s)valid (r, s)15
  • signature[64]recid ∈ {0,1,2,3,27,28}(27/28 减 27)recid ∈ {0,1,2,3,27,28} (27/28 minus 27)15
  • recovered key= public_key(压缩形式逐字节比较)= public_key (compressed, byte comparison)15

1+N → 1+M赞助 / 充值(capacity 增加)Sponsor / top-up (capacity increases)

Inputs 输入Inputs
COMP 共享 cell(group 输入,唯一)COMP shared cell (group input, the only one)Cell{ capacity: C, lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: none, data: 任意 } since: 0x8000000000000001Cell{ capacity: C, lock: COMP_LOCK{ args: channel_hash ‖ max_fee }, type: none, data: any } since: 0x8000000000000001
赞助方输入sponsor inputs普通 lock 的 cell, 由其自身 lock + witness 解锁normal-lock cells, unlocked by their own lock + witness
Outputs 输出Outputs
后继 COMP cell(唯一)successor COMP cell (the only one)Cell{ capacity: ≥ C − max_fee(可 > C), lock: 与输入相同(不可改), type: none, data: 新数据(不检查) }Cell{ capacity: ≥ C − max_fee (may be > C), lock: same as input (immutable), type: none, data: new data (unchecked) }
找零change普通 lock,不能是 COMP locknormal lock, must not be COMP

限制Constraints

  • scriptload_script 成功load_script succeedsError::Encoding;所有 syscall 失败(since / type / capacity / tx_hash 读取)也映射为 4Error::Encoding; every syscall failure (since / type / capacity / tx_hash load) also maps to 44
  • script.args长度 = 40(channel_hash 32B ‖ max_fee u64 LE)length = 40 (channel_hash 32B ‖ max_fee u64 LE)6
  • GroupInput恰好 1 个(不可合并)exactly 1 (no merge)8
  • group input since= 0x8000000000000001(相对 1 个区块)= 0x8000000000000001 (relative 1 block)16
  • inputs同 code_hash + hash_type 的 COMP 输入在整笔交易里只能有 1 个(不同 args 的其他 COMP cell 也不行)only 1 input in the whole tx may use the COMP code_hash + hash_type (other COMP cells with different args included)7
  • outputs同 code_hash + hash_type 的输出恰好 1 个(后继;0 = 销毁,≥2 = 分叉)exactly 1 output with the COMP code_hash + hash_type (successor; 0 = destroy, ≥2 = fork)9
  • input.type / successor.type都必须为空both must be absent10
  • successor.lock与输入 lock 逐字节相同(code_hash、hash_type、args)byte-identical to the input lock (code_hash, hash_type, args)后继按 code_hash + hash_type 查找,所以改了 args 的后继报 11 而不是 9the successor is found by code_hash + hash_type, so a successor with changed args fails with 11, not 911
  • successor.capacity+ max_fee ≥ 输入 capacity(checked_add,溢出视为通过;可增加)+ max_fee ≥ input capacity (checked_add; overflow passes; may increase)12
  • sponsor inputs不能是 COMP lock(否则 7)must not use the COMP lock (else 7)资金规则(总输入 ≥ 总输出 + 手续费)由 CKB 共识检查,不是本合约;本合约只限制 COMP cell 自己最多损失 max_fee。测试网上暂未找到这种交易,按 docs/contract-design.md 的“Sponsor”场景整理。Funding (total inputs ≥ outputs + fee) is a CKB consensus rule, not this contract; the lock only bounds the COMP cell's own loss by max_fee. No such tx was found on testnet; this card follows the "Sponsor" scenario in docs/contract-design.md.7

✗被拒绝的形态:合并 / 分叉 / 销毁 / 改 lock / 加 type / 超额扣费Rejected shapes: merge / fork / destroy / change lock / add type / overspend

Inputs 输入Inputs
COMP 输入COMP inputs2 个同 lock → 8 2 个不同 args → 7 since ≠ 相对 1 → 162 with same lock → 8 2 with different args → 7 since ≠ relative 1 → 16
Outputs 输出Outputs
COMP 输出COMP outputs0 个(销毁 / 取走)→ 9 ≥ 2 个(分叉)→ 9 args 改动 → 11 带 type → 10 capacity < C − max_fee → 120 (destroy / take) → 9 ≥ 2 (fork) → 9 changed args → 11 with type → 10 capacity < C − max_fee → 12

限制Constraints

  • —没有任何“回收 / 关闭”路径:COMP cell 只要存在就只能被续写no reclaim / close path: a COMP cell can only be continued, never removed仓库 scripts/reclaim.mjs 只能回收普通 cell,不能绕过本合约(未逐行核对脚本)。max_fee 只限制单次损失,不限制总损失:反复转换可以把 capacity 逐步消耗到最低占用。The repo's scripts/reclaim.mjs cannot bypass this lock (script not reviewed line by line). max_fee bounds per-transition loss only; repeated transitions can drain capacity down to the occupied minimum.9
部署与来源Deployments & source 未核验unverified
源码source
gpBlockchain/comp-shared-lock@fd2370ab · contracts/comp-shared-lock/src/main.rs · contracts/comp-shared-lock/src/json.rs · docs/contract-design.md · docs/wall-binary-payload.md · deployment.json (default-branch (master) HEAD read on 2026-11-12; contract source last changed in 1898f9d (2026-08-21, v0.3.0). Deployment from deployment.json (identical to frontend/public/deployment.json): Type ID code cell, upgraded once in 0x54d0bc54… (dataHash 0x47cf5e… → 0x81dae1…). Not surfaced by ckb-talk-radar; added at user request.)
二进制核验binary check
未核验unverified hash appears in the repo only as a deployment record or doc, which does not prove the recorded commit builds this binary (reproducible build not attempted)
0x81dae172b4…b600c4d8: listed in deployment.json; listed in plugins/comp-shared-lock/skills/comp-shared-lock/deployment.json
网络networkcode_hashcell_deptype_id args数据哈希data hash部署交易deploy tx
testnet0xbc475946ff0e50276ca152c423cc260b8817de1c42a3be2eafffc55765f873c1 type0x54d0bc5469…9651db64:0 code0xecf583fa79…5fb5a2c00x81dae172b4…b600c4d80x54d0bc5469…9651db64 #22154878
链上数据核对于 on-chain data checked 2026-11-12
错误码来自 main.rs 的 enum Error(#[repr(i8)]):1 IndexOutOfBound、2 ItemMissing、3 LengthNotEnough、4 Encoding、6 ArgsEncoding、7 MultipleLockGroups、8 InvalidInputCount、9 InvalidSuccessorCount、10 TypeScriptNotAllowed、11 LockMismatch、12 CapacityExceeded、13 InvalidIdentity、14 WitnessFormat、15 SignatureInvalid、16 InvalidSince。5 没有定义;1–3 在源码里从不返回,只有 4 用于 syscall 失败。Error codes from enum Error in main.rs (#[repr(i8)]): 1 IndexOutOfBound, 2 ItemMissing, 3 LengthNotEnough, 4 Encoding, 6 ArgsEncoding, 7 MultipleLockGroups, 8 InvalidInputCount, 9 InvalidSuccessorCount, 10 TypeScriptNotAllowed, 11 LockMismatch, 12 CapacityExceeded, 13 InvalidIdentity, 14 WitnessFormat, 15 SignatureInvalid, 16 InvalidSince. 5 is unused; 1–3 are never returned, only 4 is used for syscall failures.
检查顺序(与 enum 顺序不同):6 args → 8 group 输入数 → 16 since → 7 COMP 输入数 → 9 后继数 → 10 type → 11 lock → 12 capacity → 14/13/15 witness。所以同时违反多条时报最先命中的那个,例如两个同 lock 的 COMP 输入报 8 而不是 7。Check order (differs from the enum order): 6 args → 8 group input count → 16 since → 7 COMP input count → 9 successor count → 10 type → 11 lock → 12 capacity → 14/13/15 witness. When several rules fail, the first one wins, e.g. two COMP inputs with the same lock fail with 8, not 7.
注释 / 文档与代码不一致:README 写 message_bytes = [0;65] ‖ utf8(compact_json(extensions)),main.rs 注释写 canonical_encode(...),但代码直接哈希 witness 里 extensions 的原始字节,不做压缩或规范化(docs/contract-design.md 写的 raw_json(extensions) 才对)。签名方必须对写进 witness 的原样字节签名。README 的“Validation rules”列表顺序也与实际检查顺序不同(since 列在第 8 条,实际第 3 个检查)。Comment / doc vs code: README says message_bytes = [0;65] ‖ utf8(compact_json(extensions)) and the main.rs comment says canonical_encode(...), but the code hashes the raw extensions bytes exactly as they appear in the witness, with no compaction or canonicalization (docs/contract-design.md's raw_json(extensions) is the accurate one). Signers must sign the exact bytes written to the witness. README's "Validation rules" list is also not in execution order (since is rule 8 there but the 3rd check in code).
空 witness(0x)不是“没有 witness”:ckb-std load_witness_args 解析空字节失败 → 14。只有 witness 槽位不存在(下标越界)或 WitnessArgs.lock 为 None / 空才算匿名。An empty witness (0x) is not "no witness": ckb-std load_witness_args fails to parse empty bytes → 14. Only a missing witness slot (index out of bound) or a None / empty WitnessArgs.lock counts as anonymous.
extensions.payload 的格式(comp text、comp-wall v1 JSON、v2 "CW2:"+base64 二进制,见 docs/wall-binary-payload.md)全是前端约定,链上合约不检查;解码器只显示 protocol / version / type 和 payload 长度。The extensions.payload formats (comp text, comp-wall v1 JSON, v2 "CW2:"+base64 binary per docs/wall-binary-payload.md) are frontend conventions; the on-chain lock does not check them. The decoder only shows protocol / version / type and the payload length.
部署:COMP lock 的 code_hash 是 Type ID 脚本哈希(hash_type type),代码 cell 在 0x54d0bc54…db64:0(2026-08-21 升级,dataHash 0x47cf5e… → 0x81dae1…)。升级前(区块 22154878 之前)的测试网交易 since = 0,旧二进制不要求 since;解码器按当前规则会把它们标成 16。README 里的 v0.1 data2 部署(0x43fd…12d9)是旧 witness 格式,未收录。Deployment: the COMP lock code_hash is the Type ID script hash (hash_type type); the code cell is 0x54d0bc54…db64:0 (upgraded 2026-08-21, dataHash 0x47cf5e… → 0x81dae1…). Testnet txs before the upgrade (block < 22154878) use since = 0, which the old binary did not require; the decoder flags them with 16 under the current rules. The README's v0.1 data2 deployment (0x43fd…12d9) uses the old witness schema and is not included.
二进制未核验:链上 data_hash 与 deployment.json 记录一致,但仓库没有提交二进制或 checksum;本地用 rust 1.95.0 + Makefile 的 RUSTFLAGS 在 fd2370a 重编译得到 131672 字节,与链上 131984 字节不同,未能复现。解码器离线检查 args、since、COMP 输入/输出数、type、lock、capacity、witness JSON 结构;secp256k1 恢复为 NOT_CHECKED(会显示 signing_digest)。Binary unverified: the on-chain data_hash matches the deployment.json record, but the repo commits no binary or checksum; rebuilding fd2370a locally with rust 1.95.0 and the Makefile RUSTFLAGS gave 131672 bytes vs 131984 on chain, so the build was not reproduced. The decoder checks args, since, COMP input/output counts, type, lock, capacity and witness JSON shape offline; secp256k1 recovery is NOT_CHECKED (signing_digest is shown).