CKB Pulse
Lições

O que a CKB aprendeu

Começa aqui · Glossário · Testa-te · Feed

As lições estão escritas em inglês, por isso pesquise em inglês.

#Testing and devnet

48 lições encontradas. Todas as lições

Página 1 de 4

ckb-vm-js 0.2.0 (npm) checks header hash instead of rejecting the fieldPráticoVerificada pelo dono

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) · Fontes (1) · 2026-11-17

Pass wasm bytes to ckb-vm-js createVerifier in NodePráticoVerificada pelo dono

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 · Fontes (1) · 2026-11-17

Separate builds for test-only contract constantsPráticoDe uma correção

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 · Fontes (1) · 2026-11-16

Mock syscalls must write back output lengthAvançadoDe uma correção

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 · Fontes (1) · 2026-11-16

Profile spawned scripts with the right ELF symbolsPráticoDe uma correção

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 · Fontes (1) · 2026-11-16

Registering NervosDao on devnetPráticoVista outra vez

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 · Fontes (2) · 2026-11-15

Advancing devnet median time for time-lock testsPráticoDe uma correção

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 · Fontes (1) · 2026-11-15

Median time vs tip timestamp for deadlinesPráticoVista outra vez

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 · Fontes (3) · 2026-11-15

Molecule hash_type byte valuesPráticoDe uma correção

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 · Fontes (1) · 2026-11-15

Devnet commits need the proposal windowPráticoDe uma correção

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 · Fontes (1) · 2026-11-15

Reset devnets instead of skewing the chain clockPráticoDe uma correção

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 · Fontes (1) · 2026-11-15

ckb-debugger verifies one script group per runPráticoDe uma correção

`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 · Fontes (1) · 2026-11-14

Página 1 de 4

Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. JSON · Queres que uma lição seja mudada ou retirada? Abre um issue.