CKB Pulse
经验

CKB 学到了什么

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

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

#Network and RPC reliability

找到 37 条经验。 全部经验

第 2 页,共 4 页

Confirm a committed transaction is on the canonical chain via get_header and get_block_hash实践来自一次修复

Before recording a transaction as committed, you can cross-check get_transaction's tx_status.block_hash. Call get_header on that hash and require get_block_hash(header.number) to return the same hash. If the header is missing or the hashes differ, keep the transaction marked uncertain and reconcile it later rather than building new transactions on its outputs.

#Network and RPC reliability · 来源(1) · 2026-11-05

Reuse one CkbRpcClient across a loop instead of building one per item实践来自一次修复

Constructing a ckb_sdk CkbRpcClient (CkbRpcClient::with_builder) loads the TLS root store, about 6 ms of CPU each time. In Fiber's watchtower, building one per watched channel made a round over 11,496 channels take 93 to 115 s; building one client before the loop and passing &CkbRpcClient cut it to 5 to 7 s.

#Network and RPC reliability · 来源(1) · 2026-11-03

Reconcile a lost send_transaction response by pinned hash, not by rebuilding实践来自一次修复

When a send_transaction response is lost (the node may already have accepted the transaction), this commit pins the signed transaction hash and its input outpoints, and recovers by querying get_transaction for that exact hash and get_live_cell for each input instead of building a new payment. Only a 'committed' status ends the intent; rejected, unknown or spent inputs stay 'uncertain' for operator review, because a fresh rebuild from refreshed cells was shown to let a second payment to the same recipient commit.

#Network and RPC reliability #Transaction building and fees #Indexer queries and cell collection · 来源(1) · 2026-11-02

Dry run a transaction with test_tx_pool_accept before send_transaction实践来自一次修复

The CKB node RPC test_tx_pool_accept takes the same params as send_transaction (the snake_case tx JSON without its hash, plus an outputs validator such as "passthrough"). It returns the cycles and fee the pool would accept without broadcasting, so a tool can check a pasted transaction before sending it for real.

#Transaction building and fees #Network and RPC reliability · 来源(1) · 2026-10-30

get_live_cell may return "unknown" rather than "dead" for a spent output实践再次出现

On CKB node 0.210.0 devnet, get_live_cell for an output already consumed by a committed transaction returned status "unknown" instead of "dead", so a check requiring "dead" fails. Accept "dead" or "unknown" and prove consumption by calling get_transaction on the creating and consuming transactions, confirming both are committed and that the consumer's inputs reference the out point exactly once.

#Indexer queries and cell collection #Network and RPC reliability · 来源(3) · 2026-10-30

get_transaction returns an object with a null transaction for rejected and unknown txs实践再次出现

The CKB node's get_transaction RPC does not return a null result for rejected or unknown hashes: it returns an object whose transaction field is null and whose tx_status.status is "rejected" (with tx_status.reason holding the rejection reason) or "unknown". Check res.transaction, not just res, before reading outputs, surface tx_status.reason to users, and make test mocks return this shape rather than result null.

Joined with toastmanAu/openswap@4dbe3232c3.

#Network and RPC reliability #Testing and devnet · 来源(2) · 2026-10-30

Paging indexer get_cells and get_transactions with last_cursor实践来自一次修复

The built-in indexer RPCs get_cells and get_transactions return at most the requested limit (here 0x3e8) plus a last_cursor. To read all results for a search key, pass last_cursor as the fourth param on the next call and stop once a page returns fewer objects than the limit; a single call with a small limit (the old 0xc8 or 0x19) undercounts cells and transactions.

#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-10-30

Serialize transfers from one account until the previous tx is committed实践来自一次修复

When one account sends several transfers in a row (here via `offckb transfer`), a new transfer started before the previous one is committed can pick the same input cell, and the node rejects it with PoolRejectedRBF. This faucet queues claims and polls get_transaction until tx_status is committed, rejected or unknown before building the next transfer.

#Transaction building and fees #Network and RPC reliability · 来源(1) · 2026-10-30

Clamp the node's get_fee_rate_statistics median before using it as a fee rate实践来自一次修复

Do not pass the node's get_fee_rate_statistics median straight to a transaction builder: a high or untrusted endpoint can set the fee rate for every transaction you build. Clamp it between the minimum relay rate (1,000 shannons/KB) and an app-chosen ceiling, and fall back to the minimum if the call fails, accepting that a ceiling below the real market rate can make confirmation slow. openswap used 1,000 to 5,000 shannons/KB (testnet nodes suggested 33,000 to 47,000) plus a 0.01 CKB per-transaction cap.

#Transaction building and fees #Network and RPC reliability · 来源(1) · 2026-10-29

Use indexer matched cell indexes to limit input parent fetches实践来自一次修复

With CCC client.findTransactionsPaged (scriptSearchMode 'prefix', groupByTransaction: true), each returned transaction has a cells list of {isInput, cellIndex} entries for the cells that matched the searched script. If your logic only needs the matched inputs, fetch parent transactions with getTransaction only for those indexes (plus siblings from a parent you already hold) and skip unrelated inputs such as wallet funding. OpenSwap's market scanner did this together with raising read concurrency to 16, and its first scan went from about 8 to 10 s to about 5.3 s; the gain from this change alone was not measured.

#Indexer queries and cell collection #Network and RPC reliability · 来源(1) · 2026-10-29

A rejected or unknown get_transaction status does not make a signed transaction dead实践来自一次修复

A node reporting a transaction you sent as rejected or unknown does not prove it is dead: one node's answer is not proof, and while all its inputs are live the signed bytes could still be rebroadcast by someone and commit. Only release its reserved inputs if a later transaction is guaranteed to conflict with it (here a shared pool cell every later action must spend, so at most one can commit), and also require that every input is still live, that the status is still rejected or unknown when rechecked after the input reads, and that the submission is old enough (2 minutes here), behind an explicit confirmation.

#Transaction building and fees #Network and RPC reliability · 来源(1) · 2026-10-26

Release a stuck signed transaction's inputs only after one input is spent elsewhere实践来自一次修复

A signed CKB transaction that is not committed (not pending, proposed or sent) is still valid and can be broadcast by anyone while all its inputs are live, so do not release its input reservations yet. Release them only after a committed-state live-cell check shows at least one input spent (a spend still in the tx pool does not count), and a second status check confirms the transaction still has not committed. A conflicting spend can still be reorganized away, so require the operator to acknowledge that risk.

#Transaction building and fees #Indexer queries and cell collection #Network and RPC reliability · 来源(2) · 2026-10-22

第 2 页,共 4 页

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