Introduction
The Actor VM is Cowboy’s deterministic Python execution environment. It enables developers to write smart contracts in Python while maintaining the strict determinism and security requirements of a blockchain protocol.Note: Examples in this page are conceptual snippets/pseudocode. Final interfaces and usage should follow the SDK and Developer Guide. CIP specifications define normative protocol behavior.
Actor Model Fundamentals
What is an Actor?
An Actor is an independent entity with:Core Properties
Isolated State
Isolated State
Each actor has its own storage. No shared memory between actors. Persistent state MUST use protocol storage APIs; in-memory variables are ephemeral per invocation.
Message-Driven
Message-Driven
Communication happens via asynchronous messages; avoid synchronous assumptions about order.
Single-Threaded
Single-Threaded
One message processed at a time. No concurrency within an actor.
Autonomous
Autonomous
Can schedule its own future execution via timers (see CIP-1).
Python VM Architecture
Execution Flow
VM Components
- Interpreter
- Memory Manager
- Sandbox
- Metering
Pure bytecode interpretation (no JIT)Key properties:
- Deterministic: Same bytecode → same execution
- Metered: Every instruction charged
- Sandboxed: No escape to host system
Determinism Guarantees
Cowboy’s VM enforces determinism: given the same input, all nodes produce identical output.Determinism Requirements
1
No System Dependencies
No access to:
- System time
- Local randomness
- File system
- Network
- Environment variables
2
Deterministic Arithmetic
All floating-point operations use a software implementation of IEEE 754.
3
Deterministic Memory Management
Reference counting with immediate cleanup; destruction costs are metered in Cycles per CIP‑3.
4
No JIT Compilation
Pure interpretation only; JIT is prohibited.
5
Dictionary Ordering and Serialization
Do not rely on in-memory iteration order when results depend on ordering. When order matters, sort keys explicitly. During serialization, dictionary keys MUST be sorted lexicographically (CIP‑3) to ensure determinism.
Testing Determinism
A determinism test suite verifies that identical inputs produce identical outputs and state transitions across environments, covering instruction metering, serialization (sorted keys), exception handling costs, and software floating‑point behavior.Resource Limits
Per-call resource limits and protocol constraints prevent DoS attacks:- Cycles: Instruction-level metering with protocol-defined hard limits (CIP‑3)
- Cells: Data/IO metering with protocol-defined hard limits (CIP‑3)
- Memory: Per-transaction/per-call heap memory hard limit per CIP‑3
- Integer Size: 4096-bit maximum; exceeding raises OverflowError (CIP‑3)
- Stack/Recursion: Protocol-defined limits to prevent unbounded depth
- Storage Size: Per-actor quotas with rent/pruning policies per protocol
Protocol Host Functions (Categories)
Actors interact with the protocol via deterministic, metered host functions (non-exhaustive categories):- Storage: Persistent key/value operations; blob commits for large content-addressed data
- Messaging: Asynchronous message send/receive
- Timers: Schedule/cancel per CIP‑1; execution prioritized via GBA under per-block timer budget
- Cryptography: Hashing and signature verification; VRF access via protocol APIs
Best Practices
Minimize Storage Writes
Minimize Storage Writes
Batch writes where possible to reduce Cells; design data layout to minimize serialization overhead.
Control Input Size
Control Input Size
Validate input sizes early; avoid unbounded loops; fail fast on invalid data.
Deterministic Ordering
Deterministic Ordering
Sort keys or items when order affects results; rely on CIP‑3 serialization guarantees.
Next Steps
Determinism & Sandbox
Deep dive into how determinism is achieved
Resource Limits
Detailed specification of all resource limits
Minimal Actor Example
Build your first actor step-by-step
Fee Model
Understand Cycles and Cells metering

