Todas as lições · Rust scripts and ckb-std · Começa aqui · Glossário
CKB VM2 READ and INHERITED_FDS syscalls take a length pointer and return status in a0AvançadoDe uma correção
De uma correção · Verificação: certa · Verificada em 2026-11-19
In CKB VM2, READ takes (fd, buffer_addr, length_addr) and INHERITED_FDS takes (buffer_addr, length_addr), with *length_addr set to the buffer capacity before the ecall. The syscall returns only a status in a0 (0 on success) and writes the delivered byte count or fd count back through length_addr, so never treat a0 as the payload. After checking a0, handle short pipe reads by looping or failing explicitly, and bounds-check an INHERITED_FDS index against the smaller of the returned count and the capacity you passed.
Porque importa: A bare ecall passes garbage in a1/a2 and returns the status word as if it were the data, so the script reads wrong values or faults.
Padrão
// READ takes (fd, buffer_addr, length_addr): the scheduler writes the payload to the buffer and the delivered byte count back through length_addr, with SUCCESS in a0.Tirado do commit, encurtado.
Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- CellScript-Labs/CellScript:
services/registry-api/test/sql-registry-store.test.ts,tests/deferred_ckb_semantics.rs,tests/examples.rs
- Conceitos
- Other
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-10-29
- Última mudança
- 2026-10-29
- Ú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-29 · CellScript-Labs/CellScript · mais deste projeto
Mais sobre Rust scripts and ckb-std
- Enable molecule bytes_vec so ckb-std scripts contain no atomic instructions
- Close spawn pipe descriptors when an IPC channel is freed
- Disable overflow checks for ckb-std when using its dummy-atomic polyfills
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "CKB VM2 READ and INHERITED_FDS syscalls take a length pointer and return status in a0", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/ckb-vm2-read-and-inherited-fds-syscalls-take-a-length-pointe, CC BY 4.0, last changed 2026-10-29.