CKB Pulse

Todas as lições · Other · Começa aqui · Glossário

Strict validation of molecule table headers in hand written decodersPráticoDe uma correção

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

When decoding a molecule table by hand (here, the CSR registry cell data), check that the leading u32 total size equals the data length, derive the field count as first_offset/4 - 1, and require first_offset == 4 + 4*count and ascending offsets. Reject a field count different from the schema; this parser is strict and does not accept extra trailing fields, so truncated, padded or extended tables raise ValueError, as the tests show.

Porque importa: Without these header checks, truncated, padded or extra-field cell data gets sliced into wrong field values instead of being rejected, so the decoder trusts malformed on-chain data.

table header validation, distinct from WitnessArgs encoding lesson

Padrão

Preferir
n = first // 4 - 1

Tirado do commit, encurtado.

Conceitos
Data encoding (molecule, hex, bigints)
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-10-19
Última mudança
2026-10-19
Última verificação
2026-11-19
Verificação contra o commit
certa: a lição sai do commit e continua a valer no código de hoje

Fontes (1)

Mais sobre Other

Ver as 9 deste tema

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

Citar esta lição
LusoCryptoLabs, "Strict validation of molecule table headers in hand written decoders", CKB lessons, https://pulse.lusocryptolabs.com/learned/other/strict-validation-of-molecule-table-headers-in-hand-written, CC BY 4.0, last changed 2026-10-19.

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.