CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

Working

174 lessons found. All lessons

Page 5 of 15

Check original tx unknown and input live on independent nodes before same input cancellationWorkingFrom one fix

Before signing a same-input cancellation for a deployment whose broadcast outcome is unknown, check on two separate RPC endpoints that get_transaction for the original hash returns status 'unknown' and that get_live_cell for the shared input returns 'live', and fail closed if either endpoint errors or times out. Repeat the check before sending. 'unknown' only means the nodes have not seen the tx yet, so the cancellation is a race: if the original is relayed and committed first, the cancellation fails.

#Network and RPC reliability #Transaction building and fees · Sources (1) · 2026-11-09

CKB log subscription notifications may carry params.result as a JSON stringWorkingFrom one fix

When subscribing to the CKB node's "log" topic over the TCP subscription RPC, the notification's params.result can be a JSON-encoded string of the log entry (message, level, target, date) rather than an object. Parse it with JSON.parse when it is a string, and skip malformed payloads instead of stopping the stream; otherwise script debug output (target ckb_script::verify) is silently dropped.

#Network and RPC reliability #Testing and devnet · Sources (1) · 2026-11-09

Indexer get_cells order is by script args, not by cell ageWorkingFrom one fix

Cells returned by a prefix search on type script args (as findRounds does here) come back in indexer key order, sorted by type args, not by creation time, so taking the first result does not give the newest cell. To get the latest, sort by a field stored in the cell (here the round config's entryStart).

#Indexer queries and cell collection · Sources (1) · 2026-11-09

Verify a deployed code cell is canonical and live before recording it as a cell depWorkingFrom one fix

Before writing a deployment manifest for a code cell, this commit checks get_transaction is committed, that get_block_hash at the header number equals the block hash (not reorganized), and that get_live_cell still reports status live with the expected data hash. It then repeats the canonical and live checks after all reads (on two independent RPCs), so a stale, spent or reorganized cell never yields a manifest.

#Cell deps and script lookup #Network and RPC reliability · Sources (1) · 2026-11-09

Verifying an indexer funding cell against an advancing tip instead of a frozen snapshotWorkingFrom one fix

A frozen-tip check ("the indexer tip must not change during the scan") fails often on a live chain, so do not demand it. Select a single funding cell from get_cells, verify it directly against the node (get_live_cell, get_transaction, get_header, output and data equal to the indexed ones), then re-check at the end that get_block_hash at the starting indexer tip still equals the anchor hash, that the cell's block is canonical, and that the cell is still live. New blocks arriving in between are fine, but still fail closed if the indexer lags the node at the start or the anchor hash changed. This gives one verified input, not a snapshot of the whole wallet.

#Indexer queries and cell collection #Network and RPC reliability · Sources (1) · 2026-11-09

Wait for get_indexer_tip to reach the commit block before re-reading cellsWorkingSeen again

After get_transaction reports tx_status committed, poll get_indexer_tip until its block_number is at least the transaction's block number before calling get_cells. If you query first, the indexer silently returns the pre-transaction cell set with no error.

#Indexer queries and cell collection #Network and RPC reliability · Sources (4) · 2026-11-09

Cheque lock receiver path must return the cell's capacity to the senderWorkingFrom one fix

When a Cheque lock cell (RFC 0039) is spent on the receiver path, rule 1.b.ii requires the Cheque cell's CKB capacity to go back to the sender's lock. An output paying that CKB to the receiver fails with Cheque error 8 (SenderCapacityNotSame). So the Cheque lock cannot be used to deliver plain CKB to the receiver, and in this project's tests it also blocked an owner placed in the receiver role from reclaiming their own CKB.

#Testing and devnet #Capacity and cell size · Sources (1) · 2026-11-09

Cheque lock sender withdrawal requires exact since 0xA000000000000006WorkingFrom one fix

The deployed Cheque lock (RFC 0039) accepts a sender withdrawal only when the Cheque input's since is exactly 0xA000000000000006 (relative epoch, 6 epochs after the cell was committed). A since of 0 fails with Cheque error 11 (WithdrawChequeInputSinceError), so the sender cannot reclaim for about 24h after each create or renew.

#Since and time locks #Testing and devnet · Sources (1) · 2026-11-09

Close spawn pipe descriptors when an IPC channel is freedWorkingFrom one fix

A pipe fd created by ckb_pipe or inherited through spawn stays live until ckb_close is called on it, and the VM limits how many descriptors can be live at once. Code that creates channels repeatedly must therefore close both pipe ends when finished. In ckb-script-ipc, csi_free_channel did not close them before PR #32; it now closes the library-owned pipe fds, and the peer's ckb_read then returns CKB_OTHER_END_CLOSED.

#Other · Sources (1) · 2026-11-09

Handle None from ckb_sdk Since::extract_metric for invalid since valuesWorkingFrom one fix

A raw since u64 can carry the reserved metric flag 0b11 (e.g. 0x6000_0000_0000_0000), for which ckb_sdk::Since::extract_metric() returns None, and a timestamp metric value can exceed what chrono can represent. Code that formats since values received from RPC should handle both cases instead of unwrapping, as ckb-cli now does by printing "invalid since" or "invalid".

#Since and time locks #Data encoding (molecule, hex, bigints) · Sources (1) · 2026-11-09

Saved transaction test vectors go stale when their cell deps are spentWorkingChecked by the owner

A saved CKB transaction lists its cell deps by out point. A replay that resolves those deps as live cells, as a node does when it verifies a new transaction, stops working once a lock upgrade or redeployment spends a dep cell, although neither the saved transaction nor the verifier changed. A replay test should tell that case (a dep that is no longer live) apart from a real verification failure, and skip the vector with a note instead of reporting a defect.

#Testing and devnet #Cell deps and script lookup · Sources (1) · 2026-11-09

Classifying sendTransaction failures before dropping a pending CKB transactionWorkingFrom one fix

A failed or timed out ccc client.sendTransaction, or a getTransaction status of "rejected" or "unknown", does not prove the transaction can never commit: a node may have taken it, and "rejected" also covers pool removals such as expiry or a full pool. Store the signed bytes before sending. Drop the pending state only on final refusals (ErrorClientVerification, ErrorClientMaxFeeRateExceeded, TransactionFailedToVerify, PoolRejectedMalformedTransaction), or when an input is not live, the transaction that created that input is committed, and the node no longer holds your transaction as pending, proposed or committed. A not-live input alone is not proof, because CCC's getCellLive also returns not live for a cell the node has not seen. Otherwise resend the stored bytes, treating ErrorClientDuplicatedTransaction and PoolRejectedDuplicatedTransaction as success.

#Network and RPC reliability #Transaction building and fees · Sources (1) · 2026-11-08

Page 5 of 15

Text under CC BY 4.0: credit LusoCryptoLabs, CKB lessons, with a link to the lesson. JSON · Want a lesson changed or removed? Open an issue.