CKB Pulse
Lessons

What CKB learned

Start here · Glossary · Test yourself · Feed

From one fix

155 lessons found. All lessons

Page 11 of 13

Full-balance UDT burn is valid for SUDT and plain xUDTWorkingFrom one fix

Burning a UDT's entire balance is accepted by SUDT and xUDT without extensions, because those scripts allow output amount to be less than or equal to input amount. offckb removed a guard that rejected destroyAmount === totalBalance and now still emits a zero-balance type cell (16-byte zero amount), which is valid. Extension-enabled xUDT was not covered by this change.

#Transaction building and fees #Capacity and cell size · Sources (1) · 2026-10-08

Disable overflow checks for ckb-std when using its dummy-atomic polyfillsAdvancedFrom one fix

When a release profile sets overflow-checks = true and ckb-std (here =1.1.0 with the dummy-atomic feature) supplies the single-thread __atomic polyfills, add a per-package override turning overflow checks off for ckb-std. Atomic read/modify/write arithmetic is defined to wrap, so checked arithmetic in those polyfills would panic instead of wrapping.

#Other · Sources (1) · 2026-10-07

Parse raw CKB blocks with from_compatible_slice to accept BlockV1 extensionWorkingFrom one fix

Serialized CKB blocks may be BlockV1, which appends a consensus extension field after the Block molecule fields, so a strict packed::BlockReader::from_slice can reject them. This commit parses block bytes with ckb-gen-types 1.1.1 packed::BlockReader::from_compatible_slice, which accepts the extra field while still exposing header() and transactions().

#Data encoding (molecule, hex, bigints) · Sources (1) · 2026-10-07

Partial load of a cell's type Script header to match code_hash and hash_typeAdvancedFrom one fix

In a ckb-std script you can load a cell's type script into a fixed 49 byte buffer with syscalls::load_cell_by_field(..., CellField::Type), then compare code_hash at bytes 16..48 and hash_type at byte 48 of the molecule Script table, without allocating for args. A short buffer returns Err(SysError::LengthNotEnough) yet still fills the buffer, so treat that error like Ok, and treat ItemMissing as a cell with no type script.

#Data encoding (molecule, hex, bigints) #Cell deps and script lookup · Sources (1) · 2026-10-07

Raw cell_deps indexes match Source::CellDep only before the first dep groupAdvancedFrom one fix

When a script reads the raw transaction's cell_deps (via load_transaction) and uses a position there as a Source::CellDep index for load_cell_type_hash or load_cell_data, the mapping holds only for the leading run of dep_type code entries, because dep groups expand into their member cells and shift later indexes. This vote script restricts its proposal and deposit lookups to that direct prefix and lets wallet dep groups follow it.

#Cell deps and script lookup · Sources (1) · 2026-10-07

Light client sync progress poll racing set_scriptsAdvancedFrom one fix

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 · Sources (1) · 2026-10-06

DAO compensation must use the deposit cell's occupied capacity (102 CKB), not 61WorkingFrom one fix

When calculating Nervos DAO max withdraw or compensation (here via the light client's nativeCalculateMaxWithdraw), pass the occupied capacity of the actual DAO deposit cell (102 CKB for a secp256k1 lock plus DAO type plus 8 bytes data), not the 61 CKB of a plain secp256k1 cell. Using 61 overstates the interest by (C - 61) / (C - 102), and the result no longer matches what the unlock transaction pays out.

#Capacity and cell size · Sources (1) · 2026-10-06

Output type scripts need cell deps too, including the native DAO typeBasicFrom one fix

CKB runs the type script of every output (not only input locks and input types), so a transaction that creates a native DAO deposit must include the DAO type's code cell (genesis tx0 index 2) as a cell dep, or the node rejects it with ScriptNotFound on Outputs[i].Type. Pre-send checks that only verify deps for input locks will miss this; check every input lock, input type and output type, deduplicated by code_hash and hash_type.

#Cell deps and script lookup #Transaction building and fees · Sources (1) · 2026-10-05

Delegating script validation via exec to a hash bound cell depWorkingFrom one fix

This lifecycle type script stores a 32 byte data hash in its args, scans cell deps with load_cell_data_hash to find exactly one match (rejecting duplicates), then calls ckb_std syscalls::exec on that dep, which keeps the current Script context (GroupInput, GroupOutput, args) for the child. Because exec only returns when it fails, any code after the call must return an error instead of falling through to success.

#Cell deps and script lookup #Type ID and upgrades · Sources (1) · 2026-10-04

Relative block number since uses top byte 0x80, not the absolute epoch 0x20WorkingFrom one fix

Under RFC 0017 since encoding, bit 63 marks relative and bits 61 to 62 select the metric (00 is block number), so a relative block count is RELATIVE_BLOCK_FLAG (0x8000000000000000) OR the count, and 256 blocks becomes 0x8000000000000100. In this commit the type script checks since >> 56 == 0x80, so reusing the absolute epoch form (top byte 0x20) is rejected on chain with an error code that does not name the since as the cause.

#Since and time locks · Sources (2) · 2026-10-02

Verify header_deps against independently fetched headers, not against the tx's own listWorkingFrom one fix

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 · Sources (1) · 2026-10-02

Light client set_scripts "all" replaces the whole registered script setWorkingFrom one fix

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 · Sources (1) · 2026-09-30

Page 11 of 13

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.