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.
- CellScript-Labs/CellScript:
tests/artifact_checker/bounded_admission.rs,tests/runtime_read_bounds.rs,tests/stack_layout.rs,tests/syntax_combo/matrix.toml
- 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)
- 2026-10-27 · CellScript-Labs/CellScript · mais deste projeto
Mais sobre Rust scripts and ckb-std
- Minimum capacity of a cell depends on its lock args length
- Use raw_data(), not as_slice(), when parsing a packed::Bytes witness
- Cheque lock receiver path must return the cell's capacity to the sender
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.