Skip to content

[0.30][Runtime] Complete typed bounded CKB transaction-view and syscall adapters #24

Closed

Description

@a19q3

Summary

Define and implement one versioned, typed, bounded contract for the CKB transaction data and runtime adapters that production CellScript verifiers may use. This closes the current gap between individually implemented source/byte helpers and a release-level support matrix suitable for the 0.30 business portfolio.

This issue does not add a raw numeric-syscall escape hatch. Each admitted operation must have a typed source, deterministic memory bound, stable failure behavior, metadata and ProofPlan records, lowering, and positive/adversarial CKB-VM evidence.

Current boundary

The 0.26b baseline already exposes useful typed transaction views, exact byte/span reads, transaction preimages, hashes, and bounded EXEC or SPAWN/WAIT adapters. Issue #12 owns temporal and Since domains. Those pieces do not yet share one complete matrix proving which Cell, input, header, witness, Script, hash, source, and syscall-result families are supported together in ordinary, persistent-policy, builder, and independent-checker paths.

Required contract

The 0.30 matrix must decide and test:

  • current Script and Script hash;
  • Cell data, capacity, occupied capacity, Lock and Type Scripts and hashes;
  • input out points and since;
  • headers, header dependencies, epochs, timestamps, and block numbers;
  • raw witnesses and WitnessArgs fields with explicit ownership and bounds;
  • transaction, Script-group, input, output, CellDep, and header-dependency sources;
  • indexes, lengths, partial reads, and out-of-bound behavior;
  • transaction preimages and exact authorization message domains;
  • CellDep lookup and exact-identity EXEC or SPAWN/WAIT adapters; and
  • stable errors for syscall failure, malformed Molecule values, invalid sources, invalid indexes, and oversized byte ranges.

Every supported API must identify its source kind, value type, maximum read size, allocation/stack behavior, failure code, evidence tier, and supported entry contexts. Unsupported combinations must fail before production artifact emission.

Implementation phases

Phase 0 — matrix and identities

Phase 1 — typed frontend and IR

  • expose admitted values and conversions through the authoring grammar and type checker;
  • retain source, index, field, byte range, and message-domain provenance in structured IR;
  • reject confused source kinds, unchecked narrowing, ambiguous witnesses, and unbounded materialization; and
  • update formatter, recovering parser, LSP, VS Code, metadata, constraints, ProofPlan, and source maps together.

Phase 2 — runtime lowering

  • lower every admitted operation through canonical CKB syscalls and Source encodings;
  • enforce bounds before pointer arithmetic or allocation;
  • preserve exact syscall statuses and terminal verification failures;
  • support the same admitted contract in ordinary/scoped and persistent-policy entries; and
  • keep all unclassified syscalls fail-closed.

Phase 3 — independent and executable evidence

  • bind claimed runtime-view operations to machine blocks in the standalone checker;
  • add mutations for source, index, length, field, hash, status, and omitted bounds checks;
  • run identical fixtures through simulator where applicable and CKB-VM where authoritative;
  • add builder and adapter codec parity tests; and
  • measure cycles, stack, code size, witness bytes, and transaction size at maximum admitted bounds.

Acceptance matrix

At minimum, cover valid and invalid reads for every admitted source, zero-length and maximum-length byte ranges, indexes 0/nonzero/last/one-past-last/large-u64, missing and malformed witnesses, absent Type Scripts, wrong Script groups, header-dependency presence and absence, since type mismatches, partial syscall reads, wrong CellDep identities, and nonzero child status.

The same operation used from ordinary and persistent-policy paths must either produce the same typed/runtime contract or reject with a documented entry-context error. No metadata-only record may be counted as executable support.

Completion criteria

  • A reviewed support matrix classifies every current CKB-facing API.
  • All admitted APIs have typed source/value contracts and deterministic bounds.
  • Edition 2026 compatibility and the new 0.30 source identity are explicit.
  • Formatter, LSP, VS Code, metadata, constraints, ProofPlan, and builders agree.
  • CKB-VM positive and adversarial cases cover every admitted row.
  • Standalone-checker mutations cover every machine property it claims.
  • Worst-case resource measurements are recorded and gated.
  • dev, ci, and backend gates pass.
  • Independent review of source decoding, bounds, witness ownership, and syscall failure handling is complete.

Non-goals

  • raw syscall numbers or inline assembly;
  • unbounded transaction-wide reads or allocator-backed unbounded values;
  • silently treating syscall errors as data;
  • changing stable Edition 2026 behavior without migration; or
  • claiming external verifier internals from successful delegation.

Dependencies

