All lessons · Rust scripts and ckb-std · Start here · Glossary
Delegating script validation via exec to a hash bound cell depWorkingFrom one fix
From one fix · Check: right · Checked 2026-11-19
This lifecycle type script stores a 32 byte data hash in its args, scans cell deps with load_cell_data_hash to find exactly one match (rejecting duplicates), then calls ckb_std syscalls::exec on that dep, which keeps the current Script context (GroupInput, GroupOutput, args) for the child. Because exec only returns when it fails, any code after the call must return an error instead of falling through to success.
Why it matters: If code after exec falls through to success, a failed exec (for example a missing or invalid dep at that index) lets the transaction pass with no child validation at all, and without the uniqueness check an ambiguous dep set picks an unintended executable.
Pattern
let _ = syscalls::exec(parent, Source::CellDep, 0, 0, &[]); Err(Error::Exec)Taken from the commit, shortened.
A test changed in the same commit
It sits next to the fix. We did not run it.
- CellScript-Labs/CellScript:
contracts/zk-private-counter/tests/admission.rs,contracts/zk-private-counter/tests/application.rs,contracts/zk-private-counter/tests/node.rs,contracts/zk-private-counter/tests/support/mod.rs
- Concepts
- Cell deps and script lookup, Type ID and upgrades
- Evidence
- From one fix: from one project, checked against its commit
- First seen
- 2026-10-04
- Last changed
- 2026-10-04
- Last checked
- 2026-11-19
- Check against the commit
- right: the lesson follows from its commit and still holds in the code today
Sources (1)
- 2026-10-04 · CellScript-Labs/CellScript · more from this project
More about Rust scripts and ckb-std
- Separate builds for test-only contract constants
- Check that a derived successor type args match the spent cell's type args
- Iterating group inputs and outputs with ckb-std until IndexOutOfBound
Do you maintain a project this lesson came from? Confirm or correct it
Cite this lesson
LusoCryptoLabs, "Delegating script validation via exec to a hash bound cell dep", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/delegating-script-validation-via-exec-to-a-hash-bound-cell-d, CC BY 4.0, last changed 2026-10-04.