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.

CellScript-Labs/CellScript

Lições de CellScript-Labs/CellScript

github.com/CellScript-Labs/CellScript

Manténs este projeto? Confirma as lições dele num só issue

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

CKB VM2 READ and INHERITED_FDS syscalls take a length pointer and return status in a0AvançadoDe uma correção

In CKB VM2, READ takes (fd, buffer_addr, length_addr) and INHERITED_FDS takes (buffer_addr, length_addr), with *length_addr set to the buffer capacity before the ecall. The syscall returns only a status in a0 (0 on success) and writes the delivered byte count or fd count back through length_addr, so never treat a0 as the payload. After checking a0, handle short pipe reads by looping or failing explicitly, and bounds-check an INHERITED_FDS index against the smaller of the returned count and the capacity you passed.

#Other · Fontes (1) · 2026-10-29

Read cell data hash from the consensus DATA_HASH field instead of hashing loaded dataPráticoDe uma correção

To get a cell's data hash in a CKB script, read the DATA_HASH field with LOAD_CELL_BY_FIELD instead of loading the data with LOAD_CELL_DATA and hashing it yourself. The field works for any data size, while a fixed buffer breaks on larger data because LOAD_CELL_DATA reports the full remaining length, not the number of bytes copied. The field also returns 32 zero bytes for empty data, not Blake2b of empty, so a hash computed over loaded data would not match it.

#Data encoding (molecule, hex, bigints) #Capacity and cell size · Fontes (1) · 2026-10-27

Type Script group membership and group witness index derived from the full script hashPráticoDe uma correção

When locating a Type Script group off chain, match input and output cells by the blake2b hash of the complete Script (code_hash, hash_type, args), never by code hash alone. By convention (RFC 22 for lock groups), a group's witness sits at the transaction index of its first input, or of its first output if the group has no inputs. CKB does not enforce this: the script picks which witness it reads, and which WitnessArgs field (input_type or output_type) holds the data is the protocol's own choice.

#Witnesses and signatures #Transaction building and fees · Fontes (1) · 2026-10-09

Matching a Script code_hash to its code Cell by hash_typePráticoVista outra vez

To check that a Script points at a given deployed code Cell, compare its code_hash with ckb blake2b256 of the Cell's output data when hash_type is data, data1 or data2 (0, 2, 4), and with the hash of that Cell's Type Script when hash_type is type (1). A type selection needs the code Cell to actually carry a Type Script, and other hash_type values are rejected.

#Cell deps and script lookup #Data encoding (molecule, hex, bigints) · Fontes (2) · 2026-10-09

Script hash_type selects the VM version: data2 (4) or type (1) for a VM2 targetPráticoDe uma correção

CKB picks the VM version from the Script hash_type: data (0) runs VM0, data1 (2) runs VM1, data2 (4) runs VM2, and type (1) runs the latest activated VM. Code deployed for VM2 and pinned by data hash must be referenced with hash_type data2. The same code hash with data or data1 still resolves to the same cell but runs under an older VM, so tooling should reject those hash types for a VM2 target rather than only checking that the code hash matches.

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

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

Delegating script validation via exec to a hash bound cell depPráticoDe uma correção

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 · Fontes (1) · 2026-10-04

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.