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.

#Network and RPC reliability

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

Página 3 de 4

Pass a config object, not a URL string, to ccc.ClientPublicTestnetPráticoReproduzida

In @ckb-ccc/core, the ClientPublicTestnet constructor takes an options object, so a custom RPC endpoint must be given as { url: rpcUrl } rather than as a bare string argument. This commit corrects the bare string calls in a deploy script to the object form.

#Network and RPC reliability · Fontes (1) · 2026-10-13

Light client still reports a removed script until the new script set landsPráticoDe uma correção

The CKB light client keeps reporting a script, with its block number, from get_scripts until you register a new script set that leaves it out. A sync poll that runs between your local delete and that set_scripts call will still see the removed script. Do not let that poll recreate local per script progress for an owner that no longer exists, and clear that progress again once the new set is registered while polling is excluded.

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

Simulating a real CKB reorg with two devnet nodes over P2PAvançadoDe uma correção

To exercise genuine fork choice on a Dummy devnet, partition two nodes with set_network_active(false) plus remove_node, wait until get_peers is empty on both, then mine a longer competing branch on one node with generate_block. Reconnect with set_network_active(true) and add_node(node_id, /ip4/.../tcp/port), and wait until both nodes report the same get_tip_header hash and the same tx_pool_info tip_hash before checking reorg recovery.

#Testing and devnet #Network and RPC reliability · Fontes (2) · 2026-10-10

Reconstructing the live cell set at a past height from the CKB indexerAvançadoDe uma correção

The indexer's get_cells lists only cells live at its current tip. To get Nervos DAO deposits live at height H, read the indexer tip, list get_cells and keep those with block_number <= H, then read the indexer tip again as T. Then query get_transactions on the DAO type script with filter block_range [H+1, T+1) (the end is exclusive), keep io_type input, follow each input's previous_output to the creating tx and its header, and add back cells created at or below H. In both passes keep only real deposits (DAO type and 8 zero bytes of data), since withdrawing cells share the type script, and retry if either tip hash is no longer canonical per get_block_hash.

#Indexer queries and cell collection #Network and RPC reliability · Fontes (1) · 2026-10-08

Verify a self indexed tip against the node's canonical block hash before serving itPráticoDe uma correção

A locally maintained index of CKB blocks can lag the node or still hold an orphaned block after a reorg, so before serving its tip as an anchor, fetch the node's tip number, wait briefly for the index to reach it, then ask the node for the canonical block hash at the indexed height and refuse (503 with NOT_SYNCED or REORGANIZING) unless it equals the indexed hash. The check narrows the window but is not atomic, so a client that signs over the anchor should also compare it with an independent source.

#Network and RPC reliability #Indexer queries and cell collection · Fontes (1) · 2026-10-08

Wait for tx_pool_info tip to match chain tip before submitting on devnetPráticoDe uma correção

After generate_block, CKB's tx pool updates its snapshot asynchronously, so a transaction spending just-committed outputs can be rejected (e.g. "Resolve failed Unknown") even though get_live_cell sees them. Before send_transaction or send_test_transaction, poll tx_pool_info until its tip_hash and tip_number equal get_tip_header's hash and number.

#Testing and devnet #Network and RPC reliability · Fontes (1) · 2026-10-08

Light client sync progress poll racing set_scriptsAvançadoDe uma correção

If an app saves per-script sync progress from the light client's get_scripts while another path calls set_scripts to reset or re-register scripts, a get_scripts result read before the set landed can overwrite the reset progress. Do the get_scripts read and the progress write under the same lock that guards set_scripts, and have the poll use tryLock and skip that tick while a registration is in flight, so it never queues behind it. Pocket Node does this in SyncCoordinator.tryWithRegistrationLock.

#Indexer queries and cell collection #Network and RPC reliability · Fontes (1) · 2026-10-06

Verify header_deps against independently fetched headers, not against the tx's own listPráticoDe uma correção

When checking a transaction that uses header_deps for entropy (for example, headers at fixed offsets from a cell's inclusion block), derive the expected headers yourself: get the creating tx with get_transaction, then get_header on its block_hash, then get_header_by_number for the scheduled heights. Only then compare them to the tx's header_deps. Taking the headers from header_deps makes the check circular, since it only confirms the transaction agrees with itself.

#Since and time locks #Network and RPC reliability · Fontes (1) · 2026-10-02

Light client set_scripts "all" replaces the whole registered script setPráticoDe uma correção

The CKB light client's set_scripts with the all command replaces every registered script, so a call carrying only one wallet's lock script unregisters all other wallets. When several scripts must stay tracked, either pass the full set with each script's own start block, or use the partial command to update only the changed script. If registrations can race, serialise them so a stale full set cannot overwrite a newer one.

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

Give light clients the committing block of a cell, not just its outpointPráticoVerificada pelo dono

A CKB light client that only watches scripts cannot look a cell up by outpoint, so a service that hands one a cell should also give the block number and hash of the transaction that created it. The client can then fetch that transaction by hash and watch for the cell being spent from that block, instead of scanning from genesis.

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

Split CCC signTransaction from sendTransaction to retry on consumed inputsPráticoDe uma correção

When several clients race to spend the same shared cell, sign with signer.signTransaction and send with signer.client.sendTransaction as two steps instead of signer.sendTransaction. The dead-input rejection only appears at broadcast, so wrapping just the send in the retry catch lets you tell contention (re-read the live cell, rebuild, sign again) from a wallet refusal or a script verification failure, which must not be retried. Cap the attempts, because each retry costs another signature.

#Transaction building and fees #Network and RPC reliability · Fontes (1) · 2026-09-23

Computing cell confirmations from get_transaction block_hash and tip headerPráticoDe uma correção

To get a cell's confirmation count over raw CKB JSON-RPC, read tx_status.block_hash from get_transaction, look up its number with get_header, then compute tip − included + 1 using get_tip_header; treat a missing block_hash as 0 confirmations. This commit's helper also retries get_transaction without the "0x2" verbosity param if the node rejects it, and treats get_live_cell as live only when status === "live".

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

Página 3 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.