CKBFS V3 约束(witness 文件存储,backlink 移入 witness)CKBFS V3 Constraints (witness file storage, backlinks moved into witnesses)
来源:code-monad/ckbfs @4ee6689(tag v3)contracts/ckbfs/src/entry.rs + contracts/ckb-adler32(mode 3) · data1 0xb5d1…d695(主网 + 测试网)Source: code-monad/ckbfs @4ee6689 (tag v3) contracts/ckbfs/src/entry.rs + contracts/ckb-adler32 (mode 3) · data1 0xb5d1…d695 (mainnet + testnet)
给 AI agent:For AI agents: ckbfs_v3.md · llms.txt
0 → 1发布(创建)Publish (create)
Inputs 输入Inputs
inputs[0]:任意inputs[0]: anyCellInput{ since, previous_output }
Outputs 输出Outputs
CKBFS cellCell{
type: { codeHash: CKBFS_V3, hashType: data1,
args: type_id 32B ‖ [hasher_code_hash 32B] },
data: CKBFSData { index, checksum, content_type, filename }
}
witnesses[index](head)"CKBFS" ‖ 0x03 ‖ prev tx_hash = 0×32 ‖ prev index = 0 ‖ prev checksum ‖ next ‖ content
witnesses[next] …next(4B, 0 = end) ‖ content
head witness 字节布局head witness byte layout
"CKBFS"5B
version1B
prev tx_hash32B
prev index4B
prev checksum4B
next4B
content…
- "CKBFS"5B魔数magic未被检查not checked—
- version1B协议版本protocol version= 0x03-101
- prev tx_hash32B上一版本所在 txtx of the previous version创建 = 0;更新 = 输入 out_point.tx_hashcreate = 0; update = input out_point.tx_hash112
- prev index4B上一 head witness 序号previous head witness index创建 = 0;更新 = 输入 data.indexcreate = 0; update = input data.index112
- prev checksum4BAdler-32 恢复点Adler-32 resume point0 = 从头计算0 = start fresh-101
- next4B下一个 witness 序号next witness index0 = 结束0 = end-101
- content…内容片段content part计入 checksumhashed into the checksum-101
data(molecule table CKBFSData)data (molecule table CKBFSData)
indexUint32
checksum4B LE
content_typeBytes
filenameBytes
- indexUint32head witness 序号head witness indexhead ≥ 50 字节head ≥ 50 bytes-3
- checksum4B LEAdler-32= witness 链计算结果= result over the witness chain-101
- content_typeBytesMIME之后不可变immutable afterwards105
- filenameBytes文件名file name之后不可变immutable afterwards105
限制Constraints
- type同一 tx 中该 type 的输出 ≤ 1≤ 1 output with this type in the tx107
- args≥ 32 字节;args[0..32] 按 type_id 规则≥ 32 bytes; args[0..32] by the type_id rule-3 / 102
- head witness存在且 ≥ 50 字节;上一位置全 0exists and ≥ 50 bytes; previous position all zero-1 / -3 / 112
- cell_deps含 data hash = 校验器 code hash 的 cell(解码器不检查)contains a cell whose data hash = the hasher code hash (not checked by the decoder)106
- checksumexec ckb-adler32 mode 3:head[50..] ‖ 沿 next 链各 witness[4..];prev checksum ≠ 0 时从它恢复;结果 = data.checksumexec ckb-adler32 mode 3: head[50..] ‖ witness[4..] along the next chain; resume from prev checksum when ≠ 0; result = data.checksum-101
1 → 1追加 / 转移Append / transfer
Inputs 输入Inputs
CKBFS cellCell{ type: CKBFS_V3, data: { index: i0, checksum: c0, content_type, filename } }
Outputs 输出Outputs
CKBFS cellCell{ type: same, data: { index: i1, checksum: c1, content_type, filename } }
witnesses[i1](head)"CKBFS" ‖ 0x03 ‖ input out_point.tx_hash ‖ i0 ‖ prev checksum ‖ next ‖ content
限制Constraints
- content_type / filename / args不变unchanged105
- head witness上一位置 = (输入 out_point.tx_hash, 输入 data.index)previous position = (input out_point.tx_hash, input data.index)112
- checksumc1 = c0 走“转移”分支,否则“追加”分支;两者都 exec 同一 mode 3 校验(adler32 忽略传入的恢复参数,只用 head 里的 prev checksum)c1 = c0 takes the "transfer" branch, otherwise "append"; both exec the same mode-3 check (adler32 ignores the passed resume argument and uses the head's prev checksum)-101
1 → 0销毁:禁止Destroy: forbidden
Inputs 输入Inputs
CKBFS cellCell{ type: CKBFS_V3 }
Outputs 输出Outputs
无 CKBFS 输出no CKBFS output—
限制Constraints
- type有输入无输出 → 失败input without output → fails103
部署与来源Deployments & source 未核验unverified
源码source
code-monad/ckbfs@4ee6689b · contracts/ckbfs/src/entry.rs · contracts/ckbfs/src/error.rs · contracts/ckbfs/src/hash.rs · contracts/ckb-adler32/src/process.rs · contracts/ckb-adler32/src/utils.rs (tag v3 / master HEAD read 2026-11-06. Repo has no record of data hash 0xb5d1…d695; chosen because the deployed dep_group adler32 hash 0xbd94…1db1 equals hash.rs from 3776e2a onward (exact build commit unproven). Data schema: crates.io ckbfs-types 0.3.0)
二进制核验binary check
未核验unverified no binary or checksum at the recorded commit matched the deployed data hash (reproducible build not attempted)
| 网络network | code_hash | cell_dep | type_id args | 数据哈希data hash | 部署交易deploy tx |
|---|---|---|---|---|---|
| mainnet | 0xb5d13ffe0547c78021c01fe24dce2e959a1ed8edbca3cb93dd2e9f57fb56d695 data1 | 0x03deba7f82…a50c4719:0 dep_group | 0xf5d1b146e7…5421a529 | 0xb5d13ffe05…fb56d695 | 0xd25f2c32f5…3d3c2853 #17071377 |
| testnet | 0xb5d13ffe0547c78021c01fe24dce2e959a1ed8edbca3cb93dd2e9f57fb56d695 data1 | 0x47cfa8d554…f3e95e61:0 dep_group | 0x55f1932d30…6c4a5249 | 0xb5d13ffe05…fb56d695 | 0x1488b592b0…002a9cfb #18252964 |
| mainnet | 0xcc5411e8b70e551d7a3dd806256533cff6bc12118b48dd7b2d5d2292c3651add type | 0x03deba7f82…a50c4719:0 dep_group | 0xf5d1b146e7…5421a529 | 0xb5d13ffe05…fb56d695 | 0xd25f2c32f5…3d3c2853 #17071377 |
| testnet | 0xaebf5a7b541da9603c2066a9768d3d18fea2e7f3c1943821611545155fecc671 type | 0x47cfa8d554…f3e95e61:0 dep_group | 0x55f1932d30…6c4a5249 | 0xb5d13ffe05…fb56d695 | 0x1488b592b0…002a9cfb #18252964 |
链上数据核对于 on-chain data checked 2026-11-06
版本:仓库没有写出 0xb5d1…d695 的发布记录(README 只列 V1/V2)。链上 V3 部署的 dep_group 里 ckb-adler32 data hash = 0xbd94…1db1,与 hash.rs 在 3776e2a 之后(含 931c477、tag v3 = 4ee6689)固定的值相同,所以按 tag v3 记录;具体构建提交未证实,未做可复现构建。Version: the repo has no release record for 0xb5d1…d695 (the README lists only V1/V2). The ckb-adler32 data hash in the on-chain V3 dep_group is 0xbd94…1db1, the value hash.rs pins from 3776e2a on (incl. 931c477 and tag v3 = 4ee6689), so tag v3 is recorded; the exact build commit is unproven and no reproducible build was attempted.
数据结构来自 crates.io ckbfs-types 0.3.0(schemas/ckbfs.mol);witness 布局见 RFC.v3.md 与 ckb-adler32 process.rs。The data layout comes from crates.io ckbfs-types 0.3.0 (schemas/ckbfs.mol); the witness layout from RFC.v3.md and ckb-adler32 process.rs.
按源码原样:error.rs 定义了 110 InvalidWitnessHeader / 111 InvalidVersion,但 entry.rs 没有使用;版本字节 ≠ 0x03 由 adler32 以 -101 拒绝,"CKBFS" 魔数不检查。As written: error.rs defines 110 InvalidWitnessHeader / 111 InvalidVersion but entry.rs never uses them; a version byte ≠ 0x03 is rejected by adler32 with -101, and the "CKBFS" magic is not checked.
ckbfs 不要求 head 里的 prev checksum 等于输入 checksum,adler32 直接用 head 中的值恢复。ckbfs does not require the head's prev checksum to equal the input checksum; adler32 resumes from the head value as given.
错误码:-1 IndexOutOfBound · -2 ItemMissing · -3 LengthNotEnough · -4 Encoding · 102 InvalidTypeId · 103 DeletionForbidden · 104 ChecksumMismatch(exec 失败)· 105 InvalidFieldUpdate · 106 NoChecksumHasherFound · 107 DuplicatedOutputs · 112 InvalidPreviousPosition;ckb-adler32:-101 ValidateFailureError codes: -1 IndexOutOfBound · -2 ItemMissing · -3 LengthNotEnough · -4 Encoding · 102 InvalidTypeId · 103 DeletionForbidden · 104 ChecksumMismatch (exec failed) · 105 InvalidFieldUpdate · 106 NoChecksumHasherFound · 107 DuplicatedOutputs · 112 InvalidPreviousPosition; ckb-adler32: -101 ValidateFailure
数据结构来自 crates.io ckbfs-types 0.3.0(schemas/ckbfs.mol);witness 布局见 RFC.v3.md 与 ckb-adler32 process.rs。The data layout comes from crates.io ckbfs-types 0.3.0 (schemas/ckbfs.mol); the witness layout from RFC.v3.md and ckb-adler32 process.rs.
按源码原样:error.rs 定义了 110 InvalidWitnessHeader / 111 InvalidVersion,但 entry.rs 没有使用;版本字节 ≠ 0x03 由 adler32 以 -101 拒绝,"CKBFS" 魔数不检查。As written: error.rs defines 110 InvalidWitnessHeader / 111 InvalidVersion but entry.rs never uses them; a version byte ≠ 0x03 is rejected by adler32 with -101, and the "CKBFS" magic is not checked.
ckbfs 不要求 head 里的 prev checksum 等于输入 checksum,adler32 直接用 head 中的值恢复。ckbfs does not require the head's prev checksum to equal the input checksum; adler32 resumes from the head value as given.
错误码:-1 IndexOutOfBound · -2 ItemMissing · -3 LengthNotEnough · -4 Encoding · 102 InvalidTypeId · 103 DeletionForbidden · 104 ChecksumMismatch(exec 失败)· 105 InvalidFieldUpdate · 106 NoChecksumHasherFound · 107 DuplicatedOutputs · 112 InvalidPreviousPosition;ckb-adler32:-101 ValidateFailureError codes: -1 IndexOutOfBound · -2 ItemMissing · -3 LengthNotEnough · -4 Encoding · 102 InvalidTypeId · 103 DeletionForbidden · 104 ChecksumMismatch (exec failed) · 105 InvalidFieldUpdate · 106 NoChecksumHasherFound · 107 DuplicatedOutputs · 112 InvalidPreviousPosition; ckb-adler32: -101 ValidateFailure