You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Design an explicit, typed abstraction for opening, reading, updating, and recommitting digest-backed substate while keeping the parent Cell schema stable.
The target use case is an extensible capsule or plugin state: a shared base schema stores a commitment, while a concrete implementation supplies a typed preimage through a versioned witness, proves that the preimage matches the stored commitment, applies checked logic, and commits the successor substate.
Argent's virtual-slot state expansion demonstrates this application pattern. CellScript should preserve its stronger explicit-schema rule: the commitment field and witness opening must remain visible in source, ABI, ProofPlan, and metadata. The compiler must not inject hidden persistent fields.
Motivation
A stable external state shape is useful when independently developed implementations need private or implementation-specific memory:
Stable public capsule:
- controller identity
- implementation/interface handle
- strategy commitment
- energy / nonce / public counters
Implementation-private committed state:
- strategy parameters
- model memory
- plugin configuration
- bounded auxiliary state
Today an author can manually hash witness bytes and compare them to a Hash field, but the compiler cannot prove that:
both sides use the same canonical schema;
the hash has the correct domain separation;
the preimage is decoded exactly once;
every read comes from an authenticated opening;
every mutation is reflected in the successor commitment;
metadata and builders use the same witness codec;
the checker can link source-level commitment semantics to machine code.
Explicit source model
The final syntax requires an RFC. A strawman illustrates the intended visibility:
The parent schema stores only the commitment. The opening is transaction evidence, not persistent hidden state.
flowchart LR
CELL["Input Cell data<br/>typed base schema"] --> DIGEST["Stored commitment"]
WIT["WitnessArgs opening<br/>versioned Molecule T"] --> DECODE["Decode T once"]
DECODE --> HASH["Domain-separated canonical hash"]
DIGEST --> MATCH{"hash == commitment?"}
HASH --> MATCH
MATCH -- "no" --> REJECT["Stable opening error"]
MATCH -- "yes" --> VALUE["Authenticated typed T"]
VALUE --> UPDATE["Compute next T"]
UPDATE --> COMMIT["Commit canonical next T"]
COMMIT --> OUT["Constrain output commitment"]
Loading
Required semantic properties
Typed commitment identity
Commitment<T, H, Domain> must include, directly or through canonical metadata identity:
source type identity of T;
registered serialization profile, type identity, and profile version;
hash algorithm/profile;
domain-separation identifier;
fixed/dynamic size bounds;
compatibility identity.
A commitment to StrategyStateV1 must not be interchangeable with the same bytes interpreted as another type.
Authenticated opening
An Opening<T> must:
come from an explicit witness/source qualifier;
use a versioned canonical codec;
be decoded once with strict bounds;
be hashed over the exact canonical bytes;
become a typed value only after the digest comparison succeeds;
never escape as an authenticated value on a failure path.
Successor correspondence
When source semantics claim an updated committed substate:
the successor value must be evaluated once;
the output commitment must be derived from the exact typed successor;
no path may preserve the old digest while using mutated private state;
no path may construct a digest from noncanonical bytes;
linear Cell effects must remain explicit on the parent Cell.
No behavioral inference
Matching a base capsule or interface shape does not prove that an external implementation follows a desired behavior. This feature authenticates state openings and updates; it does not establish semantic equivalence between plugins.
Hash and codec requirements
The first fixed-width version should build on the existing CellScriptPackedHashV0\0 preimage contract used by hash_blake2b_packed instead of silently inventing a second encoding:
. Phase 0 must decide whether its current type-name component is stable and canonical enough for a public commitment identity or whether a registered successor profile is required. In either case, the profile must bind CKB Blake2b-256, type identity, width, exact packed bytes, explicit preimage limits, metadata identity, and deterministic vectors shared by compiler, builder, simulator, CKB-VM, and checker.
Do not describe the fixed-width packed representation as Molecule. Bounded dynamic Molecule values require a separate registered codec/profile after the strict offset/count work in #7 and #8. Additional hash algorithms likewise require separate registered profiles; do not accept a free-form hash function parameter.
Representation options to decide
The RFC must choose and document:
Question
Required decision
commitment bytes
raw 32 bytes versus a nominal fixed-width wrapper
domain separation
type-derived, declaration-derived, or explicit registered domain
witness placement
input_type, output_type, lock, or declared source
dynamic fields
initial fixed-width-only boundary versus bounded Molecule dynamics
nested commitments
reject initially or define depth and size budgets
optional openings
explicit enum/Option semantics; no empty-witness ambiguity
unchanged state
require opening, or permit digest-preserving paths that never read private fields
package upgrade
how compatible schema evolution affects commitment identity
Implementation phases
Phase 0 — RFC and threat model
Cover:
type/codec/hash/domain identity;
witness source and size bounds;
opening validity and evaluation order;
unchanged versus updated paths;
nested/dynamic limits;
interface and package compatibility;
error codes;
ProofPlan and checker obligations.
Phase 1 — fixed-width committed values
implement Commitment<T> and Opening<T> for fixed-width non-Cell values;
add canonical commit/open operations;
retain all source qualifiers and identities in typed semantics;
Summary
Design an explicit, typed abstraction for opening, reading, updating, and recommitting digest-backed substate while keeping the parent Cell schema stable.
The target use case is an extensible capsule or plugin state: a shared base schema stores a commitment, while a concrete implementation supplies a typed preimage through a versioned witness, proves that the preimage matches the stored commitment, applies checked logic, and commits the successor substate.
Argent's virtual-slot state expansion demonstrates this application pattern. CellScript should preserve its stronger explicit-schema rule: the commitment field and witness opening must remain visible in source, ABI, ProofPlan, and metadata. The compiler must not inject hidden persistent fields.
Motivation
A stable external state shape is useful when independently developed implementations need private or implementation-specific memory:
Today an author can manually hash witness bytes and compare them to a
Hashfield, but the compiler cannot prove that:Explicit source model
The final syntax requires an RFC. A strawman illustrates the intended visibility:
The parent schema stores only the commitment. The opening is transaction evidence, not persistent hidden state.
flowchart LR CELL["Input Cell data<br/>typed base schema"] --> DIGEST["Stored commitment"] WIT["WitnessArgs opening<br/>versioned Molecule T"] --> DECODE["Decode T once"] DECODE --> HASH["Domain-separated canonical hash"] DIGEST --> MATCH{"hash == commitment?"} HASH --> MATCH MATCH -- "no" --> REJECT["Stable opening error"] MATCH -- "yes" --> VALUE["Authenticated typed T"] VALUE --> UPDATE["Compute next T"] UPDATE --> COMMIT["Commit canonical next T"] COMMIT --> OUT["Constrain output commitment"]Required semantic properties
Typed commitment identity
Commitment<T, H, Domain>must include, directly or through canonical metadata identity:T;A commitment to
StrategyStateV1must not be interchangeable with the same bytes interpreted as another type.Authenticated opening
An
Opening<T>must:Successor correspondence
When source semantics claim an updated committed substate:
No behavioral inference
Matching a base capsule or interface shape does not prove that an external implementation follows a desired behavior. This feature authenticates state openings and updates; it does not establish semantic equivalence between plugins.
Hash and codec requirements
The first fixed-width version should build on the existing
CellScriptPackedHashV0\0preimage contract used byhash_blake2b_packedinstead of silently inventing a second encoding:CellScriptPackedHashV0\0 || type_name || 0 || width_u32_le || exact packed bytesThe current implementation is visible at
CellScript/src/codegen/calls.rs
Lines 54 to 105 in 8ae6dc4
Do not describe the fixed-width packed representation as Molecule. Bounded dynamic Molecule values require a separate registered codec/profile after the strict offset/count work in #7 and #8. Additional hash algorithms likewise require separate registered profiles; do not accept a free-form hash function parameter.
Representation options to decide
The RFC must choose and document:
input_type,output_type, lock, or declared sourceImplementation phases
Phase 0 — RFC and threat model
Cover:
Phase 1 — fixed-width committed values
Commitment<T>andOpening<T>for fixed-width non-Cell values;Phase 2 — successor updates
Phase 3 — bounded dynamic values
Only after fixed-width stabilization:
Adversarial matrix
Completion criteria
Non-goals
Relationship to other work
References