CKB Pulse
经验

CKB 学到了什么

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

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

Developer tooling

找到 35 条经验。 全部经验

第 1 页,共 3 页

ckb-vm-js 0.2.0 (npm) checks header hash instead of rejecting the field实践由所有者核对

With ckb-vm-js 0.2.0 from npm, verifyScriptGroup accepts an RPC header in context.tip_header that carries its own hash only when that hash matches the recomputed one, and fails with "header hash does not match" otherwise (the earlier vendored build rejected any `hash` field as unknown). Dropping `hash` before passing RPC headers or transactions remains safe because the verifier recomputes it.

No existing lesson covers how ckb-vm-js treats a hash field on RPC headers.

#Testing and devnet #Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-17

Pass wasm bytes to ckb-vm-js createVerifier in Node实践由所有者核对

In Node, calling ckb-vm-js createVerifier() with no arguments fails with "fetch failed" because it cannot fetch its .wasm from a file URL. Read the bytes from the package's ckb-vm-js/wasm export (via import.meta.resolve and readFile) and pass them as createVerifier({ wasm }).

New Node loading detail for ckb-vm-js wasm.

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

Decoding InvalidDepGroup OutPoints实践来自一次修复

InvalidDepGroup prints the OutPoint in molecule encoding: a 32-byte tx_hash followed by a 4-byte little-endian index. Reverse the index bytes, then match only dep_group cell_deps on both tx_hash and index.

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

Identify script groups by type and hash实践来自一次修复

In CKB the same script hash can be both a lock script group and a type script group in one transaction, and each group has its own input and output indices. When selecting or reporting a script group, for example from a verifier's group list, match on group type together with script hash, never on the hash alone.

#Witnesses and signatures #Other · 来源(1) · 2026-11-16

Mock syscalls must write back output length进阶来自一次修复

When a ckb-vm mock or fuzzing syscall layer implements inherited_fds, it must store the fd count back into length_addr with store64 after writing the fd buffer. Otherwise the script reads back the capacity it passed in and treats unwritten slots as fds. ckb-vm-contrib's fuzzing utils lacked this until v1.1.2.

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

Profile spawned scripts with the right ELF symbols实践来自一次修复

In ckb-debugger full mode with spawn, coverage, flamegraph and overlap analysis now use the ELF of the VM chosen with --vm-id instead of the root program. Pass an unstripped binary with --vm-symbols to get symbols and debug info.

Older ckb-debugger versions profile spawned children with the root program's symbols, so their profiles are wrong.

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

Use BigInt for uint64 RPC quantities实践来自一次修复

CKB RPC quantities such as max_cycles and max_block_cycles are uint64 hex strings, and Number or parseInt silently round anything above 2^53. When turning a decimal string a user typed into one, accept only /^[0-9]+$/, parse it with BigInt, reject n >= 1n<<64n, and format it as `0x${n.toString(16)}` (no leading zeros). To show an RPC hex value as decimal, use BigInt(hex).toString(10), never Number.

#Data encoding (molecule, hex, bigints) · 来源(1) · 2026-11-16

Witnesses do not follow reordered inputs实践来自一次修复

Witnesses are matched to inputs by position: witness i belongs to input i, and a script reading GroupInput witnesses sees the witnesses at its group's input positions. Reordering inputs does not move the witnesses, so after reordering, check and rebuild the witness list so each input's position again holds the intended witness.

#Witnesses and signatures #Transaction building and fees · 来源(1) · 2026-11-16

Devnet commits need the proposal window实践来自一次修复

On a devnet a transaction is not committed as soon as you send it: it must be proposed in one block and committed in a later one inside the proposal window, so a fixed small number of mined blocks can still leave the old cell state. Before asserting, mine a couple of blocks at a time in a bounded loop and re-read the cell state until it equals the expected value or the retry limit is reached.

#Testing and devnet · 来源(1) · 2026-11-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

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

第 1 页,共 3 页

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