Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário
Parse raw CKB blocks with from_compatible_slice to accept BlockV1 extensionPráticoDe uma correção
De uma correção · Verificação: certa · Verificada em 2026-11-19
Serialized CKB blocks may be BlockV1, which appends a consensus extension field after the Block molecule fields, so a strict packed::BlockReader::from_slice can reject them. This commit parses block bytes with ckb-gen-types 1.1.1 packed::BlockReader::from_compatible_slice, which accepts the extra field while still exposing header() and transactions().
Porque importa: Without the compatible reader, any serialized block that carries the BlockV1 extension fails to parse, so the replay aborts with an encoding error instead of reading the header and transactions.
Padrão
packed::BlockReader::from_compatible_slice(bytes).map_err(|_| Error::Encoding)?;Tirado do commit, encurtado.
Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- CellScript-Labs/AgoraSeal:
crates/protocol/tests/replay.rs
- 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-07
- Última mudança
- 2026-10-07
- Ú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-07 · CellScript-Labs/AgoraSeal · mais deste projeto
Mais sobre Rust scripts and ckb-std
- Use raw_data(), not as_slice(), when parsing a packed::Bytes witness
- CKB blake160 is the first 20 bytes of the 32 byte ckbhash
- Handle None from ckb_sdk Since::extract_metric for invalid since values
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "Parse raw CKB blocks with from_compatible_slice to accept BlockV1 extension", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/parse-raw-ckb-blocks-with-from-compatible-slice-to-accept-bl, CC BY 4.0, last changed 2026-10-07.