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.

“Type ID and upgrades”

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

Search for a script's cells under both its data hash and its type id code hashPráticoVerificada pelo dono

A script deployed with a type id can be referenced by cells either as hashType data1 with the code's data hash or as hashType type with the deployment's type id hash (per network). An exact indexer search via client.findCells over only one form misses the other; here @ckbfs/api's useTypeID cells read as missing until the reader queried both forms and treated a combined count above one as an error.

#Indexer queries and cell collection #Type ID and upgrades · Fontes (1) · 2026-10-24

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

Resolving cell deps per cell after redeploying a data-hashed scriptPráticoDe uma correção

After a data/data1 type script is redeployed with a new code hash, old cells still run against the old code. Keep a list of retired deployments and query the indexer for every one. Pick each cell's cell dep by matching the codeHash and hashType of that cell's own type script, not a single 'current' manifest entry.

#Cell deps and script lookup #Type ID and upgrades #Indexer queries and cell collection · Fontes (1) · 2026-11-17

Separate builds for test-only contract constantsPráticoDe uma correção

Put test variants that change protocol constants behind a Cargo feature, built as a separate binary with its own code hash and deployment file. Client deployment parsing and deploy scripts should reject that variant on mainnet. Off-chain code should read the constant from the deployment rather than hardcode the default.

#Testing and devnet #Cell deps and script lookup #Type ID and upgrades · Fontes (1) · 2026-11-16

Verifying an immutable data1 script code cell after deploymentPráticoDe uma correção

For a script referenced by hashType 'data1', put the binary in a cell whose lock is the always fail lock (codeHash 32 zero bytes, hashType data1, args 0x, which no code cell can match) and with no type, so the cell can never be spent and the cell dep stays live; the capacity is locked forever. After sending, read the cell with client.getCellLive(outPoint, true) and assert that ccc.hashCkb(outputData) equals the pinned code hash, that the lock equals the always fail lock and that there is no type, ideally on more than one endpoint. The data1 code hash is already pinned by the binary's content; the immutable lock is what keeps the cell available.

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

Check chain-wide script users before consuming a deployed code cellPráticoVerificada pelo dono

Before consuming a deployed code cell, call indexer get_cells across the whole chain with script_search_mode "prefix" and args "0x", once as lock and once as type. Query the cell's data hash with hash_type data, data1 and data2, and for a Type ID cell also its type script hash with hash_type type. Zero results only means no live cell uses the binary right now. Consuming the cell is irreversible, and a Type ID identity cannot be recreated, so treat unused Type ID cells with extra caution.

#Cell deps and script lookup #Indexer queries and cell collection #Type ID and upgrades · Fontes (2) · 2026-10-10

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

Absence of on-chain references does not mean a code cell is safe to consumePráticoDe uma correção

Before consuming a deployed code cell, search live cells for its data hash as lock and type script code hash (prefix mode, hash types data, data1 and data2), and compare its data hash (blake2b with personalization ckb-default-hash) against the binaries you currently build. Zero references does not mean superseded: a contract unchanged by a rebuild has no users yet and is still the live deployment. This search does not see type ID references or cell dep use, so treat a cell that anything may resolve by type ID or as a dep as still needed.

#Type ID and upgrades #Indexer queries and cell collection #Cell deps and script lookup · Fontes (1) · 2026-09-20

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.