CKB Pulse
经验

CKB 学到了什么

从这里开始 · 术语表 · 自测 · 订阅

经验用英文撰写,请用英文搜索。

实践

找到 174 条经验。 全部经验

第 3 页,共 15 页

Reset devnets instead of skewing the chain clock实践来自一次修复

Pushing devnet timestamps ahead leaves the chain clock skewed for every later run, which stalls services that compare the tip with wall time. Reset the devnet for each scenario. At the start, assert that |tip timestamp − now| is small, for example under 600 s.

#Testing and devnet #Since and time locks · 来源(1) · 2026-11-15

Witness data in input_type and folding sub-minimum change实践来自一次修复

Put the type script's witness data in WitnessArgs.input_type of each input it guards (the type script reads the first witness of its own input group), so the lock field stays free for the wallet's signature and one signature can cover several such inputs. If the change left after a fixed fee is below a plain cell's minimum occupied capacity, add it to an existing output whose scripts accept extra capacity; if there is no such output, refuse the build instead of creating a cell that cannot exist.

#Witnesses and signatures #Transaction building and fees #Capacity and cell size · 来源(1) · 2026-11-14

Hand-encoding WitnessArgs in molecule实践来自一次修复

WitnessArgs is a molecule table of three BytesOpt fields (lock, input_type, output_type). An absent field takes zero bytes, but a present empty field still takes a 4-byte length header, so the two encode differently. The table starts with a u32le total size, then three u32le offsets, the first being 16 (4 + 4*3), each counted from the start of the table. Check any hand-written encoder byte for byte against ccc.WitnessArgs.from(...).toBytes(), including the cases lock only, all absent, and a present empty field.

#Data encoding (molecule, hex, bigints) #Witnesses and signatures · 来源(1) · 2026-11-14

ckb-debugger verifies one script group per run实践来自一次修复

`full` is a VM mode, and by default ckb-debugger runs only input 0's lock, which may be an always-success lock. To check a whole transaction, enumerate every input lock, input type and output type group, run each with --script-group-type/--cell-type/--cell-index, and sum the cycles. Pair each accepted case with a control that must fail with an exact error code.

#Testing and devnet #Transaction building and fees · 来源(1) · 2026-11-14

Mock transactions must expand dep_group members实践来自一次修复

In a ckb-debugger mock_info, list the dep_group cell with dep_type "dep_group" (data included) and also list each member out point as a separate cell dep with dep_type "code", with its data. Get the members by decoding the group cell's data as a molecule OutPoint vector: a u32 LE count, then per entry a 32-byte tx hash and a u32 LE index (36 bytes each), and check that the length is 4 + 36*count bytes.

#Testing and devnet #Cell deps and script lookup #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-14

Release asset names differ per CKB tool实践来自一次修复

ckb, ckb-cli and ckb-debugger use `<tool>_<tag>_<triple>[-portable].<ext>`, while fnn and ckb-light-client use `<tool>_<tag>-<arch>-<os>[-portable].tar.gz`. ckb-debugger ships .tar.gz on every OS with a `<stem>-sha256.txt` and has no x86_64 macOS build, and ckb-cli ships .zip on macOS and Windows with no sums file. Try an ordered list of candidate names, including portable variants, against the release's actual asset list.

#Other · 来源(2) · 2026-11-14

Devnet tests need a real secp256k1 lock to exercise signing实践来自一次修复

Under an always-success lock, a test never checks that the signature covers the witnesses. That matters most when contract data shares a WitnessArgs with the signature, for example in inputType. Move the test cells to a secp256k1 lock, using its code cell and dep group from genesis, and sign with ccc.SignerCkbPrivateKey. The 20-byte lock args need 6 more CKB of capacity than the 14-byte fixture args.

#Witnesses and signatures #Testing and devnet #Capacity and cell size · 来源(1) · 2026-11-14

Nervos DAO hold time with term-locked withdrawals实践来自一次修复

The Nervos DAO pays out phase 2 only at a whole number of 180-epoch cycles counted from the deposit epoch D, so a withdrawal started after D + 180×n matures at D + 180×(n+1). If a lock refuses phase 1 until a term of n cycles has passed, then in practice the funds are held (n + 1) × 180 epochs, not n × 180, and interest stops at the phase 1 block. Only a phase 1 that lands exactly in the boundary epoch fraction avoids the extra cycle.

#Since and time locks #Other · 来源(1) · 2026-11-13

Pinning JS codecs and derivations to Rust test vectors实践来自一次修复

When off-chain JS encodes or derives cell data that a Rust type script decodes or re-derives byte for byte, test the JS against JSON vectors generated by the Rust code, using a distinct value in every field so a wrong offset fails. Mirror the contract's validation refusals and its exact ordering and rounding: BTreeMap ascending key order, BigInt floor division with the dust going to fixed indices, and merging duplicates before dividing. The chain only returns a bare error code, so only this off-chain check can tell you which rule failed.

#Data encoding (molecule, hex, bigints) #Testing and devnet #Transaction building and fees · 来源(2) · 2026-11-13

Nervos DAO phase-one withdrawal layout实践来自一次修复

In phase one, output i must mirror deposit input i (same capacity, lock and DAO type), with its data set to the deposit block number as a u64 LE, and the deposit block hash must be in header_deps. Put any fee-paying input and output after all deposits. A custom lock that enforces a full 180-epoch term before phase one pushes payout to the next cycle boundary (about deposit + 360 epochs, roughly 60 days).

#Since and time locks #Transaction building and fees #Cell deps and script lookup · 来源(1) · 2026-11-13

Nervos DAO phase-two withdrawal since and amount实践来自一次修复

Set the phase-two input since to an absolute epoch counted from the DEPOSIT header, not the withdrawing block. Round the elapsed epochs up to whole 180-epoch cycles, compare epoch fractions by cross-multiplication, and keep the deposit's epoch index and length. The withdrawable amount is occupied + (capacity − occupied) × AR_withdraw / AR_deposit, where AR is a little-endian u64 read from bytes 8..16 of each header's dao field. WitnessArgs.input_type must hold the deposit header's index in header_deps as an 8-byte little-endian u64.

#Since and time locks #Witnesses and signatures #Capacity and cell size · 来源(1) · 2026-11-13

Mirror on-chain rules off-chain with mutation tests实践来自一次修复

A CKB script that refuses a transaction returns only an error code that names no rule, so port the contract's witness decoders to JS with the same refusals (bad version, truncation, trailing bytes, count or size limits). Check that they round-trip bytes produced by the Rust code. Before signing, run a checker that re-derives the contract's rules from the finished transaction, and pin each rule with a mutation test that breaks one field of a valid transaction and expects that rule's named reason.

#Testing and devnet #Data encoding (molecule, hex, bigints) #Since and time locks · 来源(1) · 2026-11-13

第 3 页,共 15 页

文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 JSON · 想修改或撤下某条经验?请提交 issue。