Todas as lições · Developer tooling · Começa aqui · Glossário
Charging load_program bytes as cycles when building a custom ckb-vm machineAvançadoDe uma correção
De uma correção · Verificação: certa · Verificada em 2026-11-19
When you build a ckb-vm machine yourself (DefaultMachineBuilder or AsmMachine) and call load_program, charge the returned byte count with machine.add_cycles_no_checking(ckb_script::cost_model::transferred_byte_cycles(bytes)). That count covers the loaded program and the stack and argument setup, and TransactionScriptsVerifier charges it on chain, so without it your cycle count comes out too low (in ckb-debugger the fib test went from 1361 to 3364 cycles). For AsmMachine call it on the inner machine, and pass the error up instead of unwrapping.
Porque importa: A hand-built ckb-vm machine that skips charging the loaded program bytes reports fewer cycles than on-chain verification does (the fib example showed 1361 instead of 3364), so cycle estimates and limits based on it are wrong.
Padrão
machine.add_cycles_no_checking(transferred_byte_cycles(bytes))?;Tirado do commit, encurtado.
Um teste mudou no mesmo commit
Está ao lado da correcção. Nós não o corremos.
- nervosnetwork/ckb-standalone-debugger:
ckb-debugger/tests/test_command.rs
- Conceitos
- Testing and devnet, Other
- Evidência
- De uma correção: de um projeto, verificada contra o commit
- Vista pela primeira vez
- 2026-11-03
- Última mudança
- 2026-11-03
- Ú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-11-03 · nervosnetwork/ckb-standalone-debugger · mais deste projeto
Mais sobre Developer tooling
- ckb-vm-js 0.2.0 (npm) checks header hash instead of rejecting the field
- Derive devnet Spore and system script cell deps from a fresh OffCKB export
- Pass wasm bytes to ckb-vm-js createVerifier in Node
Manténs um projeto de onde esta lição veio? Confirma ou corrige
Citar esta lição
LusoCryptoLabs, "Charging load_program bytes as cycles when building a custom ckb-vm machine", CKB lessons, https://pulse.lusocryptolabs.com/learned/tooling/charging-load-program-bytes-as-cycles-when-building-a-custom, CC BY 4.0, last changed 2026-11-03.