Activity

  1. a19q3 commented on Sep 11, 2026

    @a19q3
    CollaboratorAuthor

    0.30 evidence update landed in 1e2f642.

    This adds the first exact non-cryptographic runtime-view resource profile for the fixed transaction/header/temporal path: 20,673 cycles, 14,040-byte ELF, 5,376-byte stack bound, 60 witness bytes, 469 transaction bytes, and 28 dependency bytes. The shared CKB harness now uses domain-separated deterministic fixture OutPoints and records raw and serialized transaction hashes, so exact fixtures remain stable across processes. The typed runtime-view integration suite passes 7/7.

    #24 should remain open. Still required are persistent-policy/builder/checker parity across all admitted rows, maximum profiles for the remaining non-cryptographic Output/GroupOutput/Script/adapter families, full adversarial coverage, and independent/release evidence.

  2. a19q3 commented on Sep 11, 2026

    @a19q3
    CollaboratorAuthor

    Follow-up for pushed 0.30 commit 68e01a2: the remaining non-cryptographic Output/GroupOutput/Script resource row is now closed.

    The new real CKB-VM fixture distinguishes global Output from current-group GroupOutput and covers fixed fields, an input with no Type Script, complete Lock/Type Script projections, exact 32-byte Script args, the maximum 459-byte Script-args boundary, and one-past-last global/group indexes (stable error 44). It also exposed and fixed an independent-checker gap: legal closed Cell-view to internal Script-reference lowering is now accepted, while non-cell sources and non-internal destinations remain rejected.

    The exact profile pins 46,043 cycles, 10,552-byte ELF, 11,344-byte maximum stack frame under a 16,384-byte bound, zero witness/dependency bytes, a 1,743-byte transaction, and artifact/lowering/source-map/bundle/raw-transaction/serialized-transaction hashes. The identity/resource test was replayed twice; the full typed runtime-view suite is now 9/9. Artifact-checker tests, relevant unit tests, clippy, docs/status, and ledger validation pass on Rust 1.97.1.

    #24 remains open for persistent-policy and generated-builder parity across all admitted rows, broader standalone machine mutations, remaining non-cryptographic adapter resource rows, independent review, and release gates. No TAC, release, deployment, or signing flow was run.

  3. a19q3 commented on Sep 11, 2026

    @a19q3
    CollaboratorAuthor

    Implemented and pushed an additional bounded persistent-policy/runtime-view slice on 0.30 in 48487521.

    The canonical partial_fill / settle / cancel policy now reads and enforces the current GroupInput<OrderState> data_size and capacity in every action. The exact policy artifact is exercised through policy-witness dispatch, generated-builder + ProtocolBundle validation/materialization, the four-artifact/five-group same-transaction CKB-VM anchor, and the stateful prior-output partial_fill -> settle plus cancel path.

    Pinned evidence was refreshed rather than weakened:

    • policy ELF: 0x5f827a767f28bcc91190945a3eeff396e24b6346e341ebe7643cbb91bac7bb28
    • lowering record: 0xbbd907d8ef8062fce1f3e583986ff15910e7a4a15eaa5c7f9fe62cca3cb33216
    • source map: 0x142c5825a9c6db00c5c9f1e475d640e003f122589bc0703472b03fa3712bff55
    • verified bundle: 0x558e5ec1ba697d0f919a57ee61dcef485ea843cbfac8c908f490b6edafc5339f
    • anchor: 41,822 cycles, 16,424 combined ELF bytes under a 17,000-byte ceiling
    • raw tx: 0xeeffbecf0ccbdda0d5709b96ccee78e11988a74be00515f96d34e84b8de73ba6
    • serialized tx: 0x8b6904472b55eec2483f262331bd71b8da3920737f1924031f67e392d0c3e0bd
    • ProtocolBundle: d9eb8c317a4c82f09a91bc607d5c9edf023b19637fe736761c1fd730c46c7bc9

    Validation: business corpus 3/3 twice; scenario-evidence and capability-ledger unit suites 2/2 each; exact Rust 1.97.1 fmt and focused Clippy; doc-status check. The repo-wide Markdown link check remains blocked only by the already-recorded unavailable pinned iCKB submodule file; no remote-head substitution was made.

    Issue remains open for persistent-policy/generated-builder parity beyond this exact GroupInput data-size/capacity slice, remaining standalone-checker/resource rows, independent review, CI/backend, and release evidence. No TAC, release, deployment, or signing workflow was invoked.

  4. a19q3 commented on Sep 11, 2026

    @a19q3
    CollaboratorAuthor

    Pushed e999c30f on 0.30, adding the third exact non-cryptographic runtime-view resource profile for the persistent policy path.

    The same stateful CKB-VM test now measures and gates all three partial_fill / settle / cancel action transactions against the canonical policy artifact and its sidecars. Fixed domain-separated input OutPoints make the identities stable under parallel execution.

    Exact maximum observed values:

    • 17,341 cycles (20,000 ceiling)
    • 7,040-byte ELF (8,192 ceiling)
    • 5,376-byte largest stack frame (6,000 ceiling)
    • 145 witness bytes (192 ceiling)
    • 493 transaction bytes (600 ceiling)
    • 14,224 dependency bytes (15,000 ceiling)

    The profile also binds the artifact/lowering/source-map/verified-bundle identities and raw + serialized hashes for the partial-fill precursor, successor settle, and independent cancel transactions. Business corpus passed 3/3 twice; typed runtime views 9/9; ledger 2/2; fmt, focused Clippy, JSON/digest, and doc-status checks passed on Rust 1.97.1.

    The frozen-corpus scope decision is now explicit: no scenario requires a full Header hash (typed epoch/block/timestamp fields cover the admitted temporal portfolio), and multisig uses the pinned standard multisig-v2 Lock boundary rather than an in-language prefix-preserving signing transform. Either future extension requires a separate typed/bounded contract.

    #24 remains open for persistent-policy/builder parity beyond the exact current slice, checker/resource coverage for admitted rows outside the three non-cryptographic profiles, independent review, and release-facing gates. No TAC, release, deployment, or signing workflow was invoked.

  5. a19q3 commented on Sep 11, 2026

    @a19q3
    CollaboratorAuthor

    0.30 update: commit 1d7e8fd is pushed. A fourth exact non-cryptographic profile now exercises every Input, current-group GroupInput, and CellDep field together with full Lock/Type Script, OutPoint, Since, and exact 32-byte WitnessArgs projections. It pins artifact/lowering/source-map/bundle and raw/serialized transaction identities plus 92,896 cycles, 16,208 ELF bytes, 22,880 max stack bytes, 124 witness bytes, 597 transaction bytes, and 73 dependency bytes under explicit ceilings. This exposed and fixed the checker-only InputView<T> -> __ckb_input_out_point_ref omission; the checker admits only that closed source/destination pair and rejects Output/CellDep/Source/integer retyping. typed_runtime_views passed twice (10/10), checker crate 29/29, artifact checker 36/36, clippy clean. Remaining local scope is persistent-policy/generated-builder parity beyond the current GroupInput data_size/capacity slice; independent review and release evidence remain external gates. No TAC/release/deploy/signing workflow was invoked.

  6. a19q3 commented on Sep 11, 2026

    @a19q3
    CollaboratorAuthor

    Follow-up pushed in b68925e: the final repository-local parity gap is now covered by an exact PolicyWitnessV1 Type-group artifact. The generated action-record encoder and canonical policy-bundle adapter drive a one-input/one-output resource transition that exercises complete GroupInput/GroupOutput, CellDep and HeaderDep views, OutPoint, Since, bounded entry bytes, and raw transaction hash. Exact identities are pinned with 96,109 cycles, 21,368 ELF bytes, 20,000 max stack bytes, 145 witness bytes, 594 transaction bytes, and 73 dependency bytes. typed_runtime_views passed twice at 11/11. The ledger now leaves only independent review (and the documented CI/backend/release gates) before #24 closure; I am not self-certifying those external gates. No TAC/release/deploy/signing workflow was invoked.

  7. a19q3 commented on Sep 12, 2026

    @a19q3
    CollaboratorAuthor

    0.30 closure update: the bounded typed CKB transaction-view/runtime-adapter contract is complete. The admitted v1 surface covers typed Cell/Input/Output/CellDep/Header/WitnessArgs/Script/hash/source operations without a raw-syscall escape hatch, including dynamic source indexes, exact OutPoint provenance, persistent-policy use, and the generated PolicyWitnessV1 builder path.

    Five exact non-cryptographic resource profiles and adversarial CKB-VM coverage bind the complete read-only handle table. The clean release replay at 3cf60a1 passed with all Rust tests, strict backend audit, Clippy -D warnings, product builds, and pinned CKB 0.207.0 production admission. Independent review was explicitly waived by the maintainer for this bounded 0.30 scope; it was not performed or claimed as passed. Full-header hashing and an in-language multisig-prefix signing transform remain explicitly excluded. Closing as complete.

  8. a19q3 commented on Sep 19, 2026

    @a19q3
    CollaboratorAuthor

    Documentation follow-up: #24 remains correctly closed for the accepted bounded runtime-view v1 contract. The runtime matrix still contained an old "issue remains open" paragraph and development-only status; those have been corrected in the current audit update.

    Implementation candidate 74cff5fd passed dev, full ci within release, backend, and release, including the typed-runtime-view fixtures and fresh pinned CKB production/stateful acceptance. Independent review was explicitly waived by the maintainer, not performed or reported as passed. Full-header hashing and an in-language multisig-prefix transform remain outside the admitted scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions