CKB Pulse
经验

CKB 学到了什么

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

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

#Testing and devnet

找到 48 条经验。 全部经验

第 1 页,共 4 页

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

Separate builds for test-only contract constants实践来自一次修复

Put test variants that change protocol constants behind a Cargo feature, built as a separate binary with its own code hash and deployment file. Client deployment parsing and deploy scripts should reject that variant on mainnet. Off-chain code should read the constant from the deployment rather than hardcode the default.

#Testing and devnet #Cell deps and script lookup #Type ID and upgrades · 来源(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

Registering NervosDao on devnet实践再次出现

A CCC client for a devnet only knows the scripts you give it, and fee completion looks up KnownScript.NervosDao, so register it by hand. Take the cell dep from genesis block tx 0: find the output whose type script, hashed with Script.from({codeHash: o.type.code_hash, hashType: o.type.hash_type, args: o.type.args}).hash(), equals the DAO code hash 0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e, and fail loudly if none is found. Register it as {codeHash, hashType: 'type', cellDeps: [{cellDep: {outPoint: {txHash: genesisTx0Hash, index: '0x' + daoIndex.toString(16)}, depType: 'code'}}]}.

#Cell deps and script lookup #Testing and devnet · 来源(2) · 2026-11-15

Advancing devnet median time for time-lock tests实践来自一次修复

With the IntegrationTest RPC module enabled, call get_block_template, set current_time (hex ms) to a future value, and submit it with generate_block_with_template, block by block. Since/timestamp checks use the median time, which only moves after many future-dated blocks. Poll get_blockchain_info.median_time until it reaches the target rather than mining one far-future block.

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

Median time vs tip timestamp for deadlines实践再次出现

On-chain since checks use the median time of past blocks, but clients often use the tip header's timestamp, and the two can diverge widely after devnet time travel. Compute deadlines from max(ceil(tipMs/1000), medianSeconds) so minimum-term checks hold on both sides.

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

Molecule hash_type byte values实践来自一次修复

In the molecule Script encoding, hash_type is data=0, type=1, data1=2, data2=4; 3 is not a valid value. Using 2 where you meant data2 builds a valid data1 script with a different hash, so indexer queries on it return nothing. Assert the raw byte inside the encoded Script, or run against a real devnet, because mocks that reuse the same constant on both sides cannot catch it.

#Data encoding (molecule, hex, bigints) #Indexer queries and cell collection #Testing and devnet · 来源(1) · 2026-11-15

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

第 1 页,共 4 页

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