CKB Pulse

Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário

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

De uma correção · Verificação: em parte certa · Verificada em 2026-11-19

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.

Porque importa: A script that hashes loaded data in a fixed 512-byte buffer fails on any cell whose data is longer than the buffer.

Um teste mudou no mesmo commit

Está ao lado da correcção. Nós não o corremos.

Conceitos
Data encoding (molecule, hex, bigints), Capacity and cell size
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-10-27
Última mudança
2026-10-27
Última verificação
2026-11-19
Verificação contra o commit
em parte certa: um núcleo verdadeiro, com uma parte solta ou demasiado larga

Fontes (1)

Mais sobre Rust scripts and ckb-std

Ver as 35 deste tema

Manténs um projeto de onde esta lição veio? Confirma ou corrige

Citar esta lição
LusoCryptoLabs, "Read cell data hash from the consensus DATA_HASH field instead of hashing loaded data", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/read-cell-data-hash-from-the-consensus-data-hash-field-inste, CC BY 4.0, last changed 2026-10-27.

Tiradas de commits públicos e verificadas contra o commit de onde cada uma veio e o código de hoje do projeto. Lê a fonte antes de confiar numa. Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. Queres que uma lição seja mudada ou retirada? Abre um issue.