Cap'n Proto
A zero-copy serialization protocol used for inter-grain RPC in the Sails.to platform, eliminating encoding/decoding overhead entirely.
Full Definition
Cap'n Proto is a data serialization and RPC protocol designed for absolute speed. Unlike JSON, Protobuf, or any format that wastes cycles marshalling data between wire format and in-memory representation, Cap'n Proto uses the same layout for both. Zero copies. Zero parsing. The bytes on the wire are the data structure in memory. On the Sails.to platform, Cap'n Proto is the native protocol for all inter-grain communication, operating on file descriptor 3 (FD3) for direct Sandstorm integration.
Why It Matters
When a DAO Manager grain needs to coordinate with an Offering grain, or a Broker Portal queries KYC status, every microsecond of serialization overhead is wasted time. Cap'n Proto eliminates that overhead completely. The protocol was purpose-built for capability-based systems — it doesn't just move data, it moves capabilities. A Cap'n Proto RPC call can pass live references to objects across grain boundaries, which is exactly how the Powerbox mechanism delegates authority.
This is not a nice-to-have optimization. When you're running regulated financial infrastructure where compliance checks must execute on every transfer, serialization speed is a systemic constraint. Cap'n Proto removes it from the equation entirely.
How It Works
- Grains expose Cap'n Proto interfaces defined in .capnp schema files
- When Grain A calls Grain B, the request is written directly to FD3 — no HTTP, no REST, no encoding step
- Grain B reads the request as a native in-memory data structure — zero deserialization
- Capability references (sturdyRefs) can be embedded in messages, enabling the Powerbox to pass live object references between grains
- Responses flow back on the same channel with the same zero-copy guarantee
The result: inter-grain RPC with latency measured in microseconds, not milliseconds.
Related Terms
Speed without compromise
Zero-copy serialization powering institutional-grade financial infrastructure.
Learn More