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
n = first // 4 - 1Tirado 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)
- 2026-10-19 · ckb-service-runner/csr-network-monitor · mais deste projeto
Mais sobre Other
- Recognizing a Nervos DAO deposit cell (not a withdrawing one)
- Hand-encoding WitnessArgs in molecule
- Restrict script hashType to data, type, data1, data2 when loading config
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.