CKB Pulse
经验

CKB 学到了什么

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

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

来自一次修复

找到 155 条经验。 全部经验

第 3 页,共 13 页

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

Port CKB's sparse-merkle-tree byte for byte进阶来自一次修复

nervosnetwork/sparse-merkle-tree folds runs of empty siblings into MergeWithZero nodes (merge byte 2; a normal merge uses byte 1 plus height and parent path), and bit 0 of a key is the low bit of byte 0. Compiled proofs use the opcodes 0x4c, 0x50, 0x51, 0x4f n (n=0 means 256) and 0x48. Test any off-chain port against vectors generated by the Rust code.

#Data encoding (molecule, hex, bigints) #Testing and devnet · 来源(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

Wallet discovery with SignersController实践来自一次修复

To support every CCC wallet without the @ckb-ccc/connector UI, call `new ccc.SignersController().refresh(client, callback, {name, icon})`. Keep the callback registered and update the picker, because it fires again as EIP-6963 wallets announce themselves. Treat signers that are `instanceof ccc.SignerDummy` as download links, not connectable wallets.

Medium confidence.

#Witnesses and signatures #Login and authorization · 来源(1) · 2026-11-12

Preview network spec removed from CKB实践来自一次修复

The preview network is retired and specs/preview.toml has been removed. `ckb init --chain preview` is rejected, and configs using { bundled = "specs/preview.toml" } fail to load after upgrading. Point tooling and tests at testnet, staging or dev instead.

#Testing and devnet · 来源(1) · 2026-11-12

Validate header and epoch lookups before using timestamps实践来自一次修复

After get_header_by_number or get_epoch_by_number, treat a null result as unavailable and check that the returned number equals the one you asked for. To get an epoch's start time, read the header at the EpochView's start_number. Then check that this header's epoch field has the epoch number in its low 24 bits and 0 in bits 24 to 39 (the block's index within the epoch), so the block really is the first block of that epoch.

#Network and RPC reliability #Since and time locks #Data encoding (molecule, hex, bigints) · 来源(2) · 2026-11-12

第 3 页,共 13 页

